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

23
package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "autopartes",
"version": "1.0.0",
"description": "**POS + Catalogo de autopartes para refaccionarias mexicanas.**",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"test": "playwright test"
},
"repository": {
"type": "git",
"url": "https://consultoria-as:b708144ceef22fef31217f1259a695005d67477b@git.consultoria-as.com/consultoria-as/Autoparts-DB.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"devDependencies": {
"@playwright/test": "^1.59.1"
}
}

21
playwright.config.js Normal file
View File

@@ -0,0 +1,21 @@
const { defineConfig, devices } = require('@playwright/test');
module.exports = defineConfig({
testDir: './tests/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'list',
use: {
baseURL: 'http://localhost:5001',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});

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 });
});
});