Skip to content

refactor(playwright): sign in through a fixture, not the form - #33219

Merged
chirag-madlani merged 4 commits into
flake/3-signed-in-page-fixturesfrom
flake/4-signin-migration
Sep 28, 2026
Merged

chirag-madlani merged 4 commits into
flake/3-signed-in-page-fixturesfrom
flake/4-signin-migration

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

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(), and openmetadata-playwright/prefer-role-page-fixture goes to error with 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 a UserClass would not compile, and the playwright tsc count 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.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 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.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.

The rule already works

While rebasing onto a main that had moved 62 commits, the rule caught a brand-new nonAsciiUser.login(page) that arrived in Login.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:

Run Result
TaskComments + Users + EntityPermissions 85 passed
9 densest migrated specs 81 passed (the 8 failures were an expired admin token, confirmed by re-minting → 17/17 clean)
RoleFixtureSessions + TokenStorage + TaskComments + TasksUIFlow on the rebased tip 35 passed

Coverage 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() sharing completeSignIn(). CI is the real gate — and thanks to #33217, any failure will now name the step that hung.

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The behavioral migration appears sound, but the outstanding explicit repository requirement concerning obvious restatement comments must be satisfied before merging.

Findings

  1. P1 Blocking Rule Breaks Lint ▶
  2. P2 Rule Documentation Is Stale ▶
  3. P2 Comments Restate Obvious Code ▶
  4. P2 Fixture Suppressions Violate Policy ▶
Summary

This PR migrates bespoke Playwright users from form-driven login() calls to API-backed signIn(), enforces that migration with an ESLint rule, and documents the remaining route-sensitive exemptions.

  • Replaces hundreds of form sign-ins while preserving shared post-sign-in handling.
  • Adds lint coverage for prohibited login() calls and enables the rule as an error.
  • Adds a lightweight same-origin primer for token storage and supports both classic and AI application shells.
  • Updates Playwright guidance and tests for the new authentication path.
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 --> Complete
Loading

Reviews (22) · Last reviewed commit: "fix(playwright): accept the AI shell as ..."

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 766 → 766
- 0 added, 0 removed, 5 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/support/fixtures/userPages.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/tokenStorage.ts
  openmetadata-ui/src/main/resources/ui/src/components/MyData/LeftSidebar/LeftSidebar.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/UserProfileIcon/UserProfileIcon.component.tsx
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts

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 getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

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',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Blocking Rule Breaks Lint

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.

Comment on lines +132 to +133
* 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Rule Documentation Is Stale

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.

Suggested change
* 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Comments Restate Obvious Code

“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!

Comment on lines 113 to 114
// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.
@gitar-bot

gitar-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown
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 login() to API-backed signIn() fixture, with the prefer-role-page-fixture ESLint rule now enforced as an error. Nine route-sensitive exemptions are explicitly documented with justified disables, and the rule's JSDoc has been updated to reflect the error-level enforcement. No issues found.

✅ 1 closed
✅ Quality: Rule JSDoc still says it runs at warn, but it is now error

📄 openmetadata-ui/src/main/resources/ui/eslint-rules/openmetadata-playwright.mjs:132-133 📄 openmetadata-ui/src/main/resources/ui/eslint.config.mjs:638
The JSDoc block added for preferRolePageFixture ends with "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." This contradicts the actual behavior introduced by this same PR: eslint.config.mjs sets the rule to error and the corpus has been fully migrated. The comment will mislead future readers about the rule's severity and rationale; update it to reflect the error promotion (or drop the warn justification).

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants