Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ node_modules/
/blob-report/
/playwright/.cache/
/playwright/.auth/

# Remove Authentication Files from GitHub:
.auth/
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const mobileViewport = { width: 430, height: 845 };
*/
export default defineConfig({
testDir: './tests',
testMatch: ['**/*.test.ts'],
testMatch: ['**/*.test.ts', '**/*.setup.ts'],
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand Down
31 changes: 31 additions & 0 deletions tests/auth.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { test as setup, tags } from '../fixtures/test-options';
import { expect } from '@playwright/test';

setup.describe('Create Customer 01 Auth', () => {
setup('Create Customer Authentication', async ({ page, context }) => {
const email = "customer@practicesoftwaretesting.com";
const password = "welcome01";
const customer01AuthFile = ".auth/customer01.json";

await page.goto('https://practicesoftwaretesting.com/auth/login');

await page.getByTestId('email').fill(email);
await page.getByTestId('password').fill(password);
await page.getByTestId('login-submit').click();
await expect(page.getByTestId('nav-menu')).toContainText('Jane Doe');

// creates folder + file with Cookie Info browser session has:
await context.storageState({ path: customer01AuthFile });
})
});

setup.describe('Homepage Customer 01 Authenticated', () => {
setup.use({ storageState: ".auth/customer01.json" });
setup.beforeEach(async ({ page }) => {
await page.goto('https://practicesoftwaretesting.com/');
});
setup('check to verify customer is authenticated', async ({ page }) => {
await expect(page.getByTestId('nav-sign-in')).not.toBeVisible();
await expect(page.getByTestId('nav-menu')).toContainText('Jane Doe');
})
})