39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
|
|
const PASSWORD = 'Sup3rSecure!123';
|
|
|
|
test('redirects protected routes to sign in and preserves the return path', async ({ page }) => {
|
|
await page.goto('/analysis?ticker=nvda');
|
|
|
|
await expect(page).toHaveURL(/\/auth\/signin\?/);
|
|
await expect(page.getByRole('heading', { name: 'Secure Sign In' })).toBeVisible();
|
|
expect(new URL(page.url()).searchParams.get('next')).toBe('/analysis?ticker=nvda');
|
|
});
|
|
|
|
test('shows client-side validation when signup passwords do not match', async ({ page }) => {
|
|
await page.goto('/auth/signup');
|
|
|
|
await page.locator('input[autocomplete="name"]').fill('Playwright User');
|
|
await page.locator('input[autocomplete="email"]').fill('mismatch@example.com');
|
|
await page.locator('input[autocomplete="new-password"]').first().fill(PASSWORD);
|
|
await page.locator('input[autocomplete="new-password"]').nth(1).fill('NotTheSame123!');
|
|
await page.getByRole('button', { name: 'Create account' }).click();
|
|
|
|
await expect(page.getByText('Passwords do not match.')).toBeVisible();
|
|
});
|
|
|
|
test('creates a new account and lands on the command center', async ({ page }) => {
|
|
const email = `playwright-${Date.now()}@example.com`;
|
|
|
|
await page.goto('/auth/signup');
|
|
await page.locator('input[autocomplete="name"]').fill('Playwright User');
|
|
await page.locator('input[autocomplete="email"]').fill(email);
|
|
await page.locator('input[autocomplete="new-password"]').first().fill(PASSWORD);
|
|
await page.locator('input[autocomplete="new-password"]').nth(1).fill(PASSWORD);
|
|
await page.getByRole('button', { name: 'Create account' }).click();
|
|
|
|
await expect(page).toHaveURL(/\/$/);
|
|
await expect(page.getByRole('heading', { name: 'Command Center' })).toBeVisible();
|
|
await expect(page.getByText('Quick Links')).toBeVisible();
|
|
});
|