SPB Git

Repository Public

05-screens.spec.ts 5.7 KB 127 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : MacLustr Command Center (MCC)8 * File             : apps/web/e2e/specs/05-screens.spec.ts9 * Module           : web10 * Repository       : https://git.spboucher.ai/maclustr-command-center11 * Project Website  : https://clustr.spboucher.ai12 * Created          : 2026-11-1813 * Last Modified    : 2026-11-1814 *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: admin@spboucher.ai23 * Technical Contact: dev@spboucher.ai24 * Security/Admin   : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License          : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142import { expect, test, type BrowserContext, type Page } from "@playwright/test";43import { endpointLive, signedIn, type Problems } from "../lib/harness";44import { SCREENS } from "../lib/screens";4546// Every main screen renders its frame for the owner. While the endpoint group behind a screen still answers 501,47// the screen must say "not available yet" — never an empty or invented view. Once it answers 200 the real view is48// asserted by 06-cluster-data / 07-operations.49test.describe.serial("main screens: real view or explicit not-available state", () => {50  let context: BrowserContext;51  let page: Page;52  let problems: Problems;53  test.beforeAll(async ({ browser }) => {54    ({ context, page, problems } = await signedIn(browser, "e2e-owner"));55  });56  test.afterAll(async () => {57    await context.close();58  });5960  for (const s of SCREENS) {61    test(`${s.name} (${s.path})`, async () => {62      const live = await endpointLive(page, s.endpoint);63      test.info().annotations.push({ type: "endpoint", description: `${s.endpoint} → ${live ? "200 (live)" : "not live"}` });64      await page.goto(s.path);65      await expect(page.getByTestId(s.testid)).toBeVisible();66      await expect(page.locator("h1")).toHaveCount(1);67      await expect(page.locator("main#main")).toBeVisible();68      if (!live) {69        await expect(page.getByTestId("not-available").first()).toBeVisible();70        await expect(page.getByText("Pas encore disponible").first()).toBeVisible();71      }72      // no error boundary, no raw key, no "undefined"/"NaN" leaking into the page73      const text = await page.locator("main#main").innerText();74      expect(text).not.toMatch(/\bundefined\b|\bNaN\b|\[object Object\]/);75    });76  }7778  test("unknown address: not-found page", async () => {79    await page.goto("/does-not-exist");80    await expect(page.getByRole("heading", { name: "Page introuvable" })).toBeVisible();81  });8283  test("command palette: ⌘K opens, navigation commands work, search degrades explicitly", async () => {84    await page.goto("/");85    await page.keyboard.press("ControlOrMeta+k");86    const input = page.getByTestId("palette-input");87    await expect(input).toBeFocused();88    await input.fill("stock");89    await expect(page.getByRole("option", { name: /Stockage/ })).toBeVisible();90    if (!(await endpointLive(page, "/search?q=stock"))) await expect(page.getByTestId("search-unavailable")).toBeVisible();91    await input.press("Enter");92    await expect(page).toHaveURL(/\/storage$/);93    await expect(page.getByTestId("palette-input")).toHaveCount(0);94  });9596  test("mobile width: bottom navigation replaces the sidebar, no horizontal overflow", async () => {97    await page.setViewportSize({ width: 360, height: 740 });98    for (const path of ["/", "/nodes", "/maintenance", "/settings"]) {99      await page.goto(path);100      await expect(page.getByRole("navigation", { name: "Navigation rapide" })).toBeVisible();101      await expect(page.getByRole("complementary")).toBeHidden();102      const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);103      expect(overflow, `horizontal overflow on ${path}`).toBeLessThanOrEqual(1);104    }105    await page.getByRole("button", { name: "Plus" }).click();106    await page.getByRole("dialog").getByRole("link", { name: "Audit" }).click();107    await expect(page).toHaveURL(/\/audit$/);108    await page.setViewportSize({ width: 1440, height: 900 });109  });110111  test("theme switch applies the light tokens and persists", async () => {112    await page.goto("/");113    await page.getByTestId("account-menu").click();114    await page.getByRole("menuitem", { name: "Thème clair" }).click();115    await expect(page.locator("html")).toHaveAttribute("data-theme", "light");116    await page.reload();117    await expect(page.locator("html")).toHaveAttribute("data-theme", "light");118    await page.getByTestId("account-menu").click();119    await page.getByRole("menuitem", { name: "Thème sombre" }).click();120    await expect(page.locator("html")).not.toHaveAttribute("data-theme", "light");121  });122123  test("no CSP violation and no console error", async () => {124    problems.assertClean();125  });126});127
Files main
Menu

Theme