Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : agentilab-web8 * File : tests/e2e/staging.spec.ts9 * Module : Tests10 * Repository : https://git.spboucher.ai/agentilab-web11 * Project Website : Not specified12 * Created : 2026-12-0513 * Last Modified : 2026-12-0514 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : Proprietary34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import { expect, test } from '@playwright/test';4445const STAGING = 'http://localhost:8192';46const auth = { Authorization: `Basic ${Buffer.from('essai:essai-local-seulement').toString('base64')}` };4748test.describe('mode staging (même artefact, SITE_ENV=staging)', () => {49 test('refuse l’accès sans authentification', async ({ request }) => {50 for (const path of ['/', '/en', '/sitemap.xml', '/og.png']) {51 const response = await request.get(STAGING + path);52 expect(response.status(), path).toBe(401);53 expect(response.headers()['www-authenticate']).toContain('Basic');54 expect(response.headers()['x-robots-tag']).toContain('noindex');55 }56 expect((await request.get(`${STAGING}/`, { headers: { Authorization: 'Basic ZmF1eDpmYXV4' } })).status()).toBe(401);57 });5859 test('sert le site, en noindex, une fois authentifié', async ({ request }) => {60 const response = await request.get(`${STAGING}/`, { headers: auth });61 expect(response.status()).toBe(200);62 expect(response.headers()['x-robots-tag']).toBe('noindex, nofollow');63 expect(response.headers()['strict-transport-security']).toBe('max-age=300');64 expect(await response.text()).toContain('Nous construisons les technologies de demain.');65 });6667 test('sert les images optimisées (la relecture interne de l’optimiseur n’est pas bloquée)', async ({ request }) => {68 const optimized = await request.get(`${STAGING}/_next/image?url=%2Fbrands%2Forix%2Fcalc%2Ficon.webp&w=48&q=75`, { headers: auth });69 expect(optimized.status()).toBe(200);70 expect(optimized.headers()['content-type']).toMatch(/^image\//);71 // L’optimiseur lui-même reste derrière l’authentification.72 expect((await request.get(`${STAGING}/_next/image?url=%2Fbrands%2Forix%2Fcalc%2Ficon.webp&w=48&q=75`)).status()).toBe(401);73 expect((await request.get(`${STAGING}/brands/orix/calc/icon.webp`)).headers()['x-robots-tag']).toContain('noindex');74 });7576 test('ferme robots.txt', async ({ request }) => {77 const body = await (await request.get(`${STAGING}/robots.txt`, { headers: auth })).text();78 expect(body).toBe('User-agent: *\nDisallow: /\n');79 });8081 test('laisse la sonde de santé ouverte', async ({ request }) => {82 expect((await request.get(`${STAGING}/healthz`)).status()).toBe(200);83 });84});85