own-list-isolation.test.ts
Language TypeScript3.2 KB81 lines
/*** The private list cannot reach anything shared, because nothing shared can see* it.** Every other guarantee in this feature is a runtime one: a scoping clause, an* ownership check, a per-viewer stamp. This file asserts the structural one,* which is the only kind that holds against a change nobody reviewed carefully:* the modules that build the company surfaces, the history rows and the* briefing payload do not import the list, so there is no code path along which* a line could travel to `/payload.json` (which `seesLeadership` may fetch), to* `briefings.json` (which is pushed), or to `analysis/brief.py` (the one place* a model is called).** The same shape as onboarding-export.test.ts's guard, and for the same reason* recorded there: whoever is next asked to "surface what people are carrying"* will reach for `readOwnList` long before they reach for a comment.*/import { readFile } from 'node:fs/promises'import { fileURLToPath } from 'node:url'import { describe, expect, it } from 'vitest'import { FIXTURE_SNAPSHOT } from '../src/fixtures.js'import { headline } from '../src/collect.js'import { buildViewModel } from '../src/view-model.js'import { buildBriefingPayload } from '../src/briefing-payload.js'import { viewerFor } from '../src/viewer.js'const DAY = '2026-08-12'/** The modules that produce anything a second person can read. */const SHARED = ['collect.ts','view-model.ts','history.ts','briefing-payload.ts','variants.ts',]describe('nothing shared can see the private list', () => {for (const file of SHARED) {it(`${file} does not import it`, async () => {const src = await readFile(fileURLToPath(new URL(`../src/${file}`, import.meta.url)), 'utf8')const imports = [...src.matchAll(/^import[\s\S]*?from '([^']+)'/gm)].map((m) => m[1]!)expect(imports.filter((i) => i.includes('own-list')),`${file} must not import the private list; it feeds a surface other people read`,).toEqual([])})}it('surfaces.ts sees ONLY the placeholder and the grant, never the store', async () => {// It has to see something: it emits the marker. What it must not be able to// reach is anything that returns a line.const src = await readFile(fileURLToPath(new URL('../src/surfaces.ts', import.meta.url)), 'utf8')expect(src).toContain('ownListPlaceholder')expect(src).not.toContain('readOwnList')expect(src).not.toContain('ownListBlock')})it('the briefing payload contains no field belonging to the list', () => {// Asserted on the built payload as well as on the imports, because the// import check would not catch a field copied in by hand.const payload = JSON.stringify(buildBriefingPayload(FIXTURE_SNAPSHOT))for (const marker of ['own_item', 'ownList', 'own-list', 'linkKey', 'doneAt']) {expect(payload).not.toContain(marker)}})it('the view model a viewer’s page is built from has no list on it', () => {const vm = buildViewModel(FIXTURE_SNAPSHOT,headline(FIXTURE_SNAPSHOT),[],DAY,viewerFor('hello@meridiandisplay.example'),)const json = JSON.stringify(vm)expect(json).not.toContain('own_item')expect(json).not.toContain('ownList')})})