test(e2e): add Playwright smoke tests for catalog, inventory, checkout, auth
- catalog.spec.js: brand grid loads, search interaction - inventory.spec.js: table loads, detail modal opens - pos-checkout.spec.js: cart visible, catalog search from POS - auth-guard.spec.js: unauthenticated redirect to login
This commit is contained in:
20
tests/e2e/auth-guard.spec.js
Normal file
20
tests/e2e/auth-guard.spec.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
|
||||
test.describe('Nexus POS — Auth Guard', () => {
|
||||
test('unauthenticated user is redirected to login', async ({ browser }) => {
|
||||
// Create incognito context without localStorage
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.goto('/pos/sale');
|
||||
await expect(page).toHaveURL(/\/pos\/login/);
|
||||
await context.close();
|
||||
});
|
||||
|
||||
test('login page is accessible without token', async ({ browser }) => {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await page.goto('/pos/login');
|
||||
await expect(page.locator('input[type="password"], #password, input[name="pin"]')).toBeVisible();
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user