SPB Git

Repository Public

shots.mjs 3.8 KB 57 lines javascript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Note SPBoucher AI8 * File             : tests/e2e/shots.mjs9 * Module           : tests10 * Repository       : https://git.spboucher.ai/note-spboucher-ai11 * Project Website  : https://note.spboucher.ai12 * Created          : 2026-11-1713 * Last Modified    : 2026-11-1714 *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 */4243// ad-hoc visual pass: node tests/e2e/shots.mjs [width] → test-results/shots/*.png (uses the saved e2e session; test database only)44import { chromium } from "@playwright/test"; import fs from "node:fs";45const w = Number(process.argv[2] ?? 360); const h = w < 500 ? 740 : 800; fs.mkdirSync("test-results/shots", { recursive: true });46const b = await chromium.launch(); const ctx = await b.newContext({ baseURL: "http://localhost:8481", storageState: "test-results/.auth/state.json", viewport: { width: w, height: h }, hasTouch: w < 800, isMobile: w < 800, deviceScaleFactor: 2 });47const p = await ctx.newPage(); const errs = []; p.on("pageerror", (e) => errs.push("PAGEERROR " + e.message.slice(0, 300))); p.on("console", (m) => { if (m.type() === "error") errs.push("CONSOLE " + m.text().slice(0, 300)); });48const shot = async (name) => { await p.waitForTimeout(700); const o = await p.evaluate(() => ({ dw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth, mw: document.getElementById("main-scroll")?.scrollWidth, mc: document.getElementById("main-scroll")?.clientWidth })); await p.screenshot({ path: `test-results/shots/${w}-${name}.png` }); console.log(name, JSON.stringify(o), (o.dw > o.cw + 1 || (o.mw ?? 0) > (o.mc ?? 0) + 1) ? "OVERFLOW" : "ok"); };49await p.goto("/"); await shot("home");50if (w < 800) { await p.getByRole("button", { name: "Quick capture" }).click(); await shot("capture"); await p.keyboard.press("Escape"); await p.getByRole("button", { name: "More" }).click(); await shot("drawer"); await p.keyboard.press("Escape"); }51await p.goto("/inbox"); await shot("inbox");52const tree = await (await p.request.get("/api/tree")).json(); const page = tree.find((n) => n.type === "page"); const dbp = tree.find((n) => n.type === "database");53if (page) { await p.goto(`/p/${page.id}`); await shot("page"); await p.locator(".ProseMirror").first().click(); await shot("page-editing"); }54if (dbp) { await p.goto(`/p/${dbp.id}`); await shot("database"); }55for (const r of ["search?q=test", "tasks", "settings", "research", "graph", "backlinks", "ai/agents", "ai/models", "trash", "archive"]) { await p.goto("/" + r); await shot(r.replace(/[^a-z]/g, "-")); }56console.log(errs.slice(0, 12).join("\n")); await b.close();57
Files main
Menu

Theme