Gate admin menu and authoring with shared JWT
This commit is contained in:
+16
-2
@@ -27,6 +27,8 @@ async function waitForSave(page: Page, action: () => Promise<void>) {
|
||||
test('move, folder expansion, empty-board pan, desktop wheel zoom, mobile pinch, and reload persistence', async ({ page }) => {
|
||||
await page.goto('/?level=e2e-level&edit=1')
|
||||
await expect(page.getByRole('heading', { name: 'Browser Safety Test' })).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: 'ADMIN', exact: true })).toBeVisible()
|
||||
expect((await page.locator('.menubar nav > button, .menubar nav > .admin-menu > button').allTextContents()).map(label => label.replace(/\d+$/, ''))).toEqual(['EVIDENCE', 'CASE BRIEF', 'TIMELINE', 'HELP', 'ADMIN'])
|
||||
const temporalLayering = await page.evaluate(() => ({
|
||||
links: Number.parseInt(getComputedStyle(document.querySelector('.temporal-links')!).zIndex, 10),
|
||||
timeline: Number.parseInt(getComputedStyle(document.querySelector('.timeline')!).zIndex, 10),
|
||||
@@ -193,7 +195,8 @@ test('move, folder expansion, empty-board pan, desktop wheel zoom, mobile pinch,
|
||||
|
||||
page.once('dialog', dialog => dialog.accept('Browser Template'))
|
||||
const templateSaved = page.waitForResponse(candidate => candidate.request().method() === 'POST' && candidate.url().includes('/templates?edit=1') && candidate.ok())
|
||||
await page.getByRole('button', { name: 'SAVE TEMPLATE', exact: true }).click()
|
||||
await page.getByRole('button', { name: 'ADMIN', exact: true }).click()
|
||||
await page.getByRole('menuitem', { name: 'SAVE AS TEMPLATE', exact: true }).click()
|
||||
await templateSaved
|
||||
await expect(page.locator('.terminal-status')).toContainText('VERSION 1')
|
||||
|
||||
@@ -201,7 +204,8 @@ test('move, folder expansion, empty-board pan, desktop wheel zoom, mobile pinch,
|
||||
const prompts = ['browser-template', 'Browser Template Clone']
|
||||
const promptHandler = (dialog: { accept(promptText?: string): Promise<void> }) => dialog.accept(prompts[promptIndex++])
|
||||
page.on('dialog', promptHandler)
|
||||
await page.getByRole('button', { name: 'NEW FROM TEMPLATE', exact: true }).click()
|
||||
await page.getByRole('button', { name: 'ADMIN', exact: true }).click()
|
||||
await page.getByRole('menuitem', { name: 'NEW FROM TEMPLATE', exact: true }).click()
|
||||
await page.waitForURL(url => url.searchParams.get('level')?.startsWith('browser-template-') === true)
|
||||
page.off('dialog', promptHandler)
|
||||
await expect(page.getByRole('heading', { name: 'Browser Template Clone' })).toBeVisible()
|
||||
@@ -223,3 +227,13 @@ test('move, folder expansion, empty-board pan, desktop wheel zoom, mobile pinch,
|
||||
if (!landscapeToolbar) throw new Error('Landscape toolbar is not visible')
|
||||
expect(landscapeToolbar.width).toBeGreaterThan(landscapeToolbar.height * 2)
|
||||
})
|
||||
|
||||
test('hides the admin menu without a verified admin JWT', async ({ browser }) => {
|
||||
const context = await browser.newContext({ baseURL: 'http://127.0.0.1:18788', viewport: { width: 1280, height: 720 }, extraHTTPHeaders: { Cookie: 'anonymous_session=1' } })
|
||||
const page = await context.newPage()
|
||||
await page.goto('/?level=e2e-level&edit=1')
|
||||
await expect(page.getByRole('heading', { name: 'Browser Safety Test' })).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: 'ADMIN', exact: true })).toHaveCount(0)
|
||||
expect((await page.locator('.menubar nav > button').allTextContents()).map(label => label.replace(/\d+$/, ''))).toEqual(['EVIDENCE', 'CASE BRIEF', 'TIMELINE', 'HELP'])
|
||||
await context.close()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user