Add backend unit/integration tests, Playwright e2e tests, README, cookie Secure fix
SonarQube Analysis / sonarqube (push) Successful in 4m20s
SonarQube Analysis / sonarqube (push) Successful in 4m20s
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
function uniqueEmail(): string {
|
||||
return `playwright-${Date.now()}-${Math.floor(Math.random() * 10000)}@example.com`;
|
||||
}
|
||||
|
||||
test.describe('Customer accounts', () => {
|
||||
test('marketing consent checkbox is unchecked by default', async ({ page }) => {
|
||||
await page.goto('/register');
|
||||
await expect(page.getByRole('checkbox')).not.toBeChecked();
|
||||
});
|
||||
|
||||
test('registers a new account and lands on the account page', async ({ page }) => {
|
||||
const email = uniqueEmail();
|
||||
await page.goto('/register');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password').fill('supersecret123');
|
||||
await page.getByRole('button', { name: 'Create account' }).click();
|
||||
await expect(page).toHaveURL(/\/account/);
|
||||
await expect(page.getByText(email)).toBeVisible();
|
||||
});
|
||||
|
||||
test('rejects login with the wrong password', async ({ page }) => {
|
||||
const email = uniqueEmail();
|
||||
await page.goto('/register');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password').fill('supersecret123');
|
||||
await page.getByRole('button', { name: 'Create account' }).click();
|
||||
await expect(page).toHaveURL(/\/account/);
|
||||
|
||||
await page.getByRole('button', { name: 'Log out' }).click();
|
||||
await page.goto('/login');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password').fill('wrong-password');
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await expect(page.getByText('invalid email or password')).toBeVisible();
|
||||
});
|
||||
});
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Storefront', () => {
|
||||
test('loads and shows the site title', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page.getByText('Redefined Designs')).toBeVisible();
|
||||
});
|
||||
|
||||
test('links to the privacy policy from the footer', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('link', { name: 'Privacy Policy' }).click();
|
||||
await expect(page).toHaveURL(/\/privacy/);
|
||||
await expect(page.getByText('What we collect')).toBeVisible();
|
||||
});
|
||||
|
||||
test('offers login and sign up when logged out', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page.getByRole('button', { name: 'Log in' })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Sign up' })).toBeVisible();
|
||||
});
|
||||
});
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Theme switching', () => {
|
||||
test('toggling the switch changes the body theme attribute', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
const body = page.locator('body');
|
||||
const initial = await body.getAttribute('data-theme');
|
||||
|
||||
await page.getByRole('switch').click();
|
||||
|
||||
await expect(async () => {
|
||||
const updated = await body.getAttribute('data-theme');
|
||||
expect(updated).not.toBe(initial);
|
||||
}).toPass();
|
||||
});
|
||||
|
||||
test('theme preference persists across a reload', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('switch').click();
|
||||
const chosen = await page.locator('body').getAttribute('data-theme');
|
||||
|
||||
await page.reload();
|
||||
await expect(page.locator('body')).toHaveAttribute('data-theme', chosen || '');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user