- Update activeContext.md with current focus and status - Add development environment decisions to decisionLog.md - Update progress.md with completed tasks - Add development patterns to systemPatterns.md - Update productContext.md with environment details - Add Development Environment Setup section to implementation plan"
45 lines
No EOL
1.9 KiB
TypeScript
45 lines
No EOL
1.9 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Login Functionality @login', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/hce-login');
|
|
});
|
|
|
|
test('displays login form', async ({ page }) => {
|
|
await expect(page.locator('#trainer-login-form')).toBeVisible();
|
|
await expect(page.locator('input[name="username"]')).toBeVisible();
|
|
await expect(page.locator('input[name="password"]')).toBeVisible();
|
|
await expect(page.locator('input[name="remember"]')).toBeVisible();
|
|
await expect(page.locator('button[type="submit"]')).toBeVisible();
|
|
});
|
|
|
|
test('shows error on invalid credentials', async ({ page }) => {
|
|
await page.fill('input[name="username"]', 'invalid@example.com');
|
|
await page.fill('input[name="password"]', 'wrongpassword');
|
|
await page.click('button[type="submit"]');
|
|
|
|
await expect(page.locator('#login-message')).toContainText('Invalid username or password');
|
|
});
|
|
|
|
test('redirects to dashboard on successful login', async ({ page }) => {
|
|
await page.fill('input[name="username"]', process.env.WP_ADMIN_USER || 'devadmin');
|
|
await page.fill('input[name="password"]', process.env.WP_ADMIN_PASSWORD || '');
|
|
await page.click('button[type="submit"]');
|
|
|
|
await expect(page).toHaveURL(/.*trainer-dashboard/);
|
|
});
|
|
|
|
test('remembers login state', async ({ page, context }) => {
|
|
await page.fill('input[name="username"]', process.env.WP_ADMIN_USER || 'devadmin');
|
|
await page.fill('input[name="password"]', process.env.WP_ADMIN_PASSWORD || '');
|
|
await page.check('input[name="remember"]');
|
|
await page.click('button[type="submit"]');
|
|
|
|
await expect(page).toHaveURL(/.*trainer-dashboard/);
|
|
|
|
// Create a new page in the same context to verify persistent login
|
|
const newPage = await context.newPage();
|
|
await newPage.goto('/trainer-dashboard');
|
|
await expect(newPage).not.toHaveURL(/.*hce-login/);
|
|
});
|
|
}); |