test(e2e): seed a realistic session so gated branches enter the sweeps

The seeded /info returned privileges:[] with no OAuth providers — a state the
backend never returns. Every privilege-gated control (e.g. the knowledge
Anonymize action) and the login page's OAuth buttons rendered in their denied
variant in every spec and tier, so a regression there shipped unseen.

Seed the admin privilege list and the OAuth providers (authenticated and guest),
assert the login page now renders its OAuth buttons, and refresh the /flows/5
baseline, which now shows the flow controls in their real admin state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Sergey Kozyrenko
2026-07-22 05:25:23 +07:00
co-authored by Claude Opus 4.8
parent 101331c920
commit b0e69b2c7c
4 changed files with 111 additions and 2 deletions
+109 -2
View File
@@ -22,9 +22,116 @@ export const SEEDED_USER = {
type: 'local',
} satisfies User;
// The admin role's privilege set as /api/v1/info returns it. An empty list is a state the
// backend never returns — it renders every privilege-gated control in its denied variant.
const ADMIN_PRIVILEGES = [
'users.create',
'users.delete',
'users.edit',
'users.view',
'roles.view',
'providers.view',
'usage.admin',
'usage.view',
'screenshots.admin',
'screenshots.view',
'screenshots.download',
'screenshots.subscribe',
'msglogs.admin',
'msglogs.view',
'msglogs.subscribe',
'termlogs.admin',
'termlogs.view',
'termlogs.subscribe',
'flows.admin',
'flows.create',
'flows.delete',
'flows.edit',
'flows.view',
'flows.subscribe',
'tasks.admin',
'tasks.view',
'tasks.subscribe',
'subtasks.admin',
'subtasks.view',
'containers.admin',
'containers.view',
'agentlogs.admin',
'agentlogs.view',
'agentlogs.subscribe',
'vecstorelogs.admin',
'vecstorelogs.view',
'vecstorelogs.subscribe',
'searchlogs.admin',
'searchlogs.view',
'searchlogs.subscribe',
'assistants.admin',
'assistants.create',
'assistants.delete',
'assistants.edit',
'assistants.view',
'assistants.subscribe',
'assistantlogs.admin',
'assistantlogs.view',
'assistantlogs.subscribe',
'settings.admin',
'settings.view',
'settings.providers.admin',
'settings.providers.view',
'settings.providers.edit',
'settings.providers.subscribe',
'settings.prompts.admin',
'settings.prompts.view',
'settings.prompts.edit',
'settings.tokens.admin',
'settings.tokens.create',
'settings.tokens.view',
'settings.tokens.edit',
'settings.tokens.delete',
'settings.tokens.subscribe',
'settings.user.admin',
'settings.user.view',
'settings.user.edit',
'settings.user.subscribe',
'templates.admin',
'templates.create',
'templates.view',
'templates.edit',
'templates.delete',
'templates.subscribe',
'flow_files.admin',
'flow_files.view',
'flow_files.upload',
'flow_files.edit',
'flow_files.delete',
'flow_files.download',
'flow_files.subscribe',
'resources.admin',
'resources.view',
'resources.upload',
'resources.edit',
'resources.delete',
'resources.download',
'resources.subscribe',
'knowledge.admin',
'knowledge.view',
'knowledge.create',
'knowledge.edit',
'knowledge.delete',
'knowledge.search',
'knowledge.subscribe',
'anonymize.call',
'toolcalls.admin',
'toolcalls.view',
];
const OAUTH_PROVIDERS = ['google', 'github'];
export const seededAuthInfo = (): AuthInfo => ({
expires_at: new Date(CASSETTE_EPOCH.getTime() + 12 * 60 * 60 * 1000).toISOString(),
privileges: [],
oauth: false,
privileges: ADMIN_PRIVILEGES,
providers: OAUTH_PROVIDERS,
role: { id: 1, name: 'admin' },
type: 'user',
user: SEEDED_USER,
@@ -35,7 +142,7 @@ export const authenticatedInfoEntry = (): RestCassetteEntry => ({
});
export const guestInfoEntry = (): RestCassetteEntry => ({
body: { data: { type: 'guest' }, status: 'success' },
body: { data: { providers: OAUTH_PROVIDERS, type: 'guest' }, status: 'success' },
});
export const seedAuthenticated = async (page: Page): Promise<void> => {
+2
View File
@@ -12,6 +12,8 @@ test.describe('smoke', { tag: '@smoke' }, () => {
await expect(page).toHaveURL(/\/login\?returnUrl=%2Fflows/);
await expect(page.getByRole('button', { name: 'Sign in' })).toBeVisible();
// The guest /info carries OAuth providers, so the login page renders its OAuth buttons.
await expect(page.getByRole('button', { name: 'Continue with Google' })).toBeVisible();
});
test('logs in through the form and lands on the flows list', async ({ page, pageErrorLog }) => {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB