test(e2e): isolate administrator roles and locale between journeys

This commit is contained in:
cesnimda
2026-10-21 07:21:29 +02:00
parent dda1687345
commit b39a5af4de
10 changed files with 260 additions and 13 deletions
@@ -90,10 +90,18 @@ for (const identity of ['anonymous', 'normal', 'admin'] as const) {
test(`[P5-15-01 E02 E07 A01] all 33 routes retain native entry, refresh and ${identity} permissions`, async ({ page, playwright }, info) => {
test.setTimeout(300_000);
const admin = await playwright.request.newContext();
let adminHeaders: Record<string, string> | undefined;
let createdAdminId: string | undefined;
const evidence: { pattern: string; mode: string; destination: string; status?: number }[] = [];
try {
const adminHeaders = await login(admin, 'e2e@example.test');
const email = await createAccount(admin, adminHeaders, identity === 'admin' ? ['Admin'] : []);
adminHeaders = await login(admin, 'e2e@example.test');
const email = `acceptance-${Date.now()}-${Math.random().toString(36).slice(2)}@example.test`;
const created = await admin.post(`${apiUrl}/users`, { headers: adminHeaders, data: { email, password, roles: identity === 'admin' ? ['Admin'] : [] } });
expect(created.status()).toBe(200);
if (identity === 'admin') {
createdAdminId = (await created.json()).id;
expect(createdAdminId).toEqual(expect.any(String));
}
let jobId = 2147483647;
let cvId = 2147483647;
if (identity !== 'anonymous') {
@@ -163,8 +171,12 @@ for (const identity of ['anonymous', 'normal', 'admin'] as const) {
await expect(page.getByTestId('admin-version-badge')).toHaveCount(identity === 'admin' ? 1 : 0);
}
} finally {
await info.attach(`route-census-${identity}`, { body: JSON.stringify(evidence, null, 2), contentType: 'application/json' });
await admin.dispose();
try {
if (createdAdminId) expect((await admin.put(`${apiUrl}/users/${createdAdminId}/roles`, { headers: adminHeaders, data: { roles: [] } })).status()).toBe(204);
} finally {
await info.attach(`route-census-${identity}`, { body: JSON.stringify(evidence, null, 2), contentType: 'application/json' });
await admin.dispose();
}
}
});
}