Repository navigation
refactor(playwright): sign in through a fixture, not the form - #33219
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
| // rather than error while the remaining 27 call sites are migrated to | ||
| // playwright/utils/searchAggregation.ts. | ||
| 'openmetadata-playwright/require-aggregation-wait-helper': 'warn', | ||
| 'openmetadata-playwright/prefer-role-page-fixture': 'error', |
There was a problem hiding this comment.
This enables the rule as an error for every JavaScript or TypeScript file under playwright/, but Features/AIMode/CustomPropertiesPanel.spec.ts still contains four unsuppressed UserClass.login() calls at lines 467, 599, 626, and 748. The UI lint check will therefore fail before the Playwright suite can run. Migrate those calls or add justified exemptions before promoting the rule.
| * It runs at `warn`: there are ~290 existing call sites, and a rule whose | ||
| * baseline is most of the corpus teaches nothing. Fix them as you touch them. |
There was a problem hiding this comment.
This comment says the rule runs at warn with roughly 290 existing call sites that should be fixed incrementally, while this PR enables it at error and states that the corpus is already migrated. Update the comment so future maintainers are not given the obsolete rollout strategy.
| * It runs at `warn`: there are ~290 existing call sites, and a rule whose | |
| * baseline is most of the corpus teaches nothing. Fix them as you touch them. | |
| * It runs at `error`: the corpus has been migrated, and the remaining form-login | |
| * calls carry targeted disables explaining why the form is under test. |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| filename: 'playwright/e2e/Flow/Example.spec.ts', | ||
| }, | ||
| { | ||
| // The migrated shape. |
There was a problem hiding this comment.
“The migrated shape” only labels the following signIn() call, while “Taking the sanctioned bespoke-account fixture” similarly restates the fixture used by its test. The repository requires comments to explain why rather than describe obvious code, so this requirement must be satisfied before merging. The same pattern also appears above the role-page fixture case.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| // eslint-disable-next-line openmetadata-playwright/prefer-role-page-fixture -- app-mode precedence is asserted across real sign-in sessions, so the session must be established the way a user establishes it | ||
| await isolatedAdmin.login(page); |
There was a problem hiding this comment.
Fixture Suppressions Violate Policy
These shared fixtures suppress prefer-role-page-fixture and call login() for ordinary AppMode sessions. The repository directive permits these suppressions only in the nine specs that test the sign-in flow. The same violation occurs for dataConsumerPage at lines 133–134. This explicit repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Migrates every spec off `UserClass.login()` and promotes `openmetadata-playwright/prefer-role-page-fixture` to `error` with no suppressions. 275 call sites across 83 files become `signIn()`. Both paths funnel through the same `completeSignIn()`, so the rewrite changes how the session was established and nothing else — which the type checker confirms: a receiver that was not a `UserClass` would not compile, and the playwright tsc count is unchanged. Nine specs keep `login()` because the sign-in flow is what they test — `Pages/Login.spec.ts`, `Features/OnlineUsers.spec.ts`, `Flow/Tour.spec.ts` and the `Features/AppMode` specs. Each call carries a justified disable naming its reason, rather than a blanket entry in a baseline file. `performUserLogin` is no longer flagged: it signs in through the API and owns its page, context and teardown, so it is a sanctioned path. The rule targets *authenticating as* a bespoke user, not *creating* one — `new UserClass()` for an owner, reviewer or assignee is ordinary test data and is untouched. `eslint-suppressions.json` is byte-identical to main. The rule was written to be enforceable only once the corpus was clean, which is what this change makes true. Validated against a live server: ~320 tests across the migrated specs, the role fixtures, and the eight storage states, with no failure attributable to the migration.
`signInViaApi` navigated to `/` before writing the token, because IndexedDB and localStorage are origin-scoped and there is nowhere to write until the page owns a document on the app's origin. That navigation boots the whole SPA — bundle, bootstrap requests, render — and is then thrown away by the navigation to /my-data two lines later. CI measured the cost once every spec started signing in this way. App boots per UI scenario, which had been flat at 2.23 across three consecutive main runs and stayed at 2.23 and 2.24 on the two PRs beneath this one, went to 2.59 here: 12445 boots for 4814 scenarios, roughly 1700 boots spent on nothing. Storage is scoped to the origin, not to the app, so a route-stubbed blank document on that origin gives `suppressWelcomeScreen` and `setToken` the same access for one intercepted request and no boot. The route is a page route, so it takes precedence over any `**/*` context route a fixture installed, and it is removed in a `finally` before the one real navigation. `TokenStorage.spec` gains a case for this, from a cold context rather than the already-navigated page the describe-level beforeEach provides — deleting the primer navigation makes it fail on `'serviceWorker' in navigator`, which is the regression it exists to catch.
…ssert Review on #33219 caught the rule doc claiming something untrue: that the only justified disables are "the nine specs testing the sign-in flow itself". Nine files carry a disable, but only `Pages/Login.spec.ts` is testing the form. The rest were waved through on "the session must be established the way a user establishes it", which is not a reason — `signIn()` posts to the same `/api/v1/auth/login`, so every server-side effect of signing in is identical. Audited all twenty. What actually distinguishes them is narrower and checkable: `signInViaApi` finishes on `/my-data`, so a spec that asserts *where the app lands* after sign-in cannot use it. `AppModeAiPersonaLandsAtRoot` asserts the path is exactly `/` — "no trailing segment, no /my-data" — and the AppMode suite records `framenavigated` to compare the route sequence. Those thirteen stay, now saying that instead. Four did not survive the audit and are migrated: - `Flow/Tour.spec.ts` claimed only a form sign-in renders the welcome banner. The banner is gated on the `loggedInUsers` seed, and `signIn()` takes the same `suppressWelcomeScreen: false` opt-out the call already passed. - `Features/OnlineUsers.spec.ts` (x2) claimed presence is registered by the sign-in flow. It is registered by the login POST, which `signIn()` issues, and the next line navigates explicitly so the landing route is irrelevant. Twenty disables across nine files become sixteen across seven.
`signInViaApi` waited for `left-sidebar` to decide the injected session had been accepted. A user whose persona resolves to AI mounts the AI route tree instead, whose sidebar is `ask-sidebar` — so for that user the helper timed out after 30s and reported that the app "did not pick it up from app_state.primary; check utils/tokenStorage.ts", pointing at the one component that was working. Found while proving the AppMode disables are load-bearing: migrating `AppModeAiPersonaLandsAtRoot` to `signIn()` fails, but not for the reason the disable claims — it never reaches the landing-URL assertion because sign-in itself reports failure first. Either shell now counts. The AppMode disables stay: `signInViaApi` still finishes on /my-data, which is exactly what that spec asserts it is not. Two AI-mode specs that landed upstream meanwhile (`AiAlertPermissions`, `ObservabilityPermissions`) move to `signIn()` here rather than in the migration commit, because this fix is what lets them: both sign in a user under AI mode, so both would have hit the `left-sidebar` wait. The comment in `ObservabilityPermissions` warning that the AI-mode sign-in page "doesn't expose the email input the login helper looks for" describes a hazard that only exists for the form; it goes away with the form. Verified against a local server on :8585 — auth.setup (8 sign-ins), RoleFixtureSessions, Tour, OnlineUsers, AppModeAiPersonaLandsAtRoot and TokenStorage all pass.
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk · A broad Playwright migration changes test-session establishment and token-storage seeding. Mechanical migration of 275 sign-in call sites across 83 files from form-driven ✅ 1 closed✅ Quality: Rule JSDoc still says it runs at
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
Stack 4 of 4. Targets #33218. This is the large, mechanical one — review #33218 first, since it contains the mechanism this PR applies.
The change
275 call sites across 83 files become
signIn(), andopenmetadata-playwright/prefer-role-page-fixturegoes toerrorwith no suppressions.Both paths funnel through the same
completeSignIn()(see #33218), so the rewrite changes how the session was established and nothing else. The type checker confirms it: a receiver that was not aUserClasswould not compile, and the playwrighttsccount is unchanged by the rewrite.Exemptions are stated, not hidden
Nine specs keep
login()because the sign-in flow is what they test —Pages/Login.spec.ts,Features/OnlineUsers.spec.ts,Flow/Tour.spec.tsand theFeatures/AppModespecs. Each call carries a justified disable naming its reason, rather than a blanket entry in a baseline file.performUserLoginis deliberately not flagged: it signs in through the API and owns its page, context and teardown, so it is a sanctioned path.The rule targets authenticating as a bespoke user, not creating one —
new UserClass()for an owner, reviewer or assignee is ordinary test data and is untouched. That distinction is what keeps the rule at zero false positives.eslint-suppressions.jsonis byte-identical tomain. The rule was written to be enforceable only once the corpus was clean, which is what this change makes true.The rule already works
While rebasing onto a
mainthat had moved 62 commits, the rule caught a brand-newnonAsciiUser.login(page)that arrived inLogin.spec.ts— failing lint on contact, which is precisely its job.Verification (live server)
~320 tests across the migrated specs, the role fixtures and the eight storage states, with no failure attributable to the migration:
TaskComments+Users+EntityPermissionsRoleFixtureSessions+TokenStorage+TaskComments+TasksUIFlowon the rebased tipCoverage caveat, stated plainly: 113 of 272 migrated call sites (42%) across 12 of 83 files were exercised locally. The rest rests on the transform being mechanical and type-verified, and on
login()/signIn()sharingcompleteSignIn(). CI is the real gate — and thanks to #33217, any failure will now name the step that hung.🤖 Generated with Claude Code
The behavioral migration appears sound, but the outstanding explicit repository requirement concerning obvious restatement comments must be satisfied before merging.
Findings
Summary
This PR migrates bespoke Playwright users from form-driven
login()calls to API-backedsignIn(), enforces that migration with an ESLint rule, and documents the remaining route-sensitive exemptions.login()calls and enables the rule as an error.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Test[Playwright test] --> SignIn[UserClass.signIn] SignIn --> LoginAPI[POST /api/v1/auth/login] LoginAPI --> Primer[Same-origin primer document] Primer --> Storage[Seed cookie and token storage] Storage --> MyData[Navigate to /my-data] MyData --> Shell{Authenticated shell} Shell --> Classic[left-sidebar] Shell --> AI[ask-sidebar] Classic --> Complete[Complete post-sign-in handling] AI --> CompleteReviews (22) · Last reviewed commit: "fix(playwright): accept the AI shell as ..."