test(e2e): setup Playwright with login smoke test
- 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
This commit is contained in:
25
tests/e2e/login.spec.js
Normal file
25
tests/e2e/login.spec.js
Normal file
@@ -0,0 +1,25 @@
|
||||
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 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user