(password === 'bad' ? 401 : 200),
groupList: (params) => paginated(params.query, db.userGroups),
groupView: (params) => lookupById(db.userGroups, params.path.groupId),
-
- projectList: (params) => paginated(params.query, db.projects),
+ projectList: ({ query, cookies }) => {
+ // this is used to test for the IdP misconfig situation where the user has
+ // no role on the silo (see error-pages.e2e.ts). requireRole checks for _at
+ // least_ viewer, and viewer is the weakest role, so checking for viewer
+ // effectively means "do I have any role at all"
+ requireRole(cookies, 'silo', defaultSilo.id, 'viewer')
+ return paginated(query, db.projects)
+ },
projectCreate({ body }) {
errIfExists(db.projects, { name: body.name }, 'project')
@@ -189,7 +195,7 @@ export const handlers = makeHandlers({
throw 'Can only enter state importing_from_bulk_write from import_ready'
}
- await delay(1000) // slow it down for the tests
+ await delay(2000) // slow it down for the tests
db.diskBulkImportState.set(disk.id, { blocks: {} })
disk.state = { state: 'importing_from_bulk_writes' }
@@ -203,7 +209,7 @@ export const handlers = makeHandlers({
if (disk.state.state !== 'importing_from_bulk_writes') {
throw 'Can only stop import for disk in state importing_from_bulk_write'
}
- await delay(1000) // slow it down for the tests
+ await delay(2000) // slow it down for the tests
db.diskBulkImportState.delete(disk.id)
disk.state = { state: 'import_ready' }
diff --git a/test/e2e/error-pages.e2e.ts b/test/e2e/error-pages.e2e.ts
index d697e5cf5b..93340de431 100644
--- a/test/e2e/error-pages.e2e.ts
+++ b/test/e2e/error-pages.e2e.ts
@@ -7,6 +7,8 @@
*/
import { expect, test } from '@playwright/test'
+import { getPageAsUser } from './utils'
+
test('Shows 404 page when a resource is not found', async ({ page }) => {
await page.goto('/nonexistent')
await expect(page.locator('text=Page not found')).toBeVisible()
@@ -42,3 +44,10 @@ test('Shows something went wrong page on other errors', async ({ page }) => {
// up at the right URL
await expect(page).toHaveURL('/login')
})
+
+test('error page for user with no groups or silo role', async ({ browser }) => {
+ const page = await getPageAsUser(browser, 'Jacob Klein')
+ await page.goto('/projects')
+ await expect(page.getByText('Something went wrong')).toBeVisible()
+ await expect(page.getByText('identity provider is not set up correctly')).toBeVisible()
+})
diff --git a/test/e2e/image-upload.e2e.ts b/test/e2e/image-upload.e2e.ts
index a1d8315a13..28e188eb91 100644
--- a/test/e2e/image-upload.e2e.ts
+++ b/test/e2e/image-upload.e2e.ts
@@ -159,7 +159,8 @@ test.describe('Image upload', () => {
await page.getByRole('button', { name: 'Cancel' }).click()
await page.getByRole('link', { name: 'Disks' }).click()
await expect(page.getByRole('cell', { name: 'disk-1', exact: true })).toBeVisible()
- await expect(page.getByRole('cell', { name: 'tmp' })).toBeHidden()
+ // needs a little extra time for delete to go through
+ await expect(page.getByRole('cell', { name: 'tmp' })).toBeHidden({ timeout: 10000 })
})
}
diff --git a/test/e2e/utils.ts b/test/e2e/utils.ts
index 4bb0638434..10c719a44e 100644
--- a/test/e2e/utils.ts
+++ b/test/e2e/utils.ts
@@ -133,11 +133,16 @@ export async function expectNoToast(page: Page, expectedText: string | RegExp) {
}
/**
- * Close toast and wait for it to fade out. For some reason it prevents things
- * from working, but only in tests as far as we can tell.
+ * Close first toast and wait for it to fade out. For some reason it prevents
+ * things from working, but only in tests as far as we can tell.
*/
export async function closeToast(page: Page) {
- await page.getByRole('button', { name: 'Dismiss notification' }).click()
+ // first() is a hack aimed at situations where we're testing an error
+ // response, which usually means we have an initial "creating..." toast
+ // followed by an error toast. Sometimes the error toast shows up so fast that
+ // we don't have time to close the first one. Without first(), this errors out
+ // because there are two toasts.
+ await page.getByRole('button', { name: 'Dismiss notification' }).first().click()
await sleep(1000)
}
@@ -185,7 +190,7 @@ export async function selectOption(
export async function getPageAsUser(
browser: Browser,
- user: 'Hans Jonas' | 'Simone de Beauvoir'
+ user: 'Hans Jonas' | 'Simone de Beauvoir' | 'Jacob Klein'
): Promise
{
const browserContext = await browser.newContext()
await browserContext.addCookies([