SPB Git

Repository Public

navigation.spec.ts 5.3 KB 124 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : agentilab-web8 * File             : tests/e2e/navigation.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';44import { href, routeIds } from './helpers';4546test('la navigation principale mène aux quatre pages', async ({ page, isMobile }) => {47  test.skip(isMobile, 'navigation de bureau');48  await page.goto('/');49  const nav = page.getByRole('navigation', { name: 'Navigation principale' }).first();50  for (const [label, path] of [['Entreprise', '/entreprise'], ['Écosystème', '/ecosysteme'], ['Technologies', '/technologies'], ['Contact', '/contact']] as const) {51    await nav.getByRole('link', { name: label, exact: true }).click();52    await expect(page).toHaveURL(path);53    await expect(nav.getByRole('link', { name: label, exact: true })).toHaveAttribute('aria-current', 'page');54  }55});5657for (const id of routeIds) {58  test(`le sélecteur de langue conserve la page équivalente (${id})`, async ({ page }) => {59    await page.goto(href(id, 'fr'));60    await page.locator('.header__bar > .header__end > a.lang').click();61    await expect(page).toHaveURL(href(id, 'en'));62    await expect(page.locator('html')).toHaveAttribute('lang', 'en-CA');63    await page.locator('.header__bar > .header__end > a.lang').click();64    await expect(page).toHaveURL(href(id, 'fr'));65  });66}6768test('aucune redirection automatique selon la langue du navigateur', async ({ browser }) => {69  const context = await browser.newContext({ locale: 'en-US' });70  const page = await context.newPage();71  await page.goto('/');72  await expect(page).toHaveURL('/');73  await expect(page.locator('html')).toHaveAttribute('lang', 'fr-CA');74  await context.close();75});7677test('lien d’évitement : premier arrêt du clavier, mène au contenu', async ({ page, browserName }) => {78  test.skip(browserName === 'webkit', 'Safari ne tabule pas vers les liens sans réglage système');79  await page.goto('/');80  await page.keyboard.press('Tab');81  const skip = page.getByRole('link', { name: 'Aller au contenu' });82  await expect(skip).toBeFocused();83  await page.keyboard.press('Enter');84  await expect(page).toHaveURL(/#contenu$/);85});8687test.describe('menu mobile', () => {88  test.use({ viewport: { width: 390, height: 844 } });8990  test('s’ouvre, bloque le défilement, se ferme par Échap et rend le focus', async ({ page }) => {91    await page.goto('/');92    const toggle = page.locator('.mnav > summary');93    await expect(toggle).toHaveAccessibleName('Ouvrir le menu');94    await toggle.click();95    await expect(page.locator('.mnav__panel')).toBeVisible();96    await expect(toggle).toHaveAccessibleName('Fermer le menu');97    await expect(page.locator('html')).toHaveClass(/nav-open/);98    await page.keyboard.press('Escape');99    await expect(page.locator('.mnav__panel')).toBeHidden();100    await expect(page.locator('html')).not.toHaveClass(/nav-open/);101    await expect(toggle).toBeFocused();102  });103104  test('navigue puis se referme', async ({ page }) => {105    await page.goto('/');106    await page.locator('.mnav > summary').click();107    await page.locator('.mnav__panel').getByRole('link', { name: 'Technologies' }).click();108    await expect(page).toHaveURL('/technologies');109    await expect(page.locator('.mnav__panel')).toBeHidden();110  });111});112113test('sans JavaScript : contenu, menu et catalogue restent utilisables', async ({ browser }) => {114  const context = await browser.newContext({ javaScriptEnabled: false, viewport: { width: 390, height: 844 } });115  const page = await context.newPage();116  await page.goto('/ecosysteme');117  await expect(page.getByRole('heading', { level: 1 })).toBeVisible();118  await expect(page.locator('.products > li')).toHaveCount(20);119  await expect(page.locator('.filters')).toBeHidden();120  await page.locator('.mnav > summary').click();121  await expect(page.locator('.mnav__panel').getByRole('link', { name: 'Contact' })).toBeVisible();122  await context.close();123});124
Files main
Menu

Theme