import {test,expect} from '@playwright/test';import crypto from 'node:crypto'; test('profils ordonnés, équipe = 10 développeurs ; comparaison et recalcul sans soumission',async({page})=>{ await page.goto('/#simulateur');await expect(page.locator('#sim-metrics')).toBeVisible();const values={}; for(const id of ['chat','dev','agent','team']){await page.locator(`[data-profile="${id}"]`).click();const m=page.locator('#sim-metrics .metric').first();const v=JSON.parse(await m.getAttribute('data-values'))[1];values[id]=v*((await m.getAttribute('data-unit'))==='kWh'?1000:1);} expect(values.chat).toBeLessThan(values.dev);expect(values.dev).toBeLessThan(values.agent);expect(values.team).toBeCloseTo(values.dev*10,8); await page.locator('[data-profile="agent"]').click();const cmp=page.locator('#results .scenario-comparison');const before=Number(await cmp.getAttribute('data-celsius-wh'));await page.locator('#hours').fill('2');expect(Number(await cmp.getAttribute('data-celsius-wh'))).toBeCloseTo(before/2,8);await expect(cmp).toContainText('Jegham — défaut');await expect(cmp).toContainText('estimation secondaire ponctuelle'); await page.goto('/#fabrication');await expect(page.locator('.external-details .scenario-comparison')).toHaveAttribute('data-celsius-wh',/800\.0679/);await expect(page.locator('.external-details .scenario-comparison')).toContainText('Hors de la fourchette Jegham');await expect(page.locator('#fabrication')).toContainText('La contribution Claude est incluse'); }); test('audit public : archive accessible, inventaire sur liste autorisée et SHA-256 correct',async({request,page})=>{ const r=await request.get('/audit/traces-source.tar');expect(r.status()).toBe(200);const bytes=await r.body(),m=await (await request.get('/audit/manifest.json')).json();expect(crypto.createHash('sha256').update(bytes).digest('hex')).toBe(m.sha256);expect(m.files.length).toBeGreaterThan(30);expect(m.files.some(x=>x.path==='src/scenarios.mjs')).toBe(true);expect(m.files.some(x=>x.path==='tests/scenarios.test.mjs')).toBe(true);for(const f of m.files)expect(f.path).not.toMatch(/(^|\/)(\.env[^/]*|\.git|\.vercel|\.research|node_modules|sessions)(\/|$)/); const source=await request.get('/audit/files/tests/scenarios.test.mjs.txt');expect(source.status()).toBe(200);expect(await source.text()).toContain('équipe = 10 individus');await page.goto('/audit.html');await expect(page.getByRole('heading',{name:'Code et tests reproductibles'})).toBeVisible();await expect(page.locator('body')).toContainText(m.sha256); }); test('journal statique sans JS : Celsius, équivalences, natif et source géographique',async({browser})=>{ const context=await browser.newContext({javaScriptEnabled:false,viewport:{width:390,height:844}}),page=await context.newPage();try{await page.goto('/journal.html');await expect(page.locator('.external-contribution .scenario-comparison')).toContainText('Hors de la fourchette Jegham');expect(Number(await page.locator('.external-contribution .scenario-comparison').getAttribute('data-celsius-wh'))).toBeCloseTo(800.06793,8);await expect(page.locator('.native-totals [data-native-type]')).toHaveCount(4);await expect(page.locator('.journal-equivalences')).toContainText('Voiture thermique');await expect(page.locator('main')).toContainText('localisation réelle de l’inférence inconnue');expect(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth)).toBe(true);}finally{await context.close();} });