/** * The console has to work mounted under a path, and nothing else in it may assume otherwise. * * WHY THIS IS A TEST AND NOT A CODE REVIEW. This has now broken three times, each time differently * and each time silently: * * 1. Four call sites bypassed the api() helper and asked for /v1/… at the root. Mounted under * /browser they hit LeadFlow instead of the console. * 2. A rename from at() to mounted() was done with a regex that only matched at('/v1 — so the * helper itself kept calling at(path). There is ALSO a pointer-event helper called at(), and * being a hoisted function declaration it won. Every API call produced a nonsense URL; the * page still rendered, the first call 404ed, and the login form was left on screen looking * like single sign-on had failed. One missed rename, two symptoms that looked unrelated. * * None of that shows up in a syntax check and none of it shows up until the page is loaded under a * prefix. So this reads the shipped file and asserts the property directly: every request goes * through the one function that knows where the console is mounted. */ import { describe, it, expect } from 'vitest'; import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const pub = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'public'); const HTML = fs.readFileSync(path.join(pub, 'index.html'), 'utf8'); /* The client script now lives in its own file — index.html links it rather than inlining it. Every property asserted below is about that script, so we read it directly. */ const script = fs.readFileSync(path.join(pub, 'js', 'console.js'), 'utf8'); describe('the split console is wired together', () => { it('index.html links the extracted stylesheet and both scripts', () => { expect(HTML).toMatch(//); expect(HTML).toMatch(/