SPB Git

Repository Public

smoke.mjs 3.6 KB 56 lines javascript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Note SPBoucher AI8 * File             : tests/e2e/next/smoke.mjs9 * Module           : tests10 * Repository       : https://git.spboucher.ai/note-spboucher-ai11 * Project Website  : https://note.spboucher.ai12 * Created          : 2026-11-1913 * Last Modified    : 2026-11-1914 *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          : None specified (no license file in this repository)34 *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 { chromium } from "@playwright/test"; import fs from "node:fs";44const base = process.env.E2E_BASE_URL ?? "http://localhost:8485"; const w = Number(process.argv[2] ?? 1280);45const b = await chromium.launch(); const ctx = await b.newContext({ baseURL: base, storageState: "test-results/.auth/state.json", viewport: { width: w, height: 900 }, hasTouch: w < 800, isMobile: w < 800 });46const p = await ctx.newPage(); const errs = []; p.on("pageerror", (e) => errs.push("PAGEERROR " + e.message.slice(0, 400))); p.on("console", (m) => { if (m.type() === "error" || m.type() === "warning") errs.push(m.type().toUpperCase() + " " + m.text().slice(0, 300)); });47const content = { type: "doc", content: JSON.parse(fs.readFileSync("tests/e2e/next/all-nodes.json", "utf8")) };48const r = await p.request.post("/api/pages", { data: { title: "E2E-smoke all nodes", content }, headers: { origin: base, "content-type": "application/json" } }); const pg = await r.json();49await p.goto(`/p/${pg.id}`); await p.locator(".ProseMirror").first().waitFor(); await p.waitForTimeout(5000);50const o = await p.evaluate(() => ({ nodes: [...document.querySelectorAll(".nb[data-node]")].map((n) => n.getAttribute("data-node")), lock: !!document.querySelector("[data-testid=editor-lock]"), dw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth, mw: document.getElementById("main-scroll")?.scrollWidth, mc: document.getElementById("main-scroll")?.clientWidth }));51console.log(JSON.stringify(o)); await p.screenshot({ path: `test-results/smoke-${w}.png`, fullPage: false });52const h = await p.evaluate(() => document.getElementById("main-scroll").scrollHeight); await p.setViewportSize({ width: w, height: Math.min(h + 100, 12000) }); await p.waitForTimeout(1200); await p.screenshot({ path: `test-results/smoke-${w}-full.png` });53console.log(errs.slice(0, 25).join("\n") || "no console errors");54if (!process.env.KEEP) await p.request.delete(`/api/pages/${pg.id}`, { headers: { origin: base } }); else console.log("page", pg.id);55await b.close();56
Files main
Menu

Theme