import {test, expect} from '@playwright/test'; async function expectPublicCodeLink(page) { await expect(page.locator('a[href*="github.com/gtbia-agent-demo/agent-footprint"]')).toHaveCount(0); const link = page.getByRole('link', {name: 'Code source et tests', exact: true}).first(); await expect(link).toBeVisible(); await expect(link).toHaveAttribute('href', '/audit.html'); await link.click(); await expect(page.getByRole('heading', {name: 'Code et tests reproductibles', exact: true})).toBeVisible(); await expect(page.locator('a[href*="github.com/gtbia-agent-demo/agent-footprint"]')).toHaveCount(0); await expect(page.locator('body')).toContainText('reste privé'); } for (const route of ['comprendre', 'simulateur', 'fabrication', 'methode']) { test(`accès public au code depuis ${route}`, async ({page}) => { await page.goto(`/#${route}`); await expect(page.locator(`#${route}`)).toBeVisible(); await expectPublicCodeLink(page); }); } test.describe('accès au code sans JavaScript', () => { test.use({javaScriptEnabled: false}); for (const path of ['/', '/methode.html', '/journal.html']) { test(`archive accessible depuis ${path}`, async ({page}) => { await page.goto(path); await expectPublicCodeLink(page); }); } }); test('échec du chargement : accès public de secours', async ({page}) => { await page.route('**/data/usage.jsonl', route => route.fulfill({status: 503, body: ''})); await page.goto('/'); await expect(page.getByRole('heading', {name: 'Chargement impossible'})).toBeVisible(); await expectPublicCodeLink(page); });