Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Note SPBoucher AI8 * File : tests/e2e/shots2.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 of the database / agents / assistant / data screens with seeded data → test-results/shots/44import { chromium } from "@playwright/test"; import fs from "node:fs";45const w = Number(process.argv[2] ?? 360); fs.mkdirSync("test-results/shots", { recursive: true }); const O = "http://localhost:8481";46const b = await chromium.launch(); const ctx = await b.newContext({ baseURL: O, storageState: "test-results/.auth/state.json", viewport: { width: w, height: 740 }, hasTouch: true, isMobile: true, 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, 200)); });48const post = async (u, d) => { const r = await p.request.post(u, { data: d, headers: { origin: O } }); return { s: r.status(), j: await r.json().catch(() => null) }; };49const shot = async (name) => { await p.waitForTimeout(900); 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, (o.dw > o.cw + 1 || (o.mw ?? 0) > (o.mc ?? 0) + 1) ? "OVERFLOW " + JSON.stringify(o) : "ok"); };50await p.goto("/");51let tree = await (await p.request.get("/api/tree")).json(); let dbp = tree.find((n) => n.type === "database" && n.title === "E2E Tasks DB");52if (!dbp) { const c = await post("/api/pages", { title: "E2E Tasks DB", type: "database", section: "databases" }); dbp = c.j; const t = await post(`/api/databases/${dbp.id}/apply-template`, { template: process.argv[3] ?? "tasks" }); console.log("template", t.s, JSON.stringify(t.j).slice(0, 200)); for (const title of ["Write the report with a rather long title that must wrap properly", "Call the notary", "Review chapter 3"]) { const r = await post(`/api/databases/${dbp.id}/rows`, { title }); if (r.s >= 300) console.log("row", r.s, JSON.stringify(r.j)); } }53await p.goto(`/p/${dbp.id}`); await shot("db-default");54const tabs = await p.getByRole("tab").allTextContents(); console.log("tabs:", tabs.join(" | "));55for (const t of tabs.slice(0, 7)) { try { await p.getByRole("tab", { name: t, exact: true }).first().click({ timeout: 3000 }); await shot("db-" + t.toLowerCase().replace(/[^a-z]/g, "")); } catch (e) { console.log("tab fail", t); } }56console.log("buttons:", (await p.locator("main button").evaluateAll((els) => els.map((e) => e.getAttribute("aria-label") || e.textContent?.trim().slice(0, 24)).filter(Boolean))).slice(0, 40).join(" | "));57for (const r of ["ai/agents", "settings#data", "research"]) { await p.goto("/" + r); await shot(r.replace(/[^a-z]/g, "-")); }58await p.goto("/"); await p.getByRole("button", { name: "AI assistant" }).click(); await shot("ai-panel");59console.log(errs.slice(0, 10).join("\n")); await b.close();60