74 lines
2.4 KiB
JavaScript
74 lines
2.4 KiB
JavaScript
// 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 exists in DOM', async ({ page }) => {
|
|
await page.goto(BASE + '/index.html');
|
|
// The welcome screen must always be present in the DOM
|
|
const welcome = page.locator('#screen-welcome');
|
|
await expect(welcome).toBeAttached();
|
|
});
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|