SPB Git

Repository Public

shots.part.ts 11.8 KB 197 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : SP Mail8 * File             : tests/e2e/next-prod/shots.part.ts9 * Module           : tests10 * Repository       : https://git.spboucher.ai/sp-mail11 * Project Website  : https://mail.spboucher.ai12 * Created          : 2026-11-2013 * Last Modified    : 2026-11-2014 *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: support@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// SP Mail Next — captures de la version fusionnée (clair et minuit à l'ordinateur, téléphone) : réception avec libellés et épingles, lecteur44// avec volet d'IA, rédaction avec barre de mise en forme et assistant, centre de commande, recherche, contacts, pièces jointes, santé.45// Zone de développement seulement (projet « next-dev ») : elle ne juge rien, elle produit /tmp/spmail-next-shots/web-final/*.png.46import { expect, test, type Page } from "@playwright/test"47import fs from "node:fs"48import type { Part } from "./harness"4950const DIR = "/tmp/spmail-next-shots/web-final"5152export const shotsPart: Part = (h) => {53  const subj = (x: string) => `${x} ${h().run}`54  const shot = async (p: Page, name: string) => void (await p.screenshot({ path: `${DIR}/${name}.png` }))55  /** Chaque écran : clair et minuit à l'ordinateur. */56  const both = async (p: Page, name: string) => {57    // la palette s'ouvre hors de la rédaction (dans l'éditeur, Ctrl+K pose un lien)58    const outside = () => p.locator("#sidebar a").first().focus({ timeout: 1500 }).catch(() => {})59    await outside()60    await h().setTheme(p, "Minuit", "midnight")61    await p.mouse.move(700, 500)62    await shot(p, `${name}-midnight`)63    await outside()64    await h().setTheme(p, "Clair", "light")65    await p.mouse.move(700, 500)66    await shot(p, `${name}-light`)67  }68  const openThread = async (p: Page, text: string) => {69    await p.locator("#message-list [role=option]").filter({ hasText: text }).first().click()70    await expect(p.locator(".reader-subject")).toContainText(text)71  }7273  test("captures : semis (libellés, épingles, pièces jointes, contacts, IA locale)", async () => {74    const { page, P1, P2 } = h()75    fs.mkdirSync(DIR, { recursive: true })76    const mk = async (name: string, color: string) => (await h().api<{ keyword: string }>(page, "POST", "/api/next/labels", { name, color })).keyword77    const [client, urgent, perso] = [await mk("Clients", "#2f6f5e"), await mk("Urgent", "#b3261e"), await mk("Personnel", "#7a3fa0")]78    await h().seed(page, P1, [79      { subject: subj("Budget du trimestre"), from: ["Camille Roy", "camille.roy@example.org"], preview: "Bonjour, peux-tu me confirmer le budget du troisième trimestre avant jeudi ? Il me manque la ligne des déplacements et le total révisé.", keywords: ["$pinned", client, urgent], minutesAgo: 4 },80      { subject: subj("Contrat de service — version signée"), from: ["Étude Lavoie", "greffe@lavoie-notaires.example"], preview: "Vous trouverez ci-joint la version signée du contrat, ainsi que l'annexe tarifaire.", keywords: [client, "$seen"], minutesAgo: 22, attachments: [{ name: "contrat-signe.pdf", type: "application/pdf", text: "%PDF-1.4 essai" }, { name: "annexe-tarifs.csv", type: "text/csv", text: "poste;montant\nconseil;1200\n" }] },81      { subject: subj("Photos du chantier"), from: ["Denis Morin", "denis.morin@example.com"], preview: "Les photos de la semaine sont jointes. La dalle est coulée, on attaque la charpente lundi.", keywords: ["$pinned", "$flagged"], minutesAgo: 51, attachments: [{ name: "notes-chantier.txt", type: "text/plain", text: "Dalle coulée le 18. Charpente lundi." }] },82      { subject: subj("Souper samedi ?"), from: ["Julie Tremblay", "julie.t@example.net"], preview: "On se fait un souper samedi ? J'apporte le dessert.", keywords: [perso], minutesAgo: 95 },83      { subject: subj("Infolettre de novembre"), from: ["Le Bulletin", "bulletin@example.org"], preview: "Les nouvelles du mois : trois articles à lire.", keywords: ["$seen"], minutesAgo: 160, headers: { "List-Id": "<bulletin.example.org>" } },84      { subject: subj("Facture 2026-114"), from: ["Hydro Estrie", "factures@hydro-estrie.example"], preview: "Votre facture du mois de novembre est disponible. Montant : 84,12 $.", keywords: ["$seen", urgent], minutesAgo: 240 },85    ])86    await h().seed(page, P2, [{ subject: subj("Réunion d'équipe"), from: ["Prod Un", P1], preview: "Ordre du jour de la réunion de lundi.", minutesAgo: 30 }])87    for (const [name, email, org] of [["Camille Roy", "camille.roy@example.org", "Atelier Roy"], ["Denis Morin", "denis.morin@example.com", "Construction Morin"], ["Julie Tremblay", "julie.t@example.net", ""]]) await h().api(page, "POST", "/api/next/contacts", { name, emails: [{ email, label: "work" }], ...(org ? { organization: org } : {}), favorite: name === "Camille Roy" })88    await h().api(page, "PUT", "/api/next/ai/settings", { provider: "local", features: { summary: true, reply: true, write: true, triage: true } })89  })9091  test("captures : ordinateur, clair et minuit", async () => {92    test.setTimeout(240_000)93    const { page, P1 } = h()94    await page.goto("/")95    await h().openBox(page, P1)96    await expect(page.locator("#message-list .label-dot").first()).toBeVisible()97    await both(page, "inbox-labels-pins")98    // lecteur + volet d'IA (résumé et suggestions)99    await openThread(page, subj("Budget du trimestre"))100    await page.getByRole("button", { name: "Résumer" }).click()101    await expect(page.getByRole("region", { name: "Résumé de la conversation" }).locator(".nx-ai-text").first()).toBeVisible()102    await both(page, "reader-ai")103    // rédaction : barre de mise en forme + assistant d'écriture (aperçu avant remplacement)104    await page.getByRole("button", { name: "Suggestions de réponse" }).click()105    await page.getByRole("button", { name: "Utiliser la suggestion 1 dans la rédaction" }).click()106    const composer = page.locator("section.composer")107    await expect(composer).toBeVisible()108    await both(page, "composer-toolbar")109    await composer.locator('[data-nx-ai="write"]').getByRole("button", { name: "Assistant" }).click()110    const dlg = page.getByRole("dialog", { name: "Assistant d'écriture" })111    await shot(page, "composer-assistant-menu-light")112    await dlg.getByRole("button", { name: "Améliorer" }).click()113    await expect(dlg.locator(".nx-ai-preview .nx-ai-text")).toBeVisible()114    await shot(page, "composer-assistant-preview-light")115    await page.keyboard.press("Escape")116    await page.locator("#sidebar a").first().focus()117    await h().setTheme(page, "Minuit", "midnight")118    await composer.locator('[data-nx-ai="write"]').getByRole("button", { name: "Assistant" }).click()119    await dlg.getByRole("button", { name: "Améliorer" }).click()120    await expect(dlg.locator(".nx-ai-preview .nx-ai-text")).toBeVisible()121    await shot(page, "composer-assistant-preview-midnight")122    await page.keyboard.press("Escape")123    await page.locator("#sidebar a").first().focus()124    await h().setTheme(page, "Clair", "light")125    await composer.getByRole("button", { name: "Supprimer le brouillon" }).click()126    await page.getByRole("alertdialog").getByRole("button", { name: "Supprimer le brouillon" }).click()127    // centre de commande128    await page.goto("/dashboard")129    await expect(page.locator(".nx-dash-grid")).toHaveAttribute("aria-busy", "false")130    await both(page, "command-center")131    // recherche132    await page.goto("/")133    await h().openBox(page, P1)134    await page.locator("#search-input").fill(`${h().run} has:attachment`)135    await page.locator("#search-input").press("Enter")136    await expect(page.locator("#list-pane [role=option]").first()).toBeVisible()137    await both(page, "search")138    // contacts139    await page.goto("/contacts")140    await expect(page.getByRole("heading", { level: 1, name: "Contacts" })).toBeVisible()141    await page.getByRole("list", { name: "Liste des contacts" }).getByText("Camille Roy").first().click()142    await both(page, "contacts")143    // pièces jointes144    await page.goto("/attachments")145    await expect(page.getByRole("heading", { level: 1, name: "Pièces jointes" })).toBeVisible()146    await expect(page.getByText("contrat-signe.pdf").first()).toBeVisible({ timeout: 30_000 })147    await both(page, "attachments")148    // administration : santé149    await page.goto("/admin/health")150    await expect(page.getByRole("heading", { level: 1 }).first()).toBeVisible()151    await page.waitForTimeout(2500)152    await both(page, "admin-health")153  })154155  test("captures : téléphone", async () => {156    test.setTimeout(180_000)157    const { P1 } = h()158    const { ctx, p } = await h().fromStorage({ width: 390, height: 844 }, true)159    try {160      await p.goto("/")161      await expect(p.locator("#message-list [role=option]").first()).toBeVisible()162      await shot(p, "phone-inbox")163      await p.locator("#message-list [role=option]").filter({ hasText: subj("Budget du trimestre") }).first().click()164      await expect(p.locator(".reader-subject")).toContainText("Budget du trimestre")165      await p.getByRole("button", { name: "Résumer" }).click()166      await expect(p.getByRole("region", { name: "Résumé de la conversation" }).locator(".nx-ai-text").first()).toBeVisible()167      await shot(p, "phone-reader-ai")168      await p.getByRole("button", { name: "Suggestions de réponse" }).click()169      await p.getByRole("button", { name: "Utiliser la suggestion 1 dans la rédaction" }).click()170      await expect(p.locator("section.composer")).toBeVisible()171      await shot(p, "phone-composer")172      await p.locator('section.composer [data-nx-ai="write"]').getByRole("button", { name: "Assistant" }).click()173      await shot(p, "phone-composer-assistant")174      await p.keyboard.press("Escape")175      await p.locator("section.composer").getByRole("button", { name: "Supprimer le brouillon" }).click()176      await p.getByRole("alertdialog").getByRole("button", { name: "Supprimer le brouillon" }).click()177      for (const [route, name, heading] of [["/dashboard", "phone-command-center", "Centre de commande"], ["/contacts", "phone-contacts", "Contacts"], ["/attachments", "phone-attachments", "Pièces jointes"]] as const) {178        await p.goto(route)179        await expect(p.getByRole("heading", { level: 1, name: heading })).toBeVisible()180        await p.waitForTimeout(1200)181        await shot(p, name)182      }183      await p.goto("/")184      await p.locator("#search-input").fill(`${h().run} has:attachment`)185      await p.locator("#search-input").press("Enter")186      await expect(p.locator("#list-pane [role=option]").first()).toBeVisible()187      await shot(p, "phone-search")188      await p.goto("/admin/health")189      await p.waitForTimeout(2500)190      await shot(p, "phone-admin-health")191      void P1192    } finally {193      await ctx.close()194    }195  })196}197
Files main
Menu

Theme