Files
Studio_Grasso/tests/e2e/navigation.spec.ts
T
Alby96andClaude Opus 5.5 3befe7e266 fix: CI adattata a Forgejo, revisione completa del codice e avvio in debug
Le run della CI restavano «in attesa» perché l'unico runner dell'istanza («Ferrari») non si è
mai collegato: il runner resta da configurare. La revisione completa del codice ha trovato
anche difetti che avrebbero fatto fallire la CI con il runner online, oltre ad altri problemi
del sito, dei controlli e della documentazione.

CI e rilascio:
- continue-on-error sullo step dei link esterni: Forgejo lo ignora sul job, e un sito esterno
  irraggiungibile avrebbe reso rossa la CI;
- artifact con i file nascosti (report Lighthouse e .htaccess non venivano mai caricati);
- token personale RELEASE_TOKEN: FORGEJO_TOKEN è riservato ed è sempre il token automatico;
- dominio in un solo punto (site.config.mjs) e variabile del repository SITE_URL;
- ripiego REST: release in bozza, file, poi pubblicazione; tag verificato sul server;
  sostituzione dei file senza mai lasciarli mancanti;
- tar.gz identico su Windows, macOS e Linux (byte del sistema operativo nell'header gzip).

Sito: CSS compatibile con Safari/iOS 15 (media query classiche, backdrop-filter), anello di
focus con contrasto di almeno 3:1, bersagli touch di 44 px dove servono, intestazione desktop
senza voci o logo a capo, HTML valido in /servizi/, colore delle chip, stampa senza mappe,
giorni di apertura, ricerca e titolo delle mappe e numero breve ricavati dai dati.

Modulo di contatto e contact.php: stesse regole nel browser e sul server (spazi, e-mail,
a capo, lunghezze), tempo minimo misurato con un solo orologio (ts_invio), corpo in
quoted-printable e oggetto RFC 2047, funzionamento con PHP a 32 bit, costante
MODALITA_PREDEFINITA per attivarlo.

Controlli e test: valori letti dai dati del sito, i sei servizi del brief con le ancore,
«commercialista» anche in meta, attributi e dati strutturati, .htaccess su righe attive,
HSTS attivabile con una scelta esplicita, contrasto del focus misurato nei test.

Esempi di pubblicazione: nginx con gli header di sicurezza in un solo punto (HSTS compreso),
deploy automatico che parte alla pubblicazione e sincronizza solo una cartella confermata,
procedura nginx che toglie i file delle versioni precedenti.

Debug: .vscode/launch.json e tasks.json, F5 avvia il server Astro e apre il browser con il
debugger collegato.

Documentazione aggiornata (README, DEPLOY, CONTENUTI, CONFORMITA, TODO-STUDIO, CHANGELOG) e
decisioni D-045…D-055.

Verificato: npm run verify su Windows e nel container della CI (Playwright 1.56.1, root);
job dei link esterni in node:24; contact.php con PHP 7.4 e 8.3, a 64 e 32 bit; nginx in
Docker; release-upload.sh e deploy di esempio contro API e shell simulate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:40:16 +02:00

141 lines
5.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Navigazione (brief §5.2, §5.3, §11.4): intestazione, sottomenu dei servizi, footer,
* breadcrumb, precedente/successivo e redirect delle ancore del vecchio sito.
*/
import { expect, test } from '@playwright/test';
import { ctaHeader, navLegale, navPrincipale } from '../../src/data/navigazione';
import { SERVICE_PAGES } from '../helpers/site';
// voci lette dalla stessa fonte del sito: cambiare un'etichetta non rompe i test
const MAIN_NAV = navPrincipale.map((v) => ({ label: v.label, path: v.href }));
const SERVIZI = navPrincipale.find((v) => v.servizi)?.label ?? 'Servizi';
test('le voci dell’intestazione portano alle pagine giuste', async ({ page }) => {
for (const item of MAIN_NAV) {
await page.goto('/');
const nav = page.getByRole('navigation', { name: 'Principale' });
await nav.getByRole('link', { name: item.label, exact: true }).click();
await expect(page, `la voce «${item.label}» porta a ${item.path}`).toHaveURL(item.path);
await expect(
page.getByRole('navigation', { name: 'Principale' }).getByRole('link', {
name: item.label,
exact: true,
}),
`la voce «${item.label}» è evidenziata come pagina corrente`,
).toHaveAttribute('aria-current', 'page');
}
});
test(`logo e pulsante «${ctaHeader.label}»`, async ({ page }) => {
await page.goto('/studio/');
await page.locator('header .brand').first().click();
await expect(page).toHaveURL('/');
await page
.getByRole('navigation', { name: 'Principale' })
.getByRole('link', { name: ctaHeader.label })
.click();
await expect(page).toHaveURL(ctaHeader.href);
});
test('il sottomenu «Servizi» elenca tutti i servizi e si apre con il pulsante', async ({
page,
}) => {
await page.goto('/');
const toggle = page.locator('.nav [data-submenu-toggle]');
const submenu = page.locator('#sottomenu-servizi');
await expect(submenu).toBeHidden();
await toggle.click();
await expect(toggle).toHaveAttribute('aria-expanded', 'true');
await expect(submenu).toBeVisible();
await expect(submenu.getByRole('link')).toHaveCount(SERVICE_PAGES.length);
await submenu.getByRole('link').first().click();
await expect(page).toHaveURL(/\/servizi\/[a-z-]+\/$/);
await expect(
page.getByRole('navigation', { name: 'Principale' }).getByRole('link', {
name: SERVIZI,
exact: true,
}),
).toHaveAttribute('aria-current', 'true');
});
test('il sottomenu si apre anche al passaggio del mouse e si chiude con un clic fuori', async ({
page,
}) => {
await page.goto('/');
const submenu = page.locator('#sottomenu-servizi');
await page.locator('.nav__item--has-sub').hover();
await expect(submenu).toBeVisible();
await page.mouse.move(10, 600);
await expect(submenu).toBeHidden();
await page.locator('.nav [data-submenu-toggle]').click();
await expect(submenu).toBeVisible();
await page.mouse.move(10, 600);
await page.locator('main h1').click();
await expect(submenu).toBeHidden();
});
test('tutti i link del footer funzionano', async ({ page, request }) => {
await page.goto('/');
const hrefs = await page
.locator('footer a[href^="/"]')
.evaluateAll((links) => links.map((a) => a.getAttribute('href') ?? ''));
expect(hrefs.length, 'link interni nel footer').toBeGreaterThanOrEqual(11);
for (const href of new Set(hrefs)) {
const response = await request.get(href);
expect(response.status(), `link del footer ${href}`).toBe(200);
}
for (const { label, href } of navLegale) {
const link = page.getByRole('navigation', { name: 'Informazioni legali' }).getByRole('link', {
name: label,
exact: true,
});
await expect(link).toBeVisible();
await expect(link).toHaveAttribute('href', href);
}
});
test('breadcrumb, barra laterale e precedente/successivo nelle pagine dei servizi', async ({
page,
}) => {
for (const path of SERVICE_PAGES) {
await page.goto(path);
const breadcrumb = page.getByRole('navigation', { name: 'Percorso' });
await expect(breadcrumb.getByRole('link', { name: 'Home' })).toHaveAttribute('href', '/');
await expect(breadcrumb.getByRole('link', { name: 'Servizi' })).toHaveAttribute(
'href',
'/servizi/',
);
await expect(
page.locator('.sidenav a[aria-current="page"]'),
`servizio corrente evidenziato in ${path}`,
).toHaveAttribute('href', path);
}
await page.goto(SERVICE_PAGES[0]);
const pager = page.getByRole('navigation', { name: 'Servizio precedente e successivo' });
const next = await pager.locator('a[rel="next"]').getAttribute('href');
await pager.locator('a[rel="next"]').click();
await expect(page).toHaveURL(next ?? '');
await page
.getByRole('navigation', { name: 'Servizio precedente e successivo' })
.locator('a[rel="prev"]')
.click();
await expect(page).toHaveURL(SERVICE_PAGES[0]);
});
test('le ancore del vecchio sito portano al servizio corrispondente', async ({ page }) => {
await page.goto('/servizi/');
const cards = await page
.locator('[data-legacy-href]')
.evaluateAll((els) =>
els.map((el) => ({ id: el.id, href: el.getAttribute('data-legacy-href') })),
);
// una card per servizio (i 6 del brief e quelli aggiunti dopo), ognuna con la sua ancora
expect(cards.length, 'card con ancora del vecchio sito').toBe(SERVICE_PAGES.length);
for (const { id, href } of cards) {
await page.goto(`/servizi/#${id}`);
await expect(page, `l'ancora #${id} porta a ${href}`).toHaveURL(href ?? '');
}
await page.goto('/servizi/#ancora-sconosciuta');
await expect(page).toHaveURL('/servizi/#ancora-sconosciuta');
});