Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions app/base/e2e/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ async function op(page: Page, name: string, input: unknown) {
expect(response.ok(), await response.text()).toBe(true)
return (await response.json()).result
}

/**
* Approve the first change in `/review` and wait until it has left the
* queue, so later reads see the approved state.
*/
async function approveFirstChange(page: Page) {
await page.goto('/review')
await page.waitForLoadState('networkidle')
const approve = page.getByRole('button', {
name: 'Approve & publish',
exact: true,
})
const pending = await approve.count()
expect(pending).toBeGreaterThan(0)
await approve.first().click()
await expect(approve).toHaveCount(pending - 1)
}
test('first-run owner setup, sign-out, and API protection', async ({
page,
}) => {
Expand Down Expand Up @@ -539,12 +556,7 @@ test('persistent recipe page: preview, review, filtering, details, and saved cod
data: { id: 'recipe-book', kind: 'page' },
})
expect(before.ok()).toBe(false)
await page.goto('/review')
await page.waitForLoadState('networkidle')
await page
.getByRole('button', { name: 'Approve & publish', exact: true })
.first()
.click()
await approveFirstChange(page)
await page.goto('/p/recipe-book')
await expect(
page.getByRole('heading', { name: 'Recipe book', exact: true }),
Expand Down Expand Up @@ -608,12 +620,7 @@ test('saved report snapshots stay fixed while live pages refresh; revisions requ
await expect(
page.getByText('Submitted for review. Approve in Review to publish.'),
).toBeVisible()
await page.goto('/review')
await page.waitForLoadState('networkidle')
await page
.getByRole('button', { name: 'Approve & publish', exact: true })
.first()
.click()
await approveFirstChange(page)
const initial = await op(page, 'readInterface', {
id: 'recipe-count',
kind: 'report',
Expand Down Expand Up @@ -653,12 +660,7 @@ test('saved report snapshots stay fixed while live pages refresh; revisions requ
(await op(page, 'readInterface', { id: 'recipe-count', kind: 'report' }))
.title,
).toBe('Recipe count')
await page.goto('/review')
await page.waitForLoadState('networkidle')
await page
.getByRole('button', { name: 'Approve & publish', exact: true })
.first()
.click()
await approveFirstChange(page)
const updated = await op(page, 'readInterface', {
id: 'recipe-count',
kind: 'report',
Expand Down Expand Up @@ -794,12 +796,7 @@ test('admins enable a reviewed snapshot schedule, pause/resume it, and run the a
await expect(
page.getByText('Submitted for review. Approve in Review to publish.'),
).toBeVisible()
await page.goto('/review')
await page.waitForLoadState('networkidle')
await page
.getByRole('button', { name: 'Approve & publish', exact: true })
.first()
.click()
await approveFirstChange(page)
await page.goto('/interfaces')
await page
.getByRole('button', { name: 'Edit Scheduled recipe total', exact: true })
Expand Down
Loading