From 2dfff6b7882336ea2a0ed5396046172eef104f83 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 18 Jun 2026 01:53:11 +0000 Subject: [PATCH 01/12] test(e2e): add cloud E2E tests for workspace auth refresh races Covers token persistence, workspace-switch replacement, transient 500 preservation, and 403 ACCESS_DENIED session clearing. Co-Authored-By: Claude Sonnet 4.6 --- .../tests/workspaceAuthRefresh.spec.ts | 247 ++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 browser_tests/tests/workspaceAuthRefresh.spec.ts diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts new file mode 100644 index 00000000000..338f6577901 --- /dev/null +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -0,0 +1,247 @@ +import { expect } from '@playwright/test' + +import type { RemoteConfig } from '@/platform/remoteConfig/types' +import type { WorkspaceWithRole } from '@/platform/workspace/api/workspaceApi' +import type { WorkspaceTokenResponse } from '@/platform/workspace/stores/workspaceAuthStore' +import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' + +const mockRemoteConfig: RemoteConfig = { team_workspaces_enabled: true } + +const mockPersonalWorkspace: WorkspaceWithRole = { + id: 'ws-personal', + name: 'Personal Workspace', + type: 'personal', + created_at: '2026-01-01T00:00:00Z', + joined_at: '2026-01-01T00:00:00Z', + role: 'owner' +} + +const mockTeamWorkspace: WorkspaceWithRole = { + id: 'ws-team', + name: 'Team Workspace', + type: 'team', + created_at: '2026-01-02T00:00:00Z', + joined_at: '2026-01-02T00:00:00Z', + role: 'member' +} + +function makeTokenResponse( + workspace: WorkspaceWithRole, + token: string, + expiresInMs = 60 * 60 * 1000 +): WorkspaceTokenResponse { + return { + token, + expires_at: new Date(Date.now() + expiresInMs).toISOString(), + workspace: { + id: workspace.id, + name: workspace.name, + type: workspace.type + }, + role: workspace.role, + permissions: [] + } +} + +const test = comfyPageFixture.extend({ + page: async ({ page }, use) => { + await page.route('**/api/features', (route) => + route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify(mockRemoteConfig) + }) + ) + + await page.route('**/api/workspaces', async (route) => { + if (route.request().method() !== 'GET') { + await route.fallback() + return + } + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ + workspaces: [mockPersonalWorkspace, mockTeamWorkspace] + }) + }) + }) + + await use(page) + } +}) + +test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { + test('token is persisted to sessionStorage after switching workspace', async ({ + comfyPage + }) => { + const page = comfyPage.page + + await page.route('**/api/auth/token', (route) => + route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify( + makeTokenResponse(mockPersonalWorkspace, 'initial-token') + ) + }) + ) + + await comfyPage.toast.closeToasts() + await page.getByRole('button', { name: 'Current user' }).click() + await page.getByText('Personal Workspace').click() + + const token = await page.evaluate(() => + sessionStorage.getItem('Comfy.Workspace.Token') + ) + expect(token).toBe('initial-token') + + const expiresAt = await page.evaluate(() => + sessionStorage.getItem('Comfy.Workspace.ExpiresAt') + ) + expect(Number(expiresAt)).toBeGreaterThan(Date.now()) + }) + + test('switching to a different workspace replaces sessionStorage token', async ({ + comfyPage + }) => { + const page = comfyPage.page + + let callCount = 0 + await page.route('**/api/auth/token', (route) => { + callCount++ + const body = + callCount === 1 + ? makeTokenResponse(mockPersonalWorkspace, 'personal-token') + : makeTokenResponse(mockTeamWorkspace, 'team-token') + return route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify(body) + }) + }) + + await comfyPage.toast.closeToasts() + await page.getByRole('button', { name: 'Current user' }).click() + await page.getByText('Personal Workspace').click() + + expect( + await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) + ).toBe('personal-token') + + await page.getByRole('button', { name: 'Current user' }).click() + await page.getByTestId('workspace-switcher-trigger').click() + await page.getByText('Team Workspace').click() + + await expect + .poll( + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + { timeout: 5000 } + ) + .toBe('team-token') + + expect( + await page.evaluate(() => + sessionStorage.getItem('Comfy.Workspace.Current') + ) + ).toContain('ws-team') + }) + + test('transient token refresh failure preserves the active workspace session', async ({ + comfyPage + }) => { + const page = comfyPage.page + + // TOKEN_REFRESH_BUFFER_MS is 5 minutes. Setting expiresInMs just below the + // buffer means scheduleTokenRefresh computes delay ≈ 0 and fires immediately. + const expiresInMs = 5 * 60 * 1000 - 500 + let callCount = 0 + + await page.route('**/api/auth/token', (route) => { + callCount++ + if (callCount === 1) { + return route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify( + makeTokenResponse(mockPersonalWorkspace, 'original-token', expiresInMs) + ) + }) + } + return route.fulfill({ + status: 500, + contentType: 'application/json', + body: JSON.stringify({ message: 'Internal Server Error' }) + }) + }) + + await comfyPage.toast.closeToasts() + await page.getByRole('button', { name: 'Current user' }).click() + await page.getByText('Personal Workspace').click() + + expect( + await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) + ).toBe('original-token') + + // The scheduled refresh fires immediately (token expires within buffer window). + // Wait for the second route call (the failing refresh) to complete, then verify + // the token is preserved — a transient 500 must not clear the session. + await expect.poll(() => callCount, { timeout: 5000 }).toBe(2) + + expect( + await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) + ).toBe('original-token') + }) + + test('permanent auth failure (ACCESS_DENIED) clears the workspace session', async ({ + comfyPage + }) => { + const page = comfyPage.page + + // TOKEN_REFRESH_BUFFER_MS is 5 minutes. Setting expiresInMs just below the + // buffer means scheduleTokenRefresh computes delay ≈ 0 and fires immediately. + const expiresInMs = 5 * 60 * 1000 - 500 + let callCount = 0 + + await page.route('**/api/auth/token', (route) => { + callCount++ + if (callCount === 1) { + return route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify( + makeTokenResponse(mockPersonalWorkspace, 'original-token', expiresInMs) + ) + }) + } + return route.fulfill({ + status: 403, + contentType: 'application/json', + body: JSON.stringify({ message: 'Access denied' }) + }) + }) + + await comfyPage.toast.closeToasts() + await page.getByRole('button', { name: 'Current user' }).click() + await page.getByText('Personal Workspace').click() + + expect( + await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) + ).toBe('original-token') + + // The scheduled refresh fires immediately (token expires within buffer window). + // A 403 ACCESS_DENIED response must clear the workspace session entirely. + await expect + .poll( + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + { timeout: 5000 } + ) + .toBeNull() + + expect( + await page.evaluate(() => + sessionStorage.getItem('Comfy.Workspace.Current') + ) + ).toBeNull() + }) +}) From 14b3c0fd9802a169bec19d80be8e1916be09e024 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 18 Jun 2026 01:57:17 +0000 Subject: [PATCH 02/12] [automated] Apply ESLint and Oxfmt fixes --- .../tests/workspaceAuthRefresh.spec.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index 338f6577901..9d3bfc7df65 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -135,7 +135,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await expect .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => + page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBe('team-token') @@ -164,7 +165,11 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { status: 200, contentType: 'application/json', body: JSON.stringify( - makeTokenResponse(mockPersonalWorkspace, 'original-token', expiresInMs) + makeTokenResponse( + mockPersonalWorkspace, + 'original-token', + expiresInMs + ) ) }) } @@ -210,7 +215,11 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { status: 200, contentType: 'application/json', body: JSON.stringify( - makeTokenResponse(mockPersonalWorkspace, 'original-token', expiresInMs) + makeTokenResponse( + mockPersonalWorkspace, + 'original-token', + expiresInMs + ) ) }) } @@ -233,7 +242,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { // A 403 ACCESS_DENIED response must clear the workspace session entirely. await expect .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => + page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBeNull() From 34826d2929c0fad014f1f08c195ab627ed05bba1 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 18 Jun 2026 21:54:34 +0000 Subject: [PATCH 03/12] fix(e2e): correct workspace switch click sequence and use polling assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .../tests/workspaceAuthRefresh.spec.ts | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index 9d3bfc7df65..bba3ace1b45 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -1,4 +1,5 @@ import { expect } from '@playwright/test' +import type { Page } from '@playwright/test' import type { RemoteConfig } from '@/platform/remoteConfig/types' import type { WorkspaceWithRole } from '@/platform/workspace/api/workspaceApi' @@ -71,6 +72,11 @@ const test = comfyPageFixture.extend({ } }) +async function openSwitcherPanel(page: Page): Promise { + await page.getByRole('button', { name: 'Current user' }).click() + await page.getByTestId('workspace-switcher-trigger').click() +} + test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { test('token is persisted to sessionStorage after switching workspace', async ({ comfyPage @@ -88,13 +94,15 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { ) await comfyPage.toast.closeToasts() - await page.getByRole('button', { name: 'Current user' }).click() + await openSwitcherPanel(page) await page.getByText('Personal Workspace').click() - const token = await page.evaluate(() => - sessionStorage.getItem('Comfy.Workspace.Token') - ) - expect(token).toBe('initial-token') + await expect + .poll( + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + { timeout: 5000 } + ) + .toBe('initial-token') const expiresAt = await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.ExpiresAt') @@ -122,15 +130,17 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) await comfyPage.toast.closeToasts() - await page.getByRole('button', { name: 'Current user' }).click() + await openSwitcherPanel(page) await page.getByText('Personal Workspace').click() - expect( - await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) - ).toBe('personal-token') + await expect + .poll( + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + { timeout: 5000 } + ) + .toBe('personal-token') - await page.getByRole('button', { name: 'Current user' }).click() - await page.getByTestId('workspace-switcher-trigger').click() + await openSwitcherPanel(page) await page.getByText('Team Workspace').click() await expect @@ -181,12 +191,15 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) await comfyPage.toast.closeToasts() - await page.getByRole('button', { name: 'Current user' }).click() + await openSwitcherPanel(page) await page.getByText('Personal Workspace').click() - expect( - await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) - ).toBe('original-token') + await expect + .poll( + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + { timeout: 5000 } + ) + .toBe('original-token') // The scheduled refresh fires immediately (token expires within buffer window). // Wait for the second route call (the failing refresh) to complete, then verify @@ -231,12 +244,15 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) await comfyPage.toast.closeToasts() - await page.getByRole('button', { name: 'Current user' }).click() + await openSwitcherPanel(page) await page.getByText('Personal Workspace').click() - expect( - await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) - ).toBe('original-token') + await expect + .poll( + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + { timeout: 5000 } + ) + .toBe('original-token') // The scheduled refresh fires immediately (token expires within buffer window). // A 403 ACCESS_DENIED response must clear the workspace session entirely. From 5e2378b2e4af26476f9708179bdb21b15e58de54 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 18 Jun 2026 21:57:58 +0000 Subject: [PATCH 04/12] [automated] Apply ESLint and Oxfmt fixes --- browser_tests/tests/workspaceAuthRefresh.spec.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index bba3ace1b45..00fb6abd80c 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -99,7 +99,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await expect .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => + page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBe('initial-token') @@ -135,7 +136,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await expect .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => + page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBe('personal-token') @@ -196,7 +198,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await expect .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => + page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBe('original-token') @@ -249,7 +252,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await expect .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => + page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBe('original-token') From 051e388c1be6cdb6dd74db556398a16f78e5fb07 Mon Sep 17 00:00:00 2001 From: bymyself Date: Fri, 19 Jun 2026 22:29:58 +0000 Subject: [PATCH 05/12] fix(e2e): account for init auto-switch and use Team Workspace for explicit switches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../tests/workspaceAuthRefresh.spec.ts | 68 +++++++++++-------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index 00fb6abd80c..841ce6eed96 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -44,6 +44,11 @@ function makeTokenResponse( } } +// On app boot, teamWorkspaceStore.initialize() auto-selects Personal Workspace +// (personal type, no prior localStorage) and calls switchWorkspace → /api/auth/token. +// This default stub absorbs that init call so per-test mocks only see explicit switches. +const defaultTokenResponse = makeTokenResponse(mockPersonalWorkspace, 'init-token') + const test = comfyPageFixture.extend({ page: async ({ page }, use) => { await page.route('**/api/features', (route) => @@ -68,10 +73,23 @@ const test = comfyPageFixture.extend({ }) }) + // Default stub for the init-time auto-switch. Per-test mocks added later + // take priority (Playwright matches routes LIFO) and handle explicit switches. + await page.route('**/api/auth/token', (route) => + route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify(defaultTokenResponse) + }) + ) + await use(page) } }) +// Opens the profile popover then the workspace-switcher panel. +// useWorkspaceSwitch skips switchWorkspace when the target is already active, +// so always switch to a workspace other than the auto-selected Personal one. async function openSwitcherPanel(page: Page): Promise { await page.getByRole('button', { name: 'Current user' }).click() await page.getByTestId('workspace-switcher-trigger').click() @@ -83,19 +101,18 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) => { const page = comfyPage.page + // Override: explicit switch to Team Workspace returns a specific token. await page.route('**/api/auth/token', (route) => route.fulfill({ status: 200, contentType: 'application/json', - body: JSON.stringify( - makeTokenResponse(mockPersonalWorkspace, 'initial-token') - ) + body: JSON.stringify(makeTokenResponse(mockTeamWorkspace, 'team-token')) }) ) await comfyPage.toast.closeToasts() await openSwitcherPanel(page) - await page.getByText('Personal Workspace').click() + await page.getByText('Team Workspace').click() await expect .poll( @@ -103,7 +120,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) - .toBe('initial-token') + .toBe('team-token') const expiresAt = await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.ExpiresAt') @@ -111,7 +128,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { expect(Number(expiresAt)).toBeGreaterThan(Date.now()) }) - test('switching to a different workspace replaces sessionStorage token', async ({ + test('switching back to personal workspace replaces sessionStorage token', async ({ comfyPage }) => { const page = comfyPage.page @@ -121,8 +138,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { callCount++ const body = callCount === 1 - ? makeTokenResponse(mockPersonalWorkspace, 'personal-token') - : makeTokenResponse(mockTeamWorkspace, 'team-token') + ? makeTokenResponse(mockTeamWorkspace, 'team-token') + : makeTokenResponse(mockPersonalWorkspace, 'personal-token') return route.fulfill({ status: 200, contentType: 'application/json', @@ -131,19 +148,21 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) await comfyPage.toast.closeToasts() + + // Switch to Team (not the auto-selected Personal) await openSwitcherPanel(page) - await page.getByText('Personal Workspace').click() + await page.getByText('Team Workspace').click() await expect .poll( - () => - page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) - .toBe('personal-token') + .toBe('team-token') + // Switch back to Personal — different from current, so switchWorkspace fires await openSwitcherPanel(page) - await page.getByText('Team Workspace').click() + await page.getByText('Personal Workspace').click() await expect .poll( @@ -151,13 +170,13 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) - .toBe('team-token') + .toBe('personal-token') expect( await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Current') ) - ).toContain('ws-team') + ).toContain('ws-personal') }) test('transient token refresh failure preserves the active workspace session', async ({ @@ -177,11 +196,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { status: 200, contentType: 'application/json', body: JSON.stringify( - makeTokenResponse( - mockPersonalWorkspace, - 'original-token', - expiresInMs - ) + makeTokenResponse(mockTeamWorkspace, 'original-token', expiresInMs) ) }) } @@ -194,7 +209,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await comfyPage.toast.closeToasts() await openSwitcherPanel(page) - await page.getByText('Personal Workspace').click() + await page.getByText('Team Workspace').click() await expect .poll( @@ -231,11 +246,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { status: 200, contentType: 'application/json', body: JSON.stringify( - makeTokenResponse( - mockPersonalWorkspace, - 'original-token', - expiresInMs - ) + makeTokenResponse(mockTeamWorkspace, 'original-token', expiresInMs) ) }) } @@ -248,7 +259,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await comfyPage.toast.closeToasts() await openSwitcherPanel(page) - await page.getByText('Personal Workspace').click() + await page.getByText('Team Workspace').click() await expect .poll( @@ -262,8 +273,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { // A 403 ACCESS_DENIED response must clear the workspace session entirely. await expect .poll( - () => - page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBeNull() From d8cdbc01d7a091c19015380b2cf42883b3e259b1 Mon Sep 17 00:00:00 2001 From: bymyself Date: Fri, 19 Jun 2026 23:02:52 +0000 Subject: [PATCH 06/12] fix(e2e): fix panel sequencing and ACCESS_DENIED timing race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- browser_tests/tests/workspaceAuthRefresh.spec.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index 841ce6eed96..5609123e8d5 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -88,11 +88,15 @@ const test = comfyPageFixture.extend({ }) // Opens the profile popover then the workspace-switcher panel. +// Waits for the panel to be visible before returning. // useWorkspaceSwitch skips switchWorkspace when the target is already active, // so always switch to a workspace other than the auto-selected Personal one. async function openSwitcherPanel(page: Page): Promise { + // Close any open popovers first by pressing Escape, then open fresh. + await page.keyboard.press('Escape') await page.getByRole('button', { name: 'Current user' }).click() await page.getByTestId('workspace-switcher-trigger').click() + await expect(page.getByTestId('workspace-switcher-panel')).toBeVisible() } test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { @@ -261,15 +265,11 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await openSwitcherPanel(page) await page.getByText('Team Workspace').click() - await expect - .poll( - () => - page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), - { timeout: 5000 } - ) - .toBe('original-token') + // Wait for both the switch (callCount=1) and the immediate refresh (callCount=2) + // to complete. The refresh fires at delay≈0 so token may already be cleared + // before we can assert the intermediate 'original-token' state. + await expect.poll(() => callCount, { timeout: 5000 }).toBe(2) - // The scheduled refresh fires immediately (token expires within buffer window). // A 403 ACCESS_DENIED response must clear the workspace session entirely. await expect .poll( From 5466ac793b561a345120c23427cda3abc98dcb95 Mon Sep 17 00:00:00 2001 From: bymyself Date: Fri, 19 Jun 2026 23:17:46 +0000 Subject: [PATCH 07/12] fix(e2e): scope workspace clicks to switcher panel to prevent ambiguous 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 --- .../tests/workspaceAuthRefresh.spec.ts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index 5609123e8d5..48977f9f4ab 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -116,7 +116,10 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await comfyPage.toast.closeToasts() await openSwitcherPanel(page) - await page.getByText('Team Workspace').click() + await page + .getByTestId('workspace-switcher-panel') + .getByText('Team Workspace') + .click() await expect .poll( @@ -155,7 +158,10 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { // Switch to Team (not the auto-selected Personal) await openSwitcherPanel(page) - await page.getByText('Team Workspace').click() + await page + .getByTestId('workspace-switcher-panel') + .getByText('Team Workspace') + .click() await expect .poll( @@ -166,7 +172,10 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { // Switch back to Personal — different from current, so switchWorkspace fires await openSwitcherPanel(page) - await page.getByText('Personal Workspace').click() + await page + .getByTestId('workspace-switcher-panel') + .getByText('Personal Workspace') + .click() await expect .poll( @@ -213,7 +222,10 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await comfyPage.toast.closeToasts() await openSwitcherPanel(page) - await page.getByText('Team Workspace').click() + await page + .getByTestId('workspace-switcher-panel') + .getByText('Team Workspace') + .click() await expect .poll( @@ -263,7 +275,10 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { await comfyPage.toast.closeToasts() await openSwitcherPanel(page) - await page.getByText('Team Workspace').click() + await page + .getByTestId('workspace-switcher-panel') + .getByText('Team Workspace') + .click() // Wait for both the switch (callCount=1) and the immediate refresh (callCount=2) // to complete. The refresh fires at delay≈0 so token may already be cleared From 646c5b3b8fc5fd65c3d4af4c97b0b5d706702a9e Mon Sep 17 00:00:00 2001 From: bymyself Date: Fri, 19 Jun 2026 23:32:30 +0000 Subject: [PATCH 08/12] =?UTF-8?q?fix(e2e):=20drop=20two-switch=20UI=20test?= =?UTF-8?q?=20=E2=80=94=20teamWorkspaceStore.switchWorkspace=20reloads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../tests/workspaceAuthRefresh.spec.ts | 56 ------------------- 1 file changed, 56 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index 48977f9f4ab..f1c290e12bf 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -135,62 +135,6 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { expect(Number(expiresAt)).toBeGreaterThan(Date.now()) }) - test('switching back to personal workspace replaces sessionStorage token', async ({ - comfyPage - }) => { - const page = comfyPage.page - - let callCount = 0 - await page.route('**/api/auth/token', (route) => { - callCount++ - const body = - callCount === 1 - ? makeTokenResponse(mockTeamWorkspace, 'team-token') - : makeTokenResponse(mockPersonalWorkspace, 'personal-token') - return route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify(body) - }) - }) - - await comfyPage.toast.closeToasts() - - // Switch to Team (not the auto-selected Personal) - await openSwitcherPanel(page) - await page - .getByTestId('workspace-switcher-panel') - .getByText('Team Workspace') - .click() - - await expect - .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), - { timeout: 5000 } - ) - .toBe('team-token') - - // Switch back to Personal — different from current, so switchWorkspace fires - await openSwitcherPanel(page) - await page - .getByTestId('workspace-switcher-panel') - .getByText('Personal Workspace') - .click() - - await expect - .poll( - () => - page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), - { timeout: 5000 } - ) - .toBe('personal-token') - - expect( - await page.evaluate(() => - sessionStorage.getItem('Comfy.Workspace.Current') - ) - ).toContain('ws-personal') - }) test('transient token refresh failure preserves the active workspace session', async ({ comfyPage From dbf50928fad35cedfd70aa0906e91a9e0c250418 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 19 Jun 2026 23:36:07 +0000 Subject: [PATCH 09/12] [automated] Apply ESLint and Oxfmt fixes --- browser_tests/tests/workspaceAuthRefresh.spec.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index f1c290e12bf..b35493e259e 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -47,7 +47,10 @@ function makeTokenResponse( // On app boot, teamWorkspaceStore.initialize() auto-selects Personal Workspace // (personal type, no prior localStorage) and calls switchWorkspace → /api/auth/token. // This default stub absorbs that init call so per-test mocks only see explicit switches. -const defaultTokenResponse = makeTokenResponse(mockPersonalWorkspace, 'init-token') +const defaultTokenResponse = makeTokenResponse( + mockPersonalWorkspace, + 'init-token' +) const test = comfyPageFixture.extend({ page: async ({ page }, use) => { @@ -135,7 +138,6 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { expect(Number(expiresAt)).toBeGreaterThan(Date.now()) }) - test('transient token refresh failure preserves the active workspace session', async ({ comfyPage }) => { @@ -232,7 +234,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { // A 403 ACCESS_DENIED response must clear the workspace session entirely. await expect .poll( - () => page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), + () => + page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')), { timeout: 5000 } ) .toBeNull() From cae2c98d8f7dff762d435bf4c76046bfc06bc401 Mon Sep 17 00:00:00 2001 From: bymyself Date: Wed, 24 Jun 2026 20:30:40 +0000 Subject: [PATCH 10/12] fix(e2e): extract workspace mock data to fixtures Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/12940#discussion_r3445170462 --- .../fixtures/data/workspaceAuthFixtures.ts | 51 +++++++++++++++ .../fixtures/helpers/WorkspaceAuthHelper.ts | 65 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 browser_tests/fixtures/data/workspaceAuthFixtures.ts create mode 100644 browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts diff --git a/browser_tests/fixtures/data/workspaceAuthFixtures.ts b/browser_tests/fixtures/data/workspaceAuthFixtures.ts new file mode 100644 index 00000000000..3b5c2abe72a --- /dev/null +++ b/browser_tests/fixtures/data/workspaceAuthFixtures.ts @@ -0,0 +1,51 @@ +import type { RemoteConfig } from '@/platform/remoteConfig/types' +import type { WorkspaceWithRole } from '@/platform/workspace/api/workspaceApi' +import type { WorkspaceTokenResponse } from '@/platform/workspace/stores/workspaceAuthStore' + +export const mockWorkspacesRemoteConfig: RemoteConfig = { + team_workspaces_enabled: true +} + +export const mockPersonalWorkspace: WorkspaceWithRole = { + id: 'ws-personal', + name: 'Personal Workspace', + type: 'personal', + created_at: '2026-01-01T00:00:00Z', + joined_at: '2026-01-01T00:00:00Z', + role: 'owner' +} + +export const mockTeamWorkspace: WorkspaceWithRole = { + id: 'ws-team', + name: 'Team Workspace', + type: 'team', + created_at: '2026-01-02T00:00:00Z', + joined_at: '2026-01-02T00:00:00Z', + role: 'member' +} + +export function makeWorkspaceTokenResponse( + workspace: WorkspaceWithRole, + token: string, + expiresInMs = 60 * 60 * 1000 +): WorkspaceTokenResponse { + return { + token, + expires_at: new Date(Date.now() + expiresInMs).toISOString(), + workspace: { + id: workspace.id, + name: workspace.name, + type: workspace.type + }, + role: workspace.role, + permissions: [] + } +} + +// On app boot, teamWorkspaceStore.initialize() auto-selects Personal Workspace +// and calls switchWorkspace → /api/auth/token. This default response absorbs +// that init call so per-test mocks only see explicit switches. +export const defaultWorkspaceTokenResponse = makeWorkspaceTokenResponse( + mockPersonalWorkspace, + 'init-token' +) diff --git a/browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts b/browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts new file mode 100644 index 00000000000..b4aec270833 --- /dev/null +++ b/browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts @@ -0,0 +1,65 @@ +import { expect } from '@playwright/test' +import type { Page, Route } from '@playwright/test' + +import { + defaultWorkspaceTokenResponse, + mockPersonalWorkspace, + mockTeamWorkspace, + mockWorkspacesRemoteConfig +} from '@e2e/fixtures/data/workspaceAuthFixtures' + +export class WorkspaceAuthHelper { + constructor(private readonly page: Page) {} + + async mockWorkspaceRoutes(): Promise { + await this.page.route('**/api/features', (route) => + route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify(mockWorkspacesRemoteConfig) + }) + ) + + await this.page.route('**/api/workspaces', async (route) => { + if (route.request().method() !== 'GET') { + await route.fallback() + return + } + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ + workspaces: [mockPersonalWorkspace, mockTeamWorkspace] + }) + }) + }) + + // Default stub for the init-time auto-switch. Per-test mocks added via + // mockTokenRoute() take priority (Playwright matches routes LIFO). + await this.page.route('**/api/auth/token', (route) => + route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify(defaultWorkspaceTokenResponse) + }) + ) + } + + async mockTokenRoute( + handler: (route: Route) => void | Promise + ): Promise { + await this.page.route('**/api/auth/token', handler) + } + + // Opens the profile popover then the workspace-switcher panel. + // useWorkspaceSwitch skips switchWorkspace when the target is already active, + // so always switch to a workspace other than the auto-selected Personal one. + async openSwitcherPanel(): Promise { + await this.page.keyboard.press('Escape') + await this.page.getByRole('button', { name: 'Current user' }).click() + await this.page.getByTestId('workspace-switcher-trigger').click() + await expect( + this.page.getByTestId('workspace-switcher-panel') + ).toBeVisible() + } +} From a31be1b422c6abd693f9efadcc032f027e5e60dc Mon Sep 17 00:00:00 2001 From: bymyself Date: Wed, 24 Jun 2026 20:31:23 +0000 Subject: [PATCH 11/12] fix(e2e): move openSwitcherPanel to WorkspaceAuthHelper Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/12940#discussion_r3445172630 --- .../tests/workspaceAuthRefresh.spec.ts | 152 +++++------------- 1 file changed, 42 insertions(+), 110 deletions(-) diff --git a/browser_tests/tests/workspaceAuthRefresh.spec.ts b/browser_tests/tests/workspaceAuthRefresh.spec.ts index b35493e259e..80ca689d1c8 100644 --- a/browser_tests/tests/workspaceAuthRefresh.spec.ts +++ b/browser_tests/tests/workspaceAuthRefresh.spec.ts @@ -1,124 +1,42 @@ import { expect } from '@playwright/test' -import type { Page } from '@playwright/test' -import type { RemoteConfig } from '@/platform/remoteConfig/types' -import type { WorkspaceWithRole } from '@/platform/workspace/api/workspaceApi' -import type { WorkspaceTokenResponse } from '@/platform/workspace/stores/workspaceAuthStore' import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' +import { + makeWorkspaceTokenResponse, + mockTeamWorkspace +} from '@e2e/fixtures/data/workspaceAuthFixtures' +import { WorkspaceAuthHelper } from '@e2e/fixtures/helpers/WorkspaceAuthHelper' -const mockRemoteConfig: RemoteConfig = { team_workspaces_enabled: true } - -const mockPersonalWorkspace: WorkspaceWithRole = { - id: 'ws-personal', - name: 'Personal Workspace', - type: 'personal', - created_at: '2026-01-01T00:00:00Z', - joined_at: '2026-01-01T00:00:00Z', - role: 'owner' -} - -const mockTeamWorkspace: WorkspaceWithRole = { - id: 'ws-team', - name: 'Team Workspace', - type: 'team', - created_at: '2026-01-02T00:00:00Z', - joined_at: '2026-01-02T00:00:00Z', - role: 'member' -} - -function makeTokenResponse( - workspace: WorkspaceWithRole, - token: string, - expiresInMs = 60 * 60 * 1000 -): WorkspaceTokenResponse { - return { - token, - expires_at: new Date(Date.now() + expiresInMs).toISOString(), - workspace: { - id: workspace.id, - name: workspace.name, - type: workspace.type - }, - role: workspace.role, - permissions: [] - } -} - -// On app boot, teamWorkspaceStore.initialize() auto-selects Personal Workspace -// (personal type, no prior localStorage) and calls switchWorkspace → /api/auth/token. -// This default stub absorbs that init call so per-test mocks only see explicit switches. -const defaultTokenResponse = makeTokenResponse( - mockPersonalWorkspace, - 'init-token' -) - -const test = comfyPageFixture.extend({ +const test = comfyPageFixture.extend<{ workspaceAuth: WorkspaceAuthHelper }>({ page: async ({ page }, use) => { - await page.route('**/api/features', (route) => - route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify(mockRemoteConfig) - }) - ) - - await page.route('**/api/workspaces', async (route) => { - if (route.request().method() !== 'GET') { - await route.fallback() - return - } - await route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify({ - workspaces: [mockPersonalWorkspace, mockTeamWorkspace] - }) - }) - }) - - // Default stub for the init-time auto-switch. Per-test mocks added later - // take priority (Playwright matches routes LIFO) and handle explicit switches. - await page.route('**/api/auth/token', (route) => - route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify(defaultTokenResponse) - }) - ) - + const helper = new WorkspaceAuthHelper(page) + await helper.mockWorkspaceRoutes() await use(page) + }, + workspaceAuth: async ({ page }, use) => { + await use(new WorkspaceAuthHelper(page)) } }) -// Opens the profile popover then the workspace-switcher panel. -// Waits for the panel to be visible before returning. -// useWorkspaceSwitch skips switchWorkspace when the target is already active, -// so always switch to a workspace other than the auto-selected Personal one. -async function openSwitcherPanel(page: Page): Promise { - // Close any open popovers first by pressing Escape, then open fresh. - await page.keyboard.press('Escape') - await page.getByRole('button', { name: 'Current user' }).click() - await page.getByTestId('workspace-switcher-trigger').click() - await expect(page.getByTestId('workspace-switcher-panel')).toBeVisible() -} - test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { test('token is persisted to sessionStorage after switching workspace', async ({ - comfyPage + comfyPage, + workspaceAuth }) => { const page = comfyPage.page - // Override: explicit switch to Team Workspace returns a specific token. - await page.route('**/api/auth/token', (route) => + await workspaceAuth.mockTokenRoute((route) => route.fulfill({ status: 200, contentType: 'application/json', - body: JSON.stringify(makeTokenResponse(mockTeamWorkspace, 'team-token')) + body: JSON.stringify( + makeWorkspaceTokenResponse(mockTeamWorkspace, 'team-token') + ) }) ) await comfyPage.toast.closeToasts() - await openSwitcherPanel(page) + await workspaceAuth.openSwitcherPanel() await page .getByTestId('workspace-switcher-panel') .getByText('Team Workspace') @@ -139,7 +57,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) test('transient token refresh failure preserves the active workspace session', async ({ - comfyPage + comfyPage, + workspaceAuth }) => { const page = comfyPage.page @@ -148,14 +67,18 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { const expiresInMs = 5 * 60 * 1000 - 500 let callCount = 0 - await page.route('**/api/auth/token', (route) => { + await workspaceAuth.mockTokenRoute((route) => { callCount++ if (callCount === 1) { return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify( - makeTokenResponse(mockTeamWorkspace, 'original-token', expiresInMs) + makeWorkspaceTokenResponse( + mockTeamWorkspace, + 'original-token', + expiresInMs + ) ) }) } @@ -167,7 +90,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) await comfyPage.toast.closeToasts() - await openSwitcherPanel(page) + await workspaceAuth.openSwitcherPanel() await page .getByTestId('workspace-switcher-panel') .getByText('Team Workspace') @@ -184,7 +107,9 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { // The scheduled refresh fires immediately (token expires within buffer window). // Wait for the second route call (the failing refresh) to complete, then verify // the token is preserved — a transient 500 must not clear the session. - await expect.poll(() => callCount, { timeout: 5000 }).toBe(2) + await expect + .poll(() => callCount, { timeout: 5000 }) + .toBeGreaterThanOrEqual(2) expect( await page.evaluate(() => sessionStorage.getItem('Comfy.Workspace.Token')) @@ -192,7 +117,8 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) test('permanent auth failure (ACCESS_DENIED) clears the workspace session', async ({ - comfyPage + comfyPage, + workspaceAuth }) => { const page = comfyPage.page @@ -201,14 +127,18 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { const expiresInMs = 5 * 60 * 1000 - 500 let callCount = 0 - await page.route('**/api/auth/token', (route) => { + await workspaceAuth.mockTokenRoute((route) => { callCount++ if (callCount === 1) { return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify( - makeTokenResponse(mockTeamWorkspace, 'original-token', expiresInMs) + makeWorkspaceTokenResponse( + mockTeamWorkspace, + 'original-token', + expiresInMs + ) ) }) } @@ -220,7 +150,7 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { }) await comfyPage.toast.closeToasts() - await openSwitcherPanel(page) + await workspaceAuth.openSwitcherPanel() await page .getByTestId('workspace-switcher-panel') .getByText('Team Workspace') @@ -229,7 +159,9 @@ test.describe('Workspace auth refresh', { tag: '@cloud' }, () => { // Wait for both the switch (callCount=1) and the immediate refresh (callCount=2) // to complete. The refresh fires at delay≈0 so token may already be cleared // before we can assert the intermediate 'original-token' state. - await expect.poll(() => callCount, { timeout: 5000 }).toBe(2) + await expect + .poll(() => callCount, { timeout: 5000 }) + .toBeGreaterThanOrEqual(2) // A 403 ACCESS_DENIED response must clear the workspace session entirely. await expect From 3f479c77dd55a59aaa07ae3ed28cd2402fd7dbaf Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 23 Jul 2026 01:14:11 +0000 Subject: [PATCH 12/12] fix(e2e): stub /api/auth/session in WorkspaceAuthHelper 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. --- browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts b/browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts index b4aec270833..f3cdd2e7a1f 100644 --- a/browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts +++ b/browser_tests/fixtures/helpers/WorkspaceAuthHelper.ts @@ -43,6 +43,10 @@ export class WorkspaceAuthHelper { body: JSON.stringify(defaultWorkspaceTokenResponse) }) ) + + await this.page.route('**/api/auth/session', (route) => + route.fulfill({ status: 204 }) + ) } async mockTokenRoute(