chore(playwright): remove unnecessary global auth checks#8341
chore(playwright): remove unnecessary global auth checks#8341
Conversation
Greptile OverviewGreptile SummaryThis PR simplifies Playwright E2E authentication by removing browser-driven global auth checks and switching auth helpers to API-based login via Playwright request contexts.
These changes fit the existing E2E testing approach where global-setup prepares reusable storageState files and individual specs either use Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant PW as Playwright Global Setup
participant Req as APIRequestContext
participant Next as Next.js /api proxy
participant BE as Backend (FastAPI)
PW->>Req: request.newContext({ baseURL })
Req->>Next: POST /api/auth/register (admin/user/admin2)
Next->>BE: POST /auth/register
BE-->>Next: 200 or 400 REGISTER_USER_ALREADY_EXISTS
Next-->>Req: response
Req->>Next: POST /api/auth/login (form: username,password)
Next->>BE: POST /auth/login
BE-->>Next: 200 + Set-Cookie fastapiusersauth
Next-->>Req: 200 + Set-Cookie
Req->>Req: storageState({path: admin_auth.json})
PW->>Req: request.newContext({ storageState: admin_auth.json })
Req->>Next: PATCH /api/manage/set-user-role
Next->>BE: PATCH /manage/set-user-role
BE-->>Next: 200 (admin2 promoted)
Next-->>Req: 200
PW->>Req: Repeat login & storageState for user_auth.json and admin2_auth.json
participant Test as Playwright Test (UI)
participant Page as Browser Page
Test->>Page: goto /auth/login, fill, click Sign In
Page->>Next: POST /api/auth/login
Next->>BE: POST /auth/login
BE-->>Next: Set-Cookie fastapiusersauth
Next-->>Page: Set-Cookie
Test->>Page: expect URL /app
Test->>Page: page.request.get(/api/me)
Page->>Next: GET /api/me (Cookie)
Next->>BE: GET /me
BE-->>Next: 200 user info
Next-->>Page: 200 user info
|
justin-tahara
left a comment
There was a problem hiding this comment.
I'm pretty sure my comment is not an issue
| await page.getByTestId("password").fill(password); | ||
| await page.getByRole("button", { name: "Sign In" }).click(); | ||
|
|
||
| await expect(page).toHaveURL(/\/app/); |
There was a problem hiding this comment.
I'm sure this shouldn't be an issue anymore but we don't need to check for any /chat endpoints right?
There was a problem hiding this comment.
Shouldn't need to. We could maybe add a test that asserts /chat redirects to /app for backwards compatibility, but not sure it'd belong here (or is really all that interesting).
|
Preview Deployment
|
e9dbb7c to
a37bfed
Compare
There was a problem hiding this comment.
1 issue found across 15 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="web/tests/e2e/global-setup.ts">
<violation number="1" location="web/tests/e2e/global-setup.ts:215">
P2: OnyxApiClient ignores the Playwright-configured baseURL and always uses BASE_URL/localhost. With this new usage in global-setup, running tests against a non-default baseURL will still call localhost, so the public provider setup can fail or target the wrong backend. Consider passing the config baseURL into OnyxApiClient (or deriving it from the request context) so it uses the same host as the rest of global-setup.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Description
Currently, there is a global check during setup that confirms that the
admin,admin2, anduseraccounts can all login from the UI. We don't really need to check this -- we can just have the user creation pre-flight workflow fail in that case.Moreover, replaces the
auth.tsflow which performed browser-based login with an API-based for faster individual test running.Also adds an explicit test for auth to cover the UI functionality spec (previously this was only assumed covered by these auth utils).
Seems to save about 2 min in CI for the
adminplaywright job 🚀How Has This Been Tested?
Takes about
16slocally now compared to29spreviously + has fewer403and similar error messages spamming the console.Additional Options
Summary by cubic
Removed global UI auth checks and switched Playwright auth to API login for faster, quieter runs. Global setup now saves storage state via API and ensures a default public LLM provider; added explicit login UI tests.
Refactors
New Features
Written for commit 92f0d3f. Summary will update on new commits.