SPB Git

Repository Public

metre.spec.ts 11.7 KB 178 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | ACADEMIC RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * PROJECT METADATA8 * -----------------------------------------------------------------------------9 * Project          : UQO Éval10 * File             : e2e/metre.spec.ts11 * Module           : e2e12 * Repository       : https://git.spboucher.ai/uqo-eval13 * Project Website  : https://www.uqo-eval.app14 * Created          : 2026-10-2815 * Last Modified    : 2026-10-2816 *17 * =============================================================================18 * SOFTWARE MAINTAINER & AFFILIATION19 * =============================================================================20 *21 * Maintainer       : Simon-Pierre Boucher22 * Position         : Professor of Finance23 * Institution      : Université du Québec en Outaouais (UQO)24 * Department       : Département des sciences administratives25 * Website          : https://spboucher.ai26 * Git              : https://git.spboucher.ai27 *28 * Research Contact : research@spboucher.ai29 * Direct Contact   : simon@spboucher.ai30 * Security/Admin   : admin@spboucher.ai31 *32 * The affiliation is descriptive. It is not an institutional endorsement,33 * a license grant or a determination of ownership.34 *35 * =============================================================================36 * COPYRIGHT, AUTHORSHIP & DATA37 * =============================================================================38 *39 * Copyright (c) the author(s) of this work.40 * Ownership is not asserted by this notice; see the repository records.41 *42 * This header identifies the maintainer of the software. Scientific43 * authorship of any associated paper is stated in the paper itself and44 * is not changed by this notice. Datasets and third-party materials45 * remain the property of their respective owners and licensors.46 *47 * This file is governed by the applicable project license, copyright48 * notices, institutional agreements and relevant law.49 *50 * =============================================================================51 * LICENSE & MAINTENANCE52 * =============================================================================53 *54 * License          : None specified (no license file in this repository)55 * Classification   : Public56 *57 * =============================================================================58 * END OF SP BOUCHER SOURCE HEADER59 * =============================================================================60 */6162// UQO Éval — Quantity Survey : parcours de bout en bout dans Chromium, PLATEFORME OUVERTE (aucune connexion) — tableau de bord → projet → plan vierge →63// murs à épaisseur, porte, fenêtre, pièce → mesures au registre → estimation → révision → PDF du plan et de l'estimation ; régression des pages existantes.64import { expect, test, type Page } from "playwright/test";6566async function openDashboard(page: Page) {67  await page.goto("/quantity-survey");68  await expect(page.getByRole("heading", { level: 1 })).toContainText(/Tableau de bord|Dashboard/, { timeout: 20_000 });69}7071test("régression : pages existantes d'UQO Éval répondent et la navigation mène au Quantity Survey", async ({ page }) => {72  for (const p of ["/", "/cout", "/a-vendre", "/stats", "/methodologie", "/hedonique"]) {73    const r = await page.goto(p);74    expect(r?.status(), p).toBe(200);75  }76  await page.goto("/");77  await expect(page.getByRole("link", { name: /Quantity Survey/ }).first()).toBeVisible();78});7980test("plateforme ouverte : session automatique, plan d'architecte, registre, estimation, révision, exports", async ({ page }) => {81  await openDashboard(page);82  await expect(page.getByText(/Visiteur-|session ouverte|open session/).first()).toBeVisible({ timeout: 15_000 }); // aucune connexion demandée83  // projet84  await page.getByRole("button", { name: /Nouveau projet|New project/ }).first().click();85  await page.getByLabel(/Nom du projet|Project name/).fill("E2E architecte");86  await page.getByLabel(/Municipalité|Municipality/).fill("Gatineau");87  await page.getByRole("button", { name: /Créer et ouvrir|Create and open/ }).click();88  await expect(page).toHaveURL(/\/quantity-survey\/projets\//, { timeout: 20_000 });89  // plan vierge 20 × 15 m à 40 px/m90  await page.getByRole("button", { name: /Plan vierge à l'échelle|Blank plan to scale/ }).click();91  await page.getByLabel(/Largeur|Width/).fill("20"); await page.getByLabel(/Hauteur \(m\)|Height \(m\)/).fill("15"); await page.getByLabel(/Échelle|Scale/).fill("40");92  await page.getByRole("button", { name: /^Créer le plan$|^Create plan$/ }).click();93  await expect(page.locator(".pl-canvas svg")).toBeVisible({ timeout: 20_000 });94  await expect(page.getByText(/px\/m/).first()).toBeVisible();95  // repère du canevas : la page tient dans le canevas (« ajuster ») ; on lit la transformation pour convertir m → écran96  const svg = page.locator(".pl-canvas svg");97  await page.waitForTimeout(300);98  // le panneau latéral apparaît/disparaît selon la sélection : on relit la boîte et la transformation avant chaque série de clics99  let box = (await svg.boundingBox())!, tx = 0, ty = 0, k = 1;100  const refresh = async () => { await page.waitForTimeout(150); box = (await svg.boundingBox())!; const t = await page.locator(".pl-canvas svg > g").getAttribute("transform"); const m = t!.match(/translate\(([-\d.]+) ([-\d.]+)\) scale\(([-\d.]+)\)/)!; tx = Number(m[1]); ty = Number(m[2]); k = Number(m[3]); };101  await refresh();102  const at = (xm: number, ym: number) => ({ x: box.x + tx + xm * 40 * k, y: box.y + ty + ym * 40 * k });103  // murs extérieurs : rectangle 10 × 8 m fermé en revenant au premier point104  await page.keyboard.press("w");105  for (const [x, y] of [[2, 2], [12, 2], [12, 10], [2, 10], [2, 2]]) { const p = at(x, y); await page.mouse.click(p.x, p.y); }106  await expect(page.locator(".pl-list button", { hasText: /Mur ext\.|Ext\. wall/ })).toHaveCount(1, { timeout: 10_000 });107  // cloison par longueur tapée : 8 m vers le bas depuis (7,2)108  await page.keyboard.press("i");109  const a = at(7, 2); await page.mouse.click(a.x, a.y);110  const b = at(7, 6); await page.mouse.move(b.x, b.y);111  await page.keyboard.type("8"); await page.keyboard.press("Enter"); await page.keyboard.press("Enter");112  await expect(page.locator(".pl-list button", { hasText: /Cloison|Partition/ })).toHaveCount(1);113  // porte et fenêtre sur le mur extérieur114  await page.keyboard.press("Escape"); await refresh();115  await page.keyboard.press("d"); { const p = at(4, 2); await page.mouse.click(p.x, p.y); }116  await page.keyboard.press("Escape"); await refresh();117  await page.keyboard.press("n"); { const p = at(9, 2); await page.mouse.click(p.x, p.y); }118  await expect(page.locator(".pl-list button", { hasText: /Porte|Door/ })).toHaveCount(1);119  await expect(page.locator(".pl-list button", { hasText: /Fenêtre|Window/ })).toHaveCount(1);120  // pièce rectangle 5 × 8 m par deux clics121  await page.keyboard.press("Escape"); await refresh();122  await page.keyboard.press("x"); { const p = at(2, 2); await page.mouse.click(p.x, p.y); } { const p = at(7, 10); await page.mouse.click(p.x, p.y); }123  await expect(page.locator(".pl-list button", { hasText: /Pièce|Room/ })).toHaveCount(1);124  await expect(page.locator(".pl-status")).toContainText(/1 portes|1 doors/);125  // registre126  await page.getByRole("button", { name: /Mesurer tout → registre|Measure all → ledger/ }).click();127  await expect(page.locator(".pl-status")).toContainText(/mesures au registre|measurements in ledger/, { timeout: 20_000 });128  await page.locator(".mt-tabs button", { hasText: /^Relevé$|^Takeoff$/ }).click();129  await expect(page.locator("table")).toContainText(/mur brut|wall gross/i);130  await expect(page.locator("table")).toContainText(/36/); // périmètre 36 m131  await expect(page.locator("table")).toContainText(/40/); // pièce 5 × 8 = 40 m²132  await page.getByRole("button", { name: /^Vérifier$|^Verify$/ }).first().click();133  // estimation : toutes les mesures + hypothèse, révision, PDF134  await page.locator(".mt-tabs button", { hasText: /^Estimation$|^Estimate$/ }).click();135  await page.getByRole("button", { name: /Créer une estimation|Create an estimate/ }).click();136  await page.getByRole("button", { name: /Toutes les mesures non liées|All unlinked measurements/ }).click();137  await page.getByRole("button", { name: /Ligne hypothèse|Assumption line/ }).click();138  await page.locator('input[placeholder="$"]').first().fill("2500");139  await expect(page.getByText(/TOTAL/)).toBeVisible();140  await page.waitForTimeout(1200);141  page.on("dialog", (d) => void d.accept(d.type() === "prompt" ? d.defaultValue() || "Révision E2E" : undefined));142  await page.getByRole("button", { name: /Figer une révision|Freeze a revision/ }).click();143  await expect(page.getByText(/r1 —/).first()).toBeVisible({ timeout: 15_000 });144  await page.locator(".mt-tabs button", { hasText: /^Rapports$|^Reports$/ }).click();145  const href = await page.getByRole("link", { name: "PDF FR" }).first().getAttribute("href");146  const pdf = await page.evaluate(async (u) => { const r = await fetch(u); const b = new Uint8Array(await r.arrayBuffer()); return { status: r.status, head: String.fromCharCode(...b.subarray(0, 4)), bytes: b.length }; }, href!);147  expect(pdf.status).toBe(200); expect(pdf.head).toBe("%PDF"); expect(pdf.bytes).toBeGreaterThan(20_000);148  // export du plan (cartouche)149  await page.locator(".mt-tabs button", { hasText: /^Plans$/ }).click();150  const planHref = await page.locator("a", { hasText: /^PDF$/ }).first().getAttribute("href");151  const planPdf = await page.evaluate(async (u) => { const r = await fetch(u); const b = new Uint8Array(await r.arrayBuffer()); return { status: r.status, head: String.fromCharCode(...b.subarray(0, 4)) }; }, planHref!);152  expect(planPdf.status).toBe(200); expect(planPdf.head).toBe("%PDF");153  // nettoyage154  await page.locator(".mt-tabs button", { hasText: /^Fiche$|^Sheet$/ }).click();155  await page.getByRole("button", { name: /^Supprimer$|^Delete$/ }).click();156  await expect(page).toHaveURL(/\/quantity-survey$/, { timeout: 15_000 });157});158159test("RSMeans Québec : explorateur du catalogue et cas d'étude tarifé RSMeans", async ({ page }) => {160  await page.goto("/quantity-survey/catalogue");161  await expect(page.locator("#rsmeans")).toBeVisible({ timeout: 20_000 });162  await expect(page.locator("#rsmeans table tbody tr").first()).toContainText(/\d{12}/, { timeout: 20_000 });163  await page.locator("#rsmeans select").first().selectOption("");164  await page.locator("#rsmeans input").first().fill("asphalt shingles laminated");165  await expect(page.locator("#rsmeans table tbody").first()).toContainText(/0731131/, { timeout: 20_000 });166  await page.goto("/quantity-survey");167  await page.locator("a", { hasText: /^Cas 1 /}).first().click();168  await expect(page).toHaveURL(/\/quantity-survey\/projets\//, { timeout: 20_000 });169  await page.locator(".mt-tabs button", { hasText: /^Estimation$|^Estimate$/ }).click();170  await expect(page.locator("table").first()).toContainText(/RSMeans \d{12}/, { timeout: 20_000 });171  await expect(page.getByText(/Ville RSMeans|RSMeans city/).first()).toBeVisible();172  // rapport PDF de la révision figée du cas (lignes RSMeans)173  await page.locator(".mt-tabs button", { hasText: /^Rapports$|^Reports$/ }).click();174  const href = await page.locator("a", { hasText: /^PDF FR$/ }).first().getAttribute("href");175  const pdf = await page.evaluate(async (u) => { const r = await fetch(u); const b = new Uint8Array(await r.arrayBuffer()); return { status: r.status, head: String.fromCharCode(...b.subarray(0, 4)), size: b.length }; }, href!);176  expect(pdf.status).toBe(200); expect(pdf.head).toBe("%PDF"); expect(pdf.size).toBeGreaterThan(30_000);177});178
Files main
Menu

Theme