Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Note SPBoucher AI8 * File : tests/e2e/live-ai.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// MANUAL, costs a few cents of provider usage: node tests/e2e/live-ai.mjs — asks one grounded question and one that the notes cannot answer.44import { chromium } from "@playwright/test";45const O = "http://localhost:8481"; const b = await chromium.launch(); const ctx = await b.newContext({ baseURL: O, storageState: "test-results/.auth/state.json", viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true, deviceScaleFactor: 2 });46const p = await ctx.newPage(); p.on("pageerror", (e) => console.log("PAGEERROR", e.message.slice(0, 200)));47const ask = async (q, tag) => {48 await p.goto("/"); await p.getByRole("button", { name: "AI assistant" }).click(); await p.waitForTimeout(600);49 const box = p.getByPlaceholder("Ask your notes…").last(); await box.click(); await box.fill(q); await p.waitForTimeout(300); await p.locator("button:has(svg.lucide-send)").last().click();50 await p.waitForTimeout(1500); const anyway = p.getByRole("button", { name: /Send anyway/ }); if (await anyway.count()) await anyway.click();51 for (let i = 0; i < 60; i++) { await p.waitForTimeout(1000); const t = await p.locator('[role="dialog"], aside, main').last().innerText().catch(() => ""); if (/\$0\.\d|No supporting note|insufficient|Retry/i.test(t) && i > 3) break; }52 const panel = await p.evaluate(() => document.body.innerText); const i = panel.lastIndexOf(q.slice(0, 20)); console.log(`--- ${tag}\n` + panel.slice(i, i + 900).replace(/\n{2,}/g, "\n"));53 const links = await p.locator('a[href*="#block-"]').evaluateAll((els) => els.map((e) => e.getAttribute("href"))); console.log("citation links:", links.slice(0, 4)); await p.screenshot({ path: `test-results/shots/live-${tag}.png` });54 return links;55};56const links = await ask("When is the IMM1033 intra and what does the lecture use?", "grounded");57if (links[0]) { await p.goto(links[0]); await p.waitForTimeout(1500); console.log("citation opens:", p.url(), "| block in view:", await p.evaluate((h) => { const el = document.getElementById(h); if (!el) return "missing"; const r = el.getBoundingClientRect(); return r.top >= 0 && r.bottom <= innerHeight ? "yes" : "no"; }, links[0].split("#")[1])); }58await ask("What is the boiling point of tungsten according to my notes?", "ungrounded");59await b.close();60