import { randomUUID } from 'node:crypto' import { en } from '@/i18n/en' import { fr } from '@/i18n/fr' import type { Dict } from '@/i18n/types' import type { Locator, Page, TestInfo } from '@playwright/test' import { sql } from '../../../../packages/supabase/tests/sandbox/stack' import { expect, expectAccessible, expectNoHorizontalOverflow, test, } from '../support/browser' import { assignRole, enrolVerifiedFactor, enterCode, seedGrant, sessionAal, stepUpAdmin, stepUpHeading, } from '../support/admin' import { createAccount, dropLateReplays, routeToSandbox, type SandboxAccount, } from '../support/sandbox' import { signIn } from '../support/shell' // V1-2.5 administration on the isolated stack (contract §11.2 A0, A1, S1, // §5.6, §16.6): the owner's bootstrap from Mon compte, Sécurité (two TOTP // factors, the step-up a session at aal1 meets, refresh keeping each level), // rights granted and revoked, a sheet created by an editor, a species created // inactive then activated, what each right shows. Accounts, roles, earlier // grants and factors of other people are set up the way the sandbox suites do; // what a test proves goes through the page. FR and EN, desktop and 375 px. const LANGUAGES = [ ['fr', fr], ['en', en], ] as const const isPhone = (info: TestInfo) => info.project.name === 'chromium-375' const tagOf = () => randomUUID().slice(0, 8) const main = (page: Page) => page.getByRole('main') const heading = (page: Page, name: string) => main(page).getByRole('heading', { level: 1, name }) /** Follows an entry of the shell's navigation: the sidebar, or the drawer on a phone. */ async function navigate(page: Page, dict: Dict, info: TestInfo, key: string) { if (isPhone(info)) { await page.getByRole('button', { name: dict['shell.open_menu'] }).click() await page .getByRole('dialog', { name: dict['shell.nav_label'] }) .getByRole('navigation') .getByRole('link', { name: dict[key] }) .click() // The drawer's modal keeps the page inert until its exit animation ends: // typed text would be lost (a fill on the search box went nowhere). await expect( page.getByRole('dialog', { name: dict['shell.nav_label'] }), ).toHaveCount(0) } else { await page .getByRole('navigation', { name: dict['shell.nav_label'] }) .getByRole('link', { name: dict[key] }) .click() } } /** The shell's sign-out: in the sidebar, or the drawer on a phone (Mon compte has its own). */ async function signOut(page: Page, dict: Dict, info: TestInfo) { const scope = isPhone(info) ? page.getByRole('dialog', { name: dict['shell.nav_label'] }) : page.getByRole('complementary') if (isPhone(info)) await page.getByRole('button', { name: dict['shell.open_menu'] }).click() await scope.getByRole('button', { name: dict['shell.sign_out'] }).click() await expect(page).toHaveURL(/\/$/) } /** The card of an administration area on /app/admin, by its heading id. */ const areaCard = (page: Page, id: string) => page.locator(`section[aria-labelledby="${id}"]`) const factorList = (page: Page, dict: Dict) => page .getByRole('list', { name: dict['mfa.factor.list_label'] }) .getByRole('listitem') /** * Adds a factor from Mon compte, Sécurité up to the QR code; resolves with the * secret shown for manual entry (read from the page, as a person would copy it). */ async function startEnrolment( page: Page, dict: Dict, name: string, ): Promise { await page.getByRole('button', { name: dict['mfa.enrol.start'] }).click() await page.getByLabel(dict['mfa.enrol.name']).fill(name) await page.getByRole('button', { name: dict['mfa.enrol.continue'] }).click() return page .locator('div', { has: page.getByRole('img', { name: dict['mfa.enrol.qr_alt'] }), }) .last() } async function enrolFromPage( page: Page, dict: Dict, name: string, ): Promise { const box = await startEnrolment(page, dict, name) await expect( box.getByRole('img', { name: dict['mfa.enrol.qr_alt'] }), ).toBeVisible() const secret = (await box.locator('code').textContent())?.trim() ?? '' // A boolean, so a failure report never prints the secret. expect(/^[A-Z2-7]{16,}$/.test(secret), 'base32 setup key shown').toBe(true) await enterCode(box, dict, secret) await expect(page.getByText(dict['mfa.enrol.done'])).toBeVisible() return secret } /** Finds an account on the rights screen and grants it `kind` with a reason and a note. */ async function grant( page: Page, dict: Dict, email: string, kind: string, note = true, ) { const panel = page.locator('section[aria-labelledby="grant-title"]') await panel.getByLabel(dict['admin.access.lookup.email']).fill(email) await panel .getByRole('button', { name: dict['admin.access.lookup.submit'] }) .click() await expect( panel.getByText(dict['admin.access.account.confirmed']), ).toBeVisible() await panel .getByRole('radio', { name: dict[`admin.grant_kind.${kind}`] }) .check() await panel .getByLabel(dict['admin.access.form.reason']) .fill(`Motif e2e ${kind}`) if (note) await panel .getByLabel(dict['admin.access.form.note']) .fill(`Diplôme vu, e2e ${kind}`) await panel .getByRole('button', { name: dict['admin.access.form.submit'] }) .click() await expect(panel.getByText(dict['admin.access.granted'])).toBeVisible() } /** The row of the rights list for this holder and right. */ const grantRow = (page: Page, dict: Dict, email: string, kind: string) => page .getByRole('list', { name: dict['admin.access.list.title'] }) .getByRole('listitem') .filter({ hasText: email }) .filter({ hasText: dict[`admin.grant_kind.${kind}`] }) /** A confirmed account with a platform role, rights and a verified factor (its secret). */ async function staff( locale: 'fr' | 'en', role: 'owner' | 'admin' | null, grants: Parameters[1][], ): Promise<{ account: SandboxAccount; secret: string }> { const account = await createAccount(locale, false) if (role) await assignRole(account, role) for (const kind of grants) await seedGrant(account, kind) return { account, secret: await enrolVerifiedFactor(account) } } /** Signs in, opens /app/admin from the navigation and steps up. */ async function openAdmin( page: Page, dict: Dict, info: TestInfo, account: SandboxAccount, secret: string, ) { await signIn(page, account, dict) await navigate(page, dict, info, 'shell.nav.admin') await expect(page).toHaveURL(/\/app\/admin$/) await stepUpAdmin(page, dict, secret) await expect(heading(page, dict['shell.nav.admin'])).toBeVisible() } /** The species select of the animal form (V1-1), loaded. */ async function animalSpeciesOptions(page: Page, dict: Dict): Promise { await page.goto('/app/animals/new') const select = page.getByRole('combobox', { name: dict['animals.form.species'], }) await expect(select.locator('option[value="equine"]')).toHaveCount(1) return select .locator('option') .evaluateAll((options) => options.map((option) => (option as HTMLOptionElement).value), ) } for (const [locale, dict] of LANGUAGES) { test.describe(`administration (${locale})`, () => { test.use({ locale: locale === 'fr' ? 'fr-FR' : 'en-GB' }) test.beforeEach(async ({ context }) => { await routeToSandbox(context) }) test.afterEach(async ({ context }) => { await dropLateReplays(context) }) test('A0: the owner enrols two factors, steps up, grants itself and a reviewer, revokes', async ({ page, requests, }, info) => { test.skip( isPhone(info), 'desktop journey (the admin screens at 375 px are covered below)', ) test.setTimeout(300_000) const owner = await createAccount(locale, false) await assignRole(owner, 'owner') requests.forbid(owner.email, owner.password, owner.displayName) await signIn(page, owner, dict) // No factor yet: the entry is there, the page asks for a factor first. await navigate(page, dict, info, 'shell.nav.admin') await expect(stepUpHeading(page, dict)).toBeVisible() await expect( main(page).getByText(dict['admin.step_up.no_factor']), ).toBeVisible() await expect(main(page).getByLabel(dict['mfa.code.label'])).toHaveCount(0) await expectAccessible(page, 'the admin gate without a factor') await main(page) .getByRole('link', { name: dict['admin.step_up.to_security'] }) .click() await expect(page).toHaveURL(/\/app\/account#security-title$/) await expect(page.getByText(dict['mfa.factor.none'])).toBeVisible() // First factor from the aal1 session; the QR step passes axe. const box = await startEnrolment(page, dict, 'Téléphone') await expect( box.getByRole('img', { name: dict['mfa.enrol.qr_alt'] }), ).toBeVisible() await expectAccessible(page, 'the enrolment step with the QR code') await expectNoHorizontalOverflow( page, 'the enrolment step with the QR code', ) const first = (await box.locator('code').textContent())?.trim() ?? '' expect(/^[A-Z2-7]{16,}$/.test(first), 'base32 setup key shown').toBe(true) await enterCode(box, dict, first) await expect(page.getByText(dict['mfa.enrol.done'])).toBeVisible() expect(await sessionAal(page)).toBe('aal2') // A second factor at aal2: no step-up asked. const second = await enrolFromPage(page, dict, 'Clé de secours') expect(second !== first, 'a new setup key').toBe(true) await expect(factorList(page, dict)).toHaveCount(2) await expect( factorList(page, dict).filter({ hasText: dict['mfa.factor.verified'] }), ).toHaveCount(2) await expectAccessible(page, 'Sécurité with two factors') // A new sign-in is aal1: another factor asks for the step-up, then goes on. await signOut(page, dict, info) await signIn(page, owner, dict) expect(await sessionAal(page)).toBe('aal1') await page.goto('/app/account') await page.getByRole('button', { name: dict['mfa.enrol.start'] }).click() await page.getByLabel(dict['mfa.enrol.name']).fill('Tablette') await page .getByRole('button', { name: dict['mfa.enrol.continue'] }) .click() await expect(page.getByText(dict['mfa.step_up.required'])).toBeVisible() await expect( page.getByRole('img', { name: dict['mfa.enrol.qr_alt'] }), ).toHaveCount(0) await expect( page.getByLabel(dict['mfa.step_up.factor'], { exact: true }), ).toBeVisible() await expectAccessible(page, 'the inline step-up of an enrolment') // Several factors: the code comes from the one chosen. await page .getByLabel(dict['mfa.step_up.factor'], { exact: true }) .selectOption({ label: 'Téléphone' }) await enterCode(page.getByRole('main'), dict, first) await expect( page.getByRole('img', { name: dict['mfa.enrol.qr_alt'] }), ).toBeVisible() expect(await sessionAal(page)).toBe('aal2') // Cancelled: the unverified factor it made is removed. await page.getByRole('button', { name: dict['common.cancel'] }).click() await expect(factorList(page, dict)).toHaveCount(2) // Again at aal1: removing a verified factor asks for the step-up too. await signOut(page, dict, info) await signIn(page, owner, dict) await page.goto('/app/account') const spare = factorList(page, dict).filter({ hasText: 'Clé de secours' }) await spare .getByRole('button', { name: dict['mfa.factor.remove'] }) .click() const confirm = page.getByRole('dialog', { name: dict['mfa.remove.title'], }) await confirm .getByRole('button', { name: dict['mfa.remove.confirm'] }) .click() await expect(page.getByText(dict['mfa.step_up.required'])).toBeVisible() // The confirmation closes first (while it is modal, the page behind is inert). await expect(confirm).toBeHidden() await expect(factorList(page, dict)).toHaveCount(2) // Several factors: the code comes from the one chosen. await page .getByLabel(dict['mfa.step_up.factor'], { exact: true }) .selectOption({ label: 'Téléphone' }) await enterCode(page.getByRole('main'), dict, first) await expect(page.getByText(dict['mfa.factor.removed'])).toBeVisible() await expect(factorList(page, dict)).toHaveCount(1) // An aal1 session meets the step-up on /app/admin, and a refresh keeps aal1. await signOut(page, dict, info) await signIn(page, owner, dict) await navigate(page, dict, info, 'shell.nav.admin') await expect(stepUpHeading(page, dict)).toBeVisible() await expect(heading(page, dict['shell.nav.admin'])).toHaveCount(0) await page.reload() await expect(stepUpHeading(page, dict)).toBeVisible() expect(await sessionAal(page)).toBe('aal1') await expectAccessible(page, 'the admin step-up') await stepUpAdmin(page, dict, first) await expect(heading(page, dict['shell.nav.admin'])).toBeVisible() // A refresh keeps aal2: no step-up again. await page.reload() await expect(heading(page, dict['shell.nav.admin'])).toBeVisible() await expect(stepUpHeading(page, dict)).toHaveCount(0) expect(await sessionAal(page)).toBe('aal2') // The owner grants itself editor and publisher. await areaCard(page, 'admin-access-title').getByRole('link').click() await expect(heading(page, dict['admin.access.title'])).toBeVisible() await grant(page, dict, owner.email, 'sheet_editor') await grant(page, dict, owner.email, 'sheet_publisher') for (const kind of ['sheet_editor', 'sheet_publisher']) await expect( grantRow(page, dict, owner.email, kind).getByText( dict['admin.grant_state.active'], { exact: true }, ), ).toBeVisible() // A business reviewer: confirmed account with its own verified factor, granted reviewer. const reviewer = await createAccount(locale, false) await enrolVerifiedFactor(reviewer) requests.forbid(reviewer.email, reviewer.password, reviewer.displayName) await grant(page, dict, reviewer.email, 'sheet_reviewer') const reviewerRow = grantRow(page, dict, reviewer.email, 'sheet_reviewer') await expect( reviewerRow.getByText(dict['admin.grant_state.active'], { exact: true, }), ).toBeVisible() await expect( reviewerRow.getByText('Diplôme vu, e2e sheet_reviewer'), ).toBeVisible() await expectAccessible(page, 'the rights screen with grants') // Revocation with its reason: the row shows it revoked, its reason kept. await reviewerRow .getByRole('button', { name: dict['admin.access.revoke.action'] }) .click() const revoke = page.getByRole('dialog', { name: dict['admin.access.revoke.title'], }) await expect(revoke).toBeVisible() await expectAccessible(page, 'the revocation dialog') await revoke .getByLabel(dict['admin.access.revoke.reason']) .fill('Fin de mission e2e') await revoke .getByRole('button', { name: dict['admin.access.revoke.confirm'] }) .click() await expect(revoke).toBeHidden() await expect( page.getByText(dict['admin.access.revoke.done']), ).toBeVisible() await expect( reviewerRow.getByText(dict['admin.grant_state.revoked'], { exact: true, }), ).toBeVisible() await expect(reviewerRow.getByText('Fin de mission e2e')).toBeVisible() await expect( reviewerRow.getByRole('button', { name: dict['admin.access.revoke.action'], }), ).toHaveCount(0) expect( await sql(`select count(*) from public.anatomical_catalog_grants where user_id = '${reviewer.id}' and revoked_at is not null`), ).toBe('1') }) test('creation page: unreadable permissions show a retry, never the form', async ({ page, requests, }, info) => { test.skip( isPhone(info), 'desktop journey (the admin screens at 375 px are covered below)', ) const { account, secret } = await staff(locale, 'admin', ['sheet_editor']) requests.forbid(account.email, account.password, account.displayName) await openAdmin(page, dict, info, account, secret) await page.goto('/app/admin/sheets/new') await expect(heading(page, dict['admin.sheets.new'])).toBeVisible() await expect(page.locator('#sheet-species-id')).toBeVisible() // The own-grants read fails: the unavailable screen, no field. const grants = '**/rest/v1/anatomical_catalog_grants*' await page.route(grants, (route) => route.fulfill({ status: 500, contentType: 'application/json', body: '{}', }), ) await page.reload() await expect( heading(page, dict['permissions_unavailable.title']), ).toBeVisible() await expect(page.locator('#sheet-species-id')).toHaveCount(0) await expectAccessible(page, 'the unavailable permissions screen') // Restored: Retry reads again and the form comes back. await page.unroute(grants) await page.getByRole('button', { name: dict['common.retry'] }).click() await expect(page.locator('#sheet-species-id')).toBeVisible() }) test('A1: an editor at aal2 creates a sheet on a new inactive species; it opens on draft v1', async ({ page, requests, }, info) => { test.skip( isPhone(info), 'desktop journey (the admin screens at 375 px are covered below)', ) const { account, secret } = await staff(locale, 'admin', ['sheet_editor']) requests.forbid(account.email, account.password, account.displayName) await openAdmin(page, dict, info, account, secret) await areaCard(page, 'admin-sheets-title') .getByRole('link', { name: dict['admin.home.all_sheets'] }) .click() await expect(heading(page, dict['admin.sheets.title'])).toBeVisible() await main(page) .getByRole('link', { name: dict['admin.sheets.new'] }) .click() await expect(heading(page, dict['admin.sheets.new'])).toBeVisible() // « Nouvelle espèce » from the form: created inactive, then chosen. const tag = tagOf() const speciesId = `e2e_${tag}` await main(page) .getByRole('button', { name: dict['admin.species.new'] }) .click() const dialog = page.getByRole('dialog', { name: dict['admin.species.dialog.create_title'], }) await dialog.getByLabel(dict['admin.species.field.id']).fill(speciesId) await dialog .getByLabel(dict['admin.species.field.name_fr']) .fill(`Espèce ${tag}`) await dialog .getByLabel(dict['admin.species.field.name_en']) .fill(`Species ${tag}`) await dialog.getByRole('button', { name: dict['common.save'] }).click() await expect(dialog).toBeHidden() const species = page.getByLabel(dict['admin.sheet_form.species'], { exact: true, }) await expect(species).toHaveValue(speciesId) await expect(species.locator('option:checked')).toHaveText( dict['admin.sheet_form.species_inactive'].replace( '{name}', locale === 'fr' ? `Espèce ${tag}` : `Species ${tag}`, ), ) expect( await sql( `select active from public.species where id = '${speciesId}'`, ), ).toBe('f') await page .getByLabel(dict['admin.sheet_form.name_fr']) .fill(`Fiche e2e ${tag}`) await page .getByLabel(dict['admin.sheet_form.name_en']) .fill(`E2E sheet ${tag}`) // The slug follows the French name until edited. await expect(page.getByLabel(dict['admin.sheet_form.slug'])).toHaveValue( `fiche-e2e-${tag}`, ) await expectAccessible(page, 'the sheet creation form') await page .getByRole('button', { name: dict['admin.sheet_form.submit'] }) .click() // V1-2.6: the creation opens the new draft in the editor; the overview follows. await expect(page).toHaveURL( /\/app\/admin\/sheets\/[0-9a-f-]{36}\/draft$/, ) await expect( heading(page, dict['editor.draft.title'].replace('{number}', '1')), ).toBeVisible() await page.goto(new URL(page.url()).pathname.replace(/\/draft$/, '')) const name = locale === 'fr' ? `Fiche e2e ${tag}` : `E2E sheet ${tag}` await expect(heading(page, name)).toBeVisible() const versions = main(page) .getByRole('listitem') .filter({ hasText: dict['admin.overview.version'].replace('{number}', '1'), }) await expect(versions).toHaveCount(1) await expect( versions.getByText(dict['admin.version_status.draft'], { exact: true }), ).toBeVisible() await expect( main(page).getByText(dict['admin.sheets.no_published'], { exact: false, }), ).toBeVisible() expect( await sql(`select v.status || '/' || v.version_number from public.anatomical_sheets s join public.anatomical_sheet_versions v on v.sheet_id = s.id where s.slug = 'fiche-e2e-${tag}' and s.species_id = '${speciesId}'`), ).toBe('draft/1') await expectAccessible(page, 'the new sheet overview') }) test('S1: an editor creates an inactive species; the animal form offers it only once the owner activates it', async ({ page, requests, }, info) => { test.skip( isPhone(info), 'desktop journey (the admin screens at 375 px are covered below)', ) test.setTimeout(180_000) const editor = await staff(locale, 'admin', ['sheet_editor']) const owner = await staff(locale, 'owner', []) requests.forbid( editor.account.email, editor.account.password, editor.account.displayName, ) requests.forbid( owner.account.email, owner.account.password, owner.account.displayName, ) const tag = tagOf() const speciesId = `e2e_${tag}` const label = (row: string) => `${row} ${tag}` const shown = locale === 'fr' ? label('Espèce') : label('Species') await openAdmin(page, dict, info, editor.account, editor.secret) await areaCard(page, 'admin-species-title').getByRole('link').click() await expect(heading(page, dict['admin.species.title'])).toBeVisible() await main(page) .getByRole('button', { name: dict['admin.species.new'] }) .click() const dialog = page.getByRole('dialog', { name: dict['admin.species.dialog.create_title'], }) await dialog.getByLabel(dict['admin.species.field.id']).fill(speciesId) await dialog .getByLabel(dict['admin.species.field.name_fr']) .fill(label('Espèce')) await dialog .getByLabel(dict['admin.species.field.name_en']) .fill(label('Species')) await dialog.getByRole('button', { name: dict['common.save'] }).click() await expect(page.getByText(dict['admin.species.created'])).toBeVisible() const row = main(page) .getByRole('listitem') .filter({ hasText: speciesId }) await expect( row.getByText(dict['admin.species.state.inactive'], { exact: true }), ).toBeVisible() // The editor edits an inactive species; activating is the owner's. await expect( row.getByRole('button', { name: dict['admin.species.edit_named'].replace('{name}', shown), }), ).toBeVisible() await expect( row.getByRole('button', { name: dict['admin.species.activate.action_named'].replace( '{name}', shown, ), }), ).toHaveCount(0) expect(await animalSpeciesOptions(page, dict)).not.toContain(speciesId) await signOut(page, dict, info) await openAdmin(page, dict, info, owner.account, owner.secret) await areaCard(page, 'admin-species-title').getByRole('link').click() const ownerRow = main(page) .getByRole('listitem') .filter({ hasText: speciesId }) await ownerRow .getByRole('button', { name: dict['admin.species.activate.action_named'].replace( '{name}', shown, ), }) .click() const activate = page.getByRole('dialog', { name: dict['admin.species.activate.title'].replace('{name}', shown), }) await expect(activate).toBeVisible() await expectAccessible(page, 'the activation confirmation') await activate .getByRole('button', { name: dict['admin.species.activate.confirm'] }) .click() await expect( page.getByText(dict['admin.species.activate.done']), ).toBeVisible() await expect( ownerRow.getByText(dict['admin.species.state.active'], { exact: true }), ).toBeVisible() expect(await animalSpeciesOptions(page, dict)).toContain(speciesId) }) test('access per right: a reviewer sees no creation, rights or working copy; an admin without capability no sheets', async ({ page, requests, }, info) => { test.setTimeout(180_000) const reviewer = await staff(locale, null, ['sheet_reviewer']) requests.forbid( reviewer.account.email, reviewer.account.password, reviewer.account.displayName, ) await openAdmin(page, dict, info, reviewer.account, reviewer.secret) await expect( main(page).getByText(dict['admin.home.capability.sheet_reviewer'], { exact: false, }), ).toBeVisible() const sheets = areaCard(page, 'admin-sheets-title') await expect(sheets).toBeVisible() // No working copy action for a reviewer (editors only), here or on the historical sheet. await expect( page.getByRole('button', { name: dict['admin.working_copy.create'] }), ).toHaveCount(0) await expect(areaCard(page, 'admin-access-title')).toHaveCount(0) await sheets .getByRole('link', { name: dict['admin.home.all_sheets'] }) .click() await expect(heading(page, dict['admin.sheets.title'])).toBeVisible() await expect( page.getByRole('link', { name: dict['admin.sheets.new'] }), ).toHaveCount(0) await page.goto('/app/admin/sheets/503dc301-a8b1-50d4-9e44-0919b2fc2916') await expect( main(page).getByText(dict['admin.badge.historical'], { exact: true }), ).toBeVisible() await expect( page.getByRole('button', { name: dict['admin.working_copy.create'] }), ).toHaveCount(0) // The rights screen by its address: refused by the server. await page.goto('/app/admin/access') await expect(heading(page, dict['access_denied.title'])).toBeVisible() // The creation page: no form for a reviewer-only account. await page.goto('/app/admin/sheets/new') await expect(heading(page, dict['access_denied.title'])).toBeVisible() await signOut(page, dict, info) const admin = await staff(locale, 'admin', []) requests.forbid( admin.account.email, admin.account.password, admin.account.displayName, ) await signIn(page, admin.account, dict) // No capability: no entry in the navigation; the page by its address. await expect( page.getByRole('link', { name: dict['shell.nav.admin'] }), ).toHaveCount(0) await page.goto('/app/admin') await stepUpAdmin(page, dict, admin.secret) await expect(heading(page, dict['shell.nav.admin'])).toBeVisible() await expect( main(page).getByText(dict['admin.home.permissions_none'], { exact: false, }), ).toBeVisible() await expect(areaCard(page, 'admin-species-title')).toBeVisible() await expect(areaCard(page, 'admin-sheets-title')).toHaveCount(0) await expect(areaCard(page, 'admin-access-title')).toHaveCount(0) }) test('admin screens: axe and no sideways scroll on every page, desktop and 375 px', async ({ page, requests, }) => { test.setTimeout(180_000) const { account, secret } = await staff(locale, 'owner', [ 'sheet_editor', 'sheet_publisher', ]) requests.forbid(account.email, account.password, account.displayName) await signIn(page, account, dict) await page.goto('/app/admin') await expectAccessible(page, 'the admin step-up') await expectNoHorizontalOverflow(page, 'the admin step-up') await stepUpAdmin(page, dict, secret) const historical = '503dc301-a8b1-50d4-9e44-0919b2fc2916' const pages: [string, string][] = [ ['/app/admin', dict['shell.nav.admin']], ['/app/admin/species', dict['admin.species.title']], ['/app/admin/access', dict['admin.access.title']], ['/app/admin/sheets', dict['admin.sheets.title']], ['/app/admin/sheets/new', dict['admin.sheets.new']], [`/app/admin/sheets/${historical}`, ''], ] const width = page.viewportSize()!.width for (const [path, title] of pages) { await page.goto(path) if (title) await expect(heading(page, title)).toBeVisible() else await expect( main(page).getByRole('heading', { level: 1 }), ).toBeVisible() await page.waitForLoadState('networkidle') await expectAccessible(page, `${path} at ${width} px`) await expectNoHorizontalOverflow(page, `${path} at ${width} px`) } // The working copy dialog on the historical sheet (W1 start), opened only. await page .getByRole('button', { name: dict['admin.working_copy.create'] }) .first() .click() const copy = page.getByRole('dialog', { name: dict['admin.working_copy.create'], }) await expect(copy).toBeVisible() await expectAccessible(page, `the working copy dialog at ${width} px`) await expectNoHorizontalOverflow( page, `the working copy dialog at ${width} px`, ) }) }) }