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:
2026-04-29 06:30:46 +00:00
parent 3b8224d15e
commit c4db5e7550
3 changed files with 69 additions and 0 deletions

25
tests/e2e/login.spec.js Normal file
View 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 });
});
});