Skip to content

Commit

Permalink
convert back to simpler structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Vostrak authored and Gregor Vostrak committed Jan 23, 2024
1 parent d89849d commit d129eeb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
12 changes: 4 additions & 8 deletions e2e/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ test('can register, logout and log back in', async ({ page }) => {
).toBeVisible();
await page.locator('#currentUserButton').click();

await Promise.all([
page.getByRole('button', { name: 'Log Out' }).click(),
page.waitForURL(PLAYWRIGHT_BASE_URL + '/'),
]);
await page.getByRole('button', { name: 'Log Out' }).click();
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/');
await page.goto(PLAYWRIGHT_BASE_URL + '/login');
await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill(password);
Expand All @@ -44,10 +42,8 @@ test('can register and delete account', async ({ page }) => {
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
await page.getByRole('button', { name: 'Delete Account' }).click();
await page.getByPlaceholder('Password').fill(password);
await Promise.all([
page.getByRole('button', { name: 'Delete Account' }).nth(1).click(),
page.waitForURL(PLAYWRIGHT_BASE_URL + '/'),
]);
await page.getByRole('button', { name: 'Delete Account' }).nth(1).click();
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/');
await page.goto(PLAYWRIGHT_BASE_URL + '/login');
await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill(password);
Expand Down
3 changes: 2 additions & 1 deletion playwright/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const PLAYWRIGHT_BASE_URL = process.env.PLAYWRIGHT_BASE_URL ?? 'http://laravel.test';
export const PLAYWRIGHT_BASE_URL =
process.env.PLAYWRIGHT_BASE_URL ?? 'http://laravel.test';
6 changes: 6 additions & 0 deletions playwright/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export const test = baseTest.extend<object, { workerStorageState: string }>({
.fill('amazingpassword123');
await page.getByRole('button', { name: 'Register' }).click();

// Wait until the page receives the cookies.
//
// Sometimes login flow sets cookies in the process of several redirects.
// Wait for the final URL to ensure that the cookies are actually set.
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/dashboard');

// Alternatively, you can wait until the page reaches a state where all cookies are set.
await expect(
page.getByRole('heading', { name: 'Dashboard' })
Expand Down

0 comments on commit d129eeb

Please sign in to comment.