- html-validate su tutte le pagine; linkinator su astro preview (link, asset, CSS e ancore), con modalità --external per i siti esterni - e2e Playwright: struttura e metadati di ogni pagina, 404, navigazione, sottomenu, menu mobile, ancore del vecchio sito, nessuna richiesta esterna, nessun cookie, localStorage vuoto, mappa solo dopo il clic, funzionamento senza JavaScript, modulo di contatto - a11y: axe su tutte le pagine a 1440 e 390 px e negli stati interattivi, tastiera (skip link, sottomenu, menu mobile), focus visibile, testo al 200 %, reflow a 320 px, movimento ridotto - check-compliance.mjs: P.IVA, link legali, risorse sicure, segnaposto, JSON-LD, sitemap, robots, .htaccess, badge e servizi, uso di «commercialista», riferimento L. 4/2013, budget - fix: punti di interruzione in em, focus ciclico nel menu mobile, rel="noopener" sui link esterni del Markdown, numeri di telefono non spezzabili Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
100 lines
4.4 KiB
TypeScript
100 lines
4.4 KiB
TypeScript
/**
|
|
* Privacy (brief §8.2, §11.4): nessuna richiesta verso host esterni al caricamento delle pagine,
|
|
* nessun cookie, localStorage vuoto, mappa Google caricata solo dopo il clic.
|
|
*/
|
|
import { expect, test } from '@playwright/test';
|
|
import { ALL_PAGES, isLocalRequest, stubGoogle } from '../helpers/site';
|
|
|
|
test('nessuna richiesta verso host esterni, nessun cookie e localStorage vuoto', async ({
|
|
page,
|
|
context,
|
|
}) => {
|
|
const external: string[] = [];
|
|
page.on('request', (req) => {
|
|
if (!isLocalRequest(req.url())) external.push(`${req.url()} (pagina ${page.url()})`);
|
|
});
|
|
|
|
for (const path of ALL_PAGES) {
|
|
await page.goto(path, { waitUntil: 'networkidle' });
|
|
// scorrimento fino in fondo: eventuali contenuti caricati in modo differito partono ora
|
|
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
|
await page.waitForLoadState('networkidle');
|
|
const storage = await page.evaluate(() => window.localStorage.length);
|
|
expect(storage, `voci in localStorage dopo ${path}`).toBe(0);
|
|
}
|
|
|
|
expect(external, 'richieste verso host diversi da localhost').toEqual([]);
|
|
expect(await context.cookies(), 'cookie impostati durante la navigazione').toEqual([]);
|
|
});
|
|
|
|
for (const path of ['/', '/contatti/', '/dove-siamo/']) {
|
|
test(`mappa click-to-load in ${path}`, async ({ page, context }) => {
|
|
const google = await stubGoogle(page);
|
|
await page.goto(path, { waitUntil: 'networkidle' });
|
|
|
|
await expect(page.locator('iframe'), 'iframe presenti prima del clic').toHaveCount(0);
|
|
expect(google, 'richieste a Google prima del clic').toEqual([]);
|
|
|
|
const blocks = page.locator('[data-map-consent]');
|
|
const count = await blocks.count();
|
|
expect(count, 'blocchi mappa nella pagina').toBeGreaterThan(0);
|
|
const first = blocks.first();
|
|
await expect(first).toContainText('Google Maps');
|
|
await expect(first.locator('a[href="/cookie-policy/"]')).toHaveCount(1);
|
|
await expect(first.locator('a[href^="https://www.google.com/maps/search/"]')).toHaveCount(1);
|
|
await expect(first.locator('a[href^="https://www.openstreetmap.org/search"]')).toHaveCount(1);
|
|
|
|
await first.locator('[data-map-load]').click();
|
|
const iframe = first.locator('iframe');
|
|
await expect(iframe).toHaveCount(1);
|
|
await expect(iframe).toHaveAttribute('src', /^https:\/\/www\.google\.com\/maps\/embed\?pb=/);
|
|
await expect(iframe).toHaveAttribute('title', /Mappa/);
|
|
await expect(iframe).toHaveAttribute('loading', 'lazy');
|
|
await expect
|
|
.poll(() => google.length, { message: 'richiesta a Google dopo il clic' })
|
|
.toBeGreaterThan(0);
|
|
|
|
const remembered = await page.evaluate(() => sessionStorage.getItem('mappa-consentita'));
|
|
expect(remembered, 'scelta ricordata in sessionStorage').toBe('1');
|
|
|
|
// la scelta vale per la sessione: ricaricando, le mappe compaiono senza un nuovo clic
|
|
await page.reload({ waitUntil: 'networkidle' });
|
|
await expect(page.locator('[data-map-consent] iframe')).toHaveCount(count);
|
|
|
|
const ours = (await context.cookies()).filter((c) => !c.domain.includes('google'));
|
|
expect(ours, 'cookie del sito dopo il caricamento della mappa').toEqual([]);
|
|
});
|
|
}
|
|
|
|
test('senza JavaScript restano i link esterni della mappa e la navigazione', async ({
|
|
browser,
|
|
}) => {
|
|
const context = await browser.newContext({ javaScriptEnabled: false });
|
|
const page = await context.newPage();
|
|
await page.goto('/dove-siamo/');
|
|
await expect(page.locator('[data-map-load]').first()).toBeHidden();
|
|
await expect(
|
|
page.locator('a[href^="https://www.google.com/maps/search/"]').first(),
|
|
).toBeVisible();
|
|
await expect(page.locator('iframe')).toHaveCount(0);
|
|
await page.goto('/');
|
|
await expect(
|
|
page.getByRole('navigation', { name: 'Principale' }).getByRole('link', { name: 'Lo studio' }),
|
|
).toBeVisible();
|
|
await context.close();
|
|
});
|
|
|
|
test('senza JavaScript il menu è navigabile anche su mobile', async ({ browser }) => {
|
|
const context = await browser.newContext({
|
|
javaScriptEnabled: false,
|
|
viewport: { width: 390, height: 844 },
|
|
});
|
|
const page = await context.newPage();
|
|
await page.goto('/');
|
|
await expect(page.locator('[data-menu-open]')).toBeHidden();
|
|
const menu = page.getByRole('navigation', { name: 'Menu mobile' });
|
|
await expect(menu.getByRole('link', { name: 'Contatti', exact: true })).toBeVisible();
|
|
await expect(menu.locator('#menu-mobile-servizi a').first()).toBeVisible();
|
|
await context.close();
|
|
});
|