ci: fix runner image (node:20), add Playwright smoke tests
Some checks failed
CI · Test & Deploy / Playwright tests (push) Failing after 3m55s
CI · Test & Deploy / Deploy to VPS (push) Has been skipped

- Change runner to node:20 (has bash) instead of node:20-alpine
- Add tests/smoke.spec.js: 7 tests covering title, welcome screen,
  COMARCA_PATHS count (43), Lluçanès/Moianès presence, and
  filter counts (coastal=12, interior=21, mountain=10)
- Add playwright.config.js
- Fix CI workflow: use 'serve' for static server, proper SSH key setup
This commit is contained in:
Jaume Garriga Maestre
2026-05-14 11:11:39 +02:00
parent 8c9b1ccfce
commit 2f90d41be3
3 changed files with 106 additions and 14 deletions

75
tests/smoke.spec.js Normal file
View File

@@ -0,0 +1,75 @@
// smoke.spec.js — Basic smoke tests for comarques app
// Runs against a static HTTP server (no DB required).
// Playwright is invoked with chromium via npx.
const { test, expect } = require('@playwright/test');
const BASE = process.env.APP_URL || 'http://localhost:9090';
test.describe('App loads', () => {
test('title is correct', async ({ page }) => {
await page.goto(BASE + '/index.html');
await expect(page).toHaveTitle(/Comarques de Catalunya/);
});
test('welcome screen is shown on first load', async ({ page }) => {
await page.goto(BASE + '/index.html');
// Clear any existing player so we always land on welcome
await page.evaluate(() => localStorage.clear());
await page.reload();
const welcome = page.locator('#screen-welcome');
await expect(welcome).toBeVisible();
});
});
test.describe('comarca-paths.js', () => {
test('COMARCA_PATHS loads and has 43 entries', async ({ page }) => {
await page.goto(BASE + '/index.html');
await page.waitForTimeout(500);
const count = await page.evaluate(() => Object.keys(COMARCA_PATHS).length);
expect(count).toBe(43);
});
test('Lluçanès and Moianès have map paths', async ({ page }) => {
await page.goto(BASE + '/index.html');
await page.waitForTimeout(500);
const result = await page.evaluate(() => ({
llucanes: !!COMARCA_PATHS['Lluçanès'],
moianes: !!COMARCA_PATHS['Moianès'],
}));
expect(result.llucanes).toBe(true);
expect(result.moianes).toBe(true);
});
});
test.describe('Filters', () => {
test('coastal filter returns 12 comarques', async ({ page }) => {
await page.goto(BASE + '/index.html');
await page.waitForTimeout(500);
const count = await page.evaluate(() => {
activeGroups = new Set(['coastal']);
return getActiveComarques().length;
});
expect(count).toBe(12);
});
test('interior filter returns 21 comarques', async ({ page }) => {
await page.goto(BASE + '/index.html');
await page.waitForTimeout(500);
const count = await page.evaluate(() => {
activeGroups = new Set(['interior']);
return getActiveComarques().length;
});
expect(count).toBe(21);
});
test('mountain filter returns 10 comarques', async ({ page }) => {
await page.goto(BASE + '/index.html');
await page.waitForTimeout(500);
const count = await page.evaluate(() => {
activeGroups = new Set(['mountain']);
return getActiveComarques().length;
});
expect(count).toBe(10);
});
});