Skip to content

Commit

Permalink
CI debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Kruggel committed Jul 18, 2024
1 parent 6d533ec commit 6f9e398
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions tests/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ import { test as setup, expect } from '@playwright/test';
import { authFile } from './playwright.config';

setup('authenticate', async ({ page, context, baseURL }) => {
await page.goto(baseURL);
await page.getByLabel("Username or email").fill("doug");
await page.getByLabel("Password").fill("unicorn123!@#");
await page.getByRole("button", { name: "Log In" }).click();
try {
await page.goto(baseURL);
await page.getByLabel("Username or email").fill("doug");
await page.getByLabel("Password").fill("unicorn123!@#");
await page.getByRole("button", { name: "Log In" }).click();

// ensure auth cookies were set
const cookies = await context.cookies();
const keycloakCookie = cookies.find(
(cookie) => cookie.name === "KEYCLOAK_SESSION",
);
// ensure auth cookies were set
const cookies = await context.cookies();
const keycloakCookie = cookies.find(
(cookie) => cookie.name === "KEYCLOAK_SESSION",
);

expect(keycloakCookie).toBeDefined();
expect(keycloakCookie?.value).not.toBe("");
expect(keycloakCookie?.domain).toContain("sso.");
expect(keycloakCookie).toBeDefined();
expect(keycloakCookie?.value).not.toBe("");
expect(keycloakCookie?.domain).toContain("sso.");

await page.context().storageState({ path: authFile });
await page.context().storageState({ path: authFile });

await page.waitForURL(baseURL); // successful redirect

await expect(page).toHaveURL(baseURL);
await expect(page).toHaveURL(baseURL);
} catch (error) {
await page.screenshot({ path: 'screenshot.png' });
throw error; // rethrow the error after taking the screenshot
}
})

0 comments on commit 6f9e398

Please sign in to comment.