From c1b4d8845c1096d4abb39d35832cedff3ea06fb5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Sep 2026 03:05:06 +0000 Subject: [PATCH 1/2] test(scripts): pin the published stylesheet banner per subject (#7044) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Export `defaultHeader` from `scripts/build-plugin-stylesheet.mjs` (previously module-private) and add one per-subject assertion in `plugin-published-stylesheet.test.ts` that the emitted sheet starts with the package's own declared header (`fields`, via `buildOptions.header`) or the shared `defaultHeader(PACKAGE_NAME)` (`plugin-grid`, `plugin-kanban`) when it declares none — reading the expected value from each subject's own build script export, never a second hand-spelled copy. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01BGMDbrVa8JjZcCQ7DWYH1b --- .../plugin-published-stylesheet.test.ts | 20 ++++++++++++++++++- scripts/build-plugin-stylesheet.mjs | 6 +++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/__tests__/plugin-published-stylesheet.test.ts b/scripts/__tests__/plugin-published-stylesheet.test.ts index f3cc151767..b725d576f7 100644 --- a/scripts/__tests__/plugin-published-stylesheet.test.ts +++ b/scripts/__tests__/plugin-published-stylesheet.test.ts @@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url'; import * as gridStylesheet from '../../packages/plugin-grid/scripts/build-css.mjs'; import * as kanbanStylesheet from '../../packages/plugin-kanban/scripts/build-css.mjs'; import * as fieldsStylesheet from '../../packages/fields/scripts/build-css.mjs'; -import { classesOf, COMPONENTS_ENTRY, REPO_ROOT } from '../build-plugin-stylesheet.mjs'; +import { classesOf, COMPONENTS_ENTRY, REPO_ROOT, defaultHeader } from '../build-plugin-stylesheet.mjs'; /** * objectui#4929: `@object-ui/plugin-grid` and `@object-ui/plugin-kanban` now @@ -199,6 +199,24 @@ describe('published supplement stylesheets (objectui#4929, objectui#6438)', () = describe.each(SUBJECTS.map(({ name }) => name))('%s', (name) => { const themed = CARD_THEMED[name]; + /** + * objectui#7044: the emitted sheet's banner is part of the published + * artifact (objectui#6405's acceptance gate was byte-identity of that + * file), yet nothing here read it. The expected value is read from the + * subject's OWN build script export — `mod.buildOptions.header` for the + * package that declares one (`fields`, objectui#4059/#6405), else the + * shared `defaultHeader(mod.PACKAGE_NAME)` this module now exports for + * exactly this — never a second, hand-spelled copy of either wording, + * which would be free to drift from the real one while staying green. + */ + it('opens the emitted sheet with the banner it declares', () => { + const { css } = built.get(name) as Built; + const { mod } = SUBJECTS.find((s) => s.name === name)!; + const declaredHeader = (mod.buildOptions as { header?: string }).header; + const expectedHeader = declaredHeader ?? defaultHeader(mod.PACKAGE_NAME); + expect(css.startsWith(`${expectedHeader}\n`)).toBe(true); + }); + it('emits the themed utilities only this build can produce', () => { const { classes } = built.get(name) as Built; expect(themed.filter((cls) => !classes.has(cls))).toEqual([]); diff --git a/scripts/build-plugin-stylesheet.mjs b/scripts/build-plugin-stylesheet.mjs index 1805f2cf44..a9356572ab 100644 --- a/scripts/build-plugin-stylesheet.mjs +++ b/scripts/build-plugin-stylesheet.mjs @@ -214,8 +214,12 @@ export function indexSheet(rootNode) { * those exact bytes are part of a published artifact (objectui#6405). Wording * that would be an improvement everywhere else is a diff in a published file * there. A package with no such history passes no `header` and inherits this. + * + * Exported (objectui#7044) so `scripts/__tests__/plugin-published-stylesheet.test.ts` + * can pin the emitted banner against the real default instead of a second, + * hand-spelled copy that would be free to drift from it while staying green. */ -function defaultHeader(packageName) { +export function defaultHeader(packageName) { return [ `/*! ${packageName} — utilities this package adds on top of @object-ui/components.`, ' *', From cb38d8a9d0c4e441b1052d42072cbfab5fe250c3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Sep 2026 03:13:18 +0000 Subject: [PATCH 2/2] test(scripts): give the banner pin real teeth against self-consistency (#7044) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original per-subject assertion recomputed "expected" by calling the same function (defaultHeader, or buildOptions.header) that produced "actual" — so it could never be surprised by a mutation to that function's wording; both sides move together. Add two checks that break that symmetry without a second hand-spelled copy of any wording: - the banner must actually name the subject's own package (mod.PACKAGE_NAME, a plain constant each build script declares independently of defaultHeader) — gives the assembly check teeth against a broken interpolation inside defaultHeader for the two packages that inherit it; - fields' emitted sheet must NOT match the shared default banner — the control for the scenario objectui#7044 named directly: an accidental drop of fields' own header override, which the first check alone cannot see because dropping it moves fields' "expected" and "actual" to the shared default in lockstep. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01BGMDbrVa8JjZcCQ7DWYH1b --- .../plugin-published-stylesheet.test.ts | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/scripts/__tests__/plugin-published-stylesheet.test.ts b/scripts/__tests__/plugin-published-stylesheet.test.ts index b725d576f7..2e3463d5ec 100644 --- a/scripts/__tests__/plugin-published-stylesheet.test.ts +++ b/scripts/__tests__/plugin-published-stylesheet.test.ts @@ -202,12 +202,27 @@ describe('published supplement stylesheets (objectui#4929, objectui#6438)', () = /** * objectui#7044: the emitted sheet's banner is part of the published * artifact (objectui#6405's acceptance gate was byte-identity of that - * file), yet nothing here read it. The expected value is read from the - * subject's OWN build script export — `mod.buildOptions.header` for the - * package that declares one (`fields`, objectui#4059/#6405), else the - * shared `defaultHeader(mod.PACKAGE_NAME)` this module now exports for - * exactly this — never a second, hand-spelled copy of either wording, - * which would be free to drift from the real one while staying green. + * file), yet nothing here read it. Two checks, deliberately independent + * of each other, because the obvious single check is vacuous: recomputing + * "expected" by calling the very function that ALSO produced "actual" + * (`defaultHeader`, or fields' own `buildOptions.header`) can never be + * surprised by a mutation to that function's wording — both sides move + * together. Neither check below has that shape: + * + * 1. the emitted sheet starts with the header this subject is + * CONFIGURED to use — its own declared `buildOptions.header` when it + * has one (`fields`, objectui#4059/#6405), else the shared + * `defaultHeader(PACKAGE_NAME)` this module now exports for exactly + * this. Catches the ASSEMBLY breaking (`header` no longer prepended, + * or some third, unrelated value used) — never a second hand-spelled + * copy of either wording, which would be free to drift from the real + * one while staying green. + * 2. that header actually NAMES this package: `mod.PACKAGE_NAME` is a + * plain string constant each build script declares independently + * (never derived from `defaultHeader`), so a broken interpolation + * inside `defaultHeader` cannot hide behind (1)'s self-consistent + * recomputation — this is what gives (1) teeth against a mutation to + * `defaultHeader` itself, for the two subjects that inherit it. */ it('opens the emitted sheet with the banner it declares', () => { const { css } = built.get(name) as Built; @@ -215,8 +230,23 @@ describe('published supplement stylesheets (objectui#4929, objectui#6438)', () = const declaredHeader = (mod.buildOptions as { header?: string }).header; const expectedHeader = declaredHeader ?? defaultHeader(mod.PACKAGE_NAME); expect(css.startsWith(`${expectedHeader}\n`)).toBe(true); + expect(css.slice(0, expectedHeader.length)).toContain(mod.PACKAGE_NAME); }); + // fields-only: the control that (1) above cannot provide, because + // dropping fields' `header` override moves both its "expected" and + // "actual" to the shared default IN LOCKSTEP — exactly the failure mode + // objectui#7044 was filed over ("an accidental drop of fields' per-package + // `header`, would ship silently"). This checks the emitted sheet against + // the OTHER branch's value, independent of whichever branch (1) took. + if (name === 'fields') { + it('does not fall back to the shared default banner', () => { + const { css } = built.get('fields') as Built; + const { mod } = SUBJECTS.find((s) => s.name === 'fields')!; + expect(css.startsWith(`${defaultHeader(mod.PACKAGE_NAME)}\n`)).toBe(false); + }); + } + it('emits the themed utilities only this build can produce', () => { const { classes } = built.get(name) as Built; expect(themed.filter((cls) => !classes.has(cls))).toEqual([]);