Skip to content

Commit

Permalink
fix: add timeout on login to avoid csrf cookies being sent simultaneo…
Browse files Browse the repository at this point in the history
…usly
  • Loading branch information
alarv committed Nov 26, 2024
1 parent 54935a6 commit 12d6094
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/util/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const login = async (
username: string = process.env.TEST_USER_USERNAME!!,
password: string = process.env.TEST_USER_PASSWORD!!,
) => {
await page.waitForLoadState();
await page.waitForTimeout(1000);
await page.getByRole('button', { name: 'Sign in' }).click();

await page.waitForURL(
Expand All @@ -13,4 +15,19 @@ export const login = async (
await page.locator('[name="username"]').fill(username);
await page.locator('[name="password"]').fill(password);
await page.getByRole('button', { name: 'Sign in' }).click();
await page.waitForURL('https://app.jaqpot.org/**');
};

export const logout = async (page: Page) => {
await page.waitForTimeout(1000);
await page.waitForLoadState();

await page.getByRole('button', { name: 'jaqpot e2e-' }).click();
await page.getByText('Sign out').click();
await page.waitForURL(
'https://login.jaqpot.org/realms/jaqpot/protocol/openid-connect/**',
);
await page.getByRole('button', { name: 'Logout' }).click();

await page.waitForURL('https://app.jaqpot.org/**');
};

0 comments on commit 12d6094

Please sign in to comment.