- Installed @playwright/test + Chromium - playwright.config.js: baseURL localhost:5001, Desktop Chrome - tests/e2e/login.spec.js: validates login form loads and invalid credentials show error
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
const { test, expect } = require('@playwright/test');
|
|
|
|
test.describe('Nexus POS — Login', () => {
|
|
test('login page loads with form', async ({ page }) => {
|
|
await page.goto('/pos/login');
|
|
await expect(page).toHaveTitle(/Nexus|Login/i);
|
|
await expect(page.locator('input[name="username"], input[name="email"], #username, #email')).toBeVisible();
|
|
await expect(page.locator('input[type="password"], #password')).toBeVisible();
|
|
await expect(page.locator('button[type="submit"], .btn--primary')).toBeVisible();
|
|
});
|
|
|
|
test('invalid credentials show error', async ({ page }) => {
|
|
await page.goto('/pos/login');
|
|
const userInput = page.locator('input[name="username"], input[name="email"], #username, #email').first();
|
|
const passInput = page.locator('input[type="password"], #password').first();
|
|
const submitBtn = page.locator('button[type="submit"], .btn--primary').first();
|
|
|
|
await userInput.fill('invalid_user');
|
|
await passInput.fill('wrong_password');
|
|
await submitBtn.click();
|
|
|
|
// Expect error toast or message
|
|
await expect(page.locator('.toast, .alert, .error, [role="alert"]')).toBeVisible({ timeout: 5000 });
|
|
});
|
|
});
|