Repository navigation
test(e2e): workspace auth refresh races — cloud E2E coverage - #12940
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ChangesWorkspace Auth Refresh Browser Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 6 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🎭 Playwright: ✅ 1723 passed, 0 failed · 2 flaky📊 Browser Reports
📦 Bundle: 8.03 MB gzip ⚪ 0 BDetailsSummary
Category Glance App Entry Points — 47.5 kB (baseline 47.5 kB) • ⚪ 0 BMain entry bundles and manifests Status: 1 unchanged Graph Workspace — 1.25 MB (baseline 1.25 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration Status: 2 unchanged Views & Navigation — 112 kB (baseline 112 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces Status: 16 unchanged Panels & Settings — 551 kB (baseline 551 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens Status: 26 unchanged User & Accounts — 29.1 kB (baseline 29.1 kB) • ⚪ 0 BAuthentication, profile, and account management bundles Status: 10 unchanged Editors & Dialogs — 121 kB (baseline 121 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors Status: 6 unchanged UI Components — 64.7 kB (baseline 64.7 kB) • ⚪ 0 BReusable component library chunks Status: 14 unchanged Data & Services — 271 kB (baseline 271 kB) • ⚪ 0 BStores, services, APIs, and repositories Status: 16 unchanged Utilities & Hooks — 3.45 MB (baseline 3.45 MB) • ⚪ 0 BHelpers, composables, and utility bundles Status: 36 unchanged Vendor & Third-Party — 15.7 MB (baseline 15.7 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 16 unchanged Other — 12.1 MB (baseline 12.1 MB) • ⚪ 0 BBundles that do not match a named category Status: 273 unchanged ⚡ Performance
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@browser_tests/tests/workspaceAuthRefresh.spec.ts`:
- Around line 186-190: The exact equality check in the await expect.poll
assertion on callCount is brittle and causes race conditions where refresh
retries might increment callCount beyond 2 before the poll samples the value,
creating nondeterministic test failures. Replace the `.toBe(2)` assertion with
`.toBeGreaterThanOrEqual(2)` to allow the test to pass with callCount 2 or
higher, or instead assert an external state condition (such as verifying the
token is preserved or the session state) that validates the actual behavior
being tested rather than checking an exact timing snapshot.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a2d9466b-831d-4923-8792-a1b8e74244ad
📒 Files selected for processing (1)
browser_tests/tests/workspaceAuthRefresh.spec.ts
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #12940 +/- ##
==========================================
- Coverage 78.92% 78.84% -0.08%
==========================================
Files 1692 1692
Lines 95679 95890 +211
Branches 29601 29568 -33
==========================================
+ Hits 75513 75609 +96
- Misses 19779 19891 +112
- Partials 387 390 +3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
6a8db97 to
7b06203
Compare
Addresses review feedback: #12940 (comment)
Addresses review feedback: #12940 (comment)
Addresses review feedback: #12940 (comment)
Addresses review feedback: #12940 (comment)
8917704 to
a4ddb3f
Compare
Covers token persistence, workspace-switch replacement, transient 500 preservation, and 403 ACCESS_DENIED session clearing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ertions - Add two-step open: profile popover → workspace-switcher-trigger → workspace item (clicking the trigger div opens the panel; only clicking an item calls switchWorkspace) - Replace bare expect() after click with expect.poll() to wait for async switchWorkspace - Import Page type from @playwright/test instead of inline import() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…licit switches teamWorkspaceStore.initialize() auto-selects Personal Workspace on boot and calls switchWorkspace → /api/auth/token. useWorkspaceSwitch skips switchWorkspace when the target is already active, so clicking Personal Workspace in the panel after init is a no-op. Fix: - Add default /api/auth/token stub in the fixture to absorb the init call - Switch to Team Workspace in tests (not the auto-selected Personal one) so the explicit click is always a genuine workspace change - Per-test route mocks are matched LIFO and override the fixture default Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add Escape before re-opening profile popover to avoid toggle-close on double-click, and wait for workspace-switcher-panel to be visible before clicking an item (prevents stale-panel click timeouts) - Remove intermediate 'original-token' assertion in ACCESS_DENIED test: the refresh timer fires at delay≈0 so the token is cleared before the poll can observe it — wait for callCount=2 instead then assert null Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…us matches
getByText() without scoping could match the trigger row label or other
text on the page. Scope all workspace name clicks to
getByTestId('workspace-switcher-panel') to ensure only the list item
button is targeted.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e reloads teamWorkspaceStore.switchWorkspace() calls window.location.reload() after clearing context. The second switch in the back-and-forth test never lands because the page reloads and re-runs init with the fixture-default token mock. Single-switch token persistence is already covered by the first test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Addresses review feedback: #12940 (comment)
Addresses review feedback: #12940 (comment)
a4ddb3f to
a31be1b
Compare
🔀 Rebase & handoff status (2026-07-23)Status: Rebased onto current `main` (was 88 commits behind), ready for final CI pass and merge.
Checklist:
|
useSessionCookie (introduced in #13832) calls /api/auth/session during workspace auth init. Without the stub the cloud test env hangs waiting for the real endpoint, causing workspace-switcher-trigger to never become clickable. Mirrors the same stub already present in workspaceSwitcher.spec.ts.
3f479c7
|
This PR's Consequence is bigger than one failing job: the merge queue re-runs CI: Lint One thing worth your eye rather than mine, since it's your feature: I removed If you intended to gate on a server flag and the frontend side of it simply |
- Select the nudge and its controls by role/accessible name instead of data-testid, and assert cooldown with toBeDisabled(). - Drop the @/i18n mock so the composable tests exercise real translation key resolution. - Run the shared composable inside an effectScope stopped after each test so its window focus listener does not leak across tests. - Use fake timers for the whole resend suite and clear pending timers on teardown. - Cover the focus-triggered refresh after dismissal and the concurrent refresh guard. - Cover emailVerificationNudgeEnabled resolution in useFeatureFlags. Also drop the retired team_workspaces_enabled key from the workspace auth E2E fixture: #14613 removed it from RemoteConfig after #12940 was written, so typecheck:browser fails on main and on every PR that merges it.
## The merge queue is down repo-wide `typecheck:browser` fails on `main`: ``` browser_tests/fixtures/data/workspaceAuthFixtures.ts(6,3): error TS2353: Object literal may only specify known properties, and 'team_workspaces_enabled' does not exist in type 'RemoteConfig'. ``` Because the merge queue re-runs **CI: Lint Format** against the queue branch, this fails there too — so PRs are being **added to the queue and then dequeued without merging**, whatever their own CI said. Two of mine were dequeued this way in the last hour (#14691 at 02:59Z, #14669 at 03:05Z), and four unrelated branches hit the sibling `validate-pins` breakage in the same window. Introduced by #12940 (`e544b2ad90`), merged ~4 hours ago. ## Why removing the key is the right fix `team_workspaces_enabled` appears **exactly once in the entire repository** — this line. No `src/` code reads it. Team workspaces are gated on the workspace's own `type` (`'personal' | 'team'`), not on a remote-config flag, and there is no corresponding entry in `useFeatureFlags`. The fixture was enabling nothing, so `{}` is behaviour-identical. The alternative — adding the key to `RemoteConfig` — would invent frontend API surface that nothing consumes. ## Verification Matched control, same machine, same install: | tree | `pnpm run typecheck:browser` | | ---- | --- | | `origin/main` | **exit 2**, the error above | | this branch | **exit 0** | `pnpm run format:check` clean. ## Relationship to #14955 #14955 contains this same one-line fix, but bundled with an unrelated litegraph subgraph-serialization change. That change looks sound to me, but it deserves review on its own merits by someone who owns litegraph — and the queue outage shouldn't wait on it. This PR is the fixture fix alone so it can land immediately. Whichever merges first, the other's hunk drops out trivially. Co-authored-by: t <t@t.t>
- Select the nudge and its controls by role/accessible name instead of data-testid, and assert cooldown with toBeDisabled(). - Drop the @/i18n mock so the composable tests exercise real translation key resolution. - Run the shared composable inside an effectScope stopped after each test so its window focus listener does not leak across tests. - Use fake timers for the whole resend suite and clear pending timers on teardown. - Cover the focus-triggered refresh after dismissal and the concurrent refresh guard. - Cover emailVerificationNudgeEnabled resolution in useFeatureFlags. Also drop the retired team_workspaces_enabled key from the workspace auth E2E fixture: #14613 removed it from RemoteConfig after #12940 was written, so typecheck:browser fails on main and on every PR that merges it.
Summary
browser_tests/tests/workspaceAuthRefresh.spec.tswith 4@cloud-tagged Playwright tests covering the workspace auth refresh race conditions fixed in fix: guard workspace auth refresh races #11726.waitForTimeout.switchWorkspacewrites token + expiry to sessionStorage/api/auth/tokenmust not clearComfy.Workspace.Token/api/auth/tokenmust null out token + workspaceThe timer-based refresh is triggered by setting
expiresInMsjust belowTOKEN_REFRESH_BUFFER_MS(5 min − 500 ms), causingscheduleTokenRefreshto fire with delay ≈ 0 — no fake timers needed.Test plan
@cloudPlaywright job passes all 4 testspnpm typecheck:browser— cleanpnpm exec eslint+pnpm exec oxlint— cleanFollowup to #11726.
🤖 Generated with Claude Code
🔀 Rebase & handoff status (2026-07-13)
Status: APPROVED + green months ago → rotted on
main(merge-skew) → now rebased onto currentmain→ ready to merge.Rebased onto current
main; refreshed a stale CLA.Note: one flaky
templates.spec.tsshard is UNRELATED to this PR (209 tests passed in that shard). A CI re-run clears it.Rebased onto current
mainStale CLA refreshed
Re-run CI to clear the unrelated
templates.spec.tsflakeReady to merge — assigned to @christian-byrne