Skip to content

Commit

Permalink
Enable E2E auth setup to work when SSO is enabled (#4624)
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalabbad authored Oct 14, 2024
1 parent 04fbfed commit c255485
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions frontend/app/tests/e2e/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import {
setup("authenticate admin", async ({ page }) => {
await page.goto("/login");
await expect(page.getByText("Log in to your account")).toBeVisible();
const loginButton = page.getByRole("button", {
name: "Log in with your credentials",
});
if (await loginButton.isVisible()) {
await loginButton.click();
}
await page.getByLabel("Username").fill(ADMIN_CREDENTIALS.username);
await page.getByLabel("Password").fill(ADMIN_CREDENTIALS.password);
await page.getByRole("button", { name: "Log in" }).click();
await page.getByRole("button", { name: "Log in", exact: true }).click();

await expect(page.getByTestId("authenticated-menu-trigger")).toBeVisible();
await page.context().storageState({ path: ACCOUNT_STATE_PATH.ADMIN });
Expand All @@ -20,9 +26,15 @@ setup("authenticate admin", async ({ page }) => {
setup("authenticate read-write", async ({ page }) => {
await page.goto("/login");
await expect(page.getByText("Log in to your account")).toBeVisible();
const loginButton = page.getByRole("button", {
name: "Log in with your credentials",
});
if (await loginButton.isVisible()) {
await loginButton.click();
}
await page.getByLabel("Username").fill(READ_WRITE_CREDENTIALS.username);
await page.getByLabel("Password").fill(READ_WRITE_CREDENTIALS.password);
await page.getByRole("button", { name: "Log in" }).click();
await page.getByRole("button", { name: "Log in", exact: true }).click();

await expect(page.getByTestId("authenticated-menu-trigger")).toBeVisible();
await page.context().storageState({ path: ACCOUNT_STATE_PATH.READ_WRITE });
Expand All @@ -31,9 +43,15 @@ setup("authenticate read-write", async ({ page }) => {
setup("authenticate read-only", async ({ page }) => {
await page.goto("/login");
await expect(page.getByText("Log in to your account")).toBeVisible();
const loginButton = page.getByRole("button", {
name: "Log in with your credentials",
});
if (await loginButton.isVisible()) {
await loginButton.click();
}
await page.getByLabel("Username").fill(READ_ONLY_CREDENTIALS.username);
await page.getByLabel("Password").fill(READ_ONLY_CREDENTIALS.password);
await page.getByRole("button", { name: "Log in" }).click();
await page.getByRole("button", { name: "Log in", exact: true }).click();

await expect(page.getByTestId("authenticated-menu-trigger")).toBeVisible();
await page.context().storageState({ path: ACCOUNT_STATE_PATH.READ_ONLY });
Expand Down

0 comments on commit c255485

Please sign in to comment.