A calm place to write long-form, and publish it to the open social web. skypress.blog/
0

Configure Feed

Select the types of activity you want to include in your feed.

at trunk 2.0 kB View raw
1/** 2 * Regression guard for the publication-theme injection (Decision 0012). 3 * 4 * The publication-home and article pages inject a `<style>` overriding the design tokens when a 5 * publication has a `basicTheme`. Rendering these `.astro` pages through astro/container isn't 6 * viable here (the runner is pinned to jsdom for the WordPress block suites, which breaks 7 * esbuild's init invariant — see index.phase.test.ts), so these asserts pin the wiring at the 8 * source level: each page must compute `themeStyleBlock(publication.basicTheme)` and inject it, 9 * gated on a truthy result, via `set:html` (the value is app-built CSS, proven injection-safe by 10 * themes.test.ts). A refactor that drops the gate or passes the wrong field ships green without it. 11 * 12 * Lives under src/lib/ (not src/pages/) on purpose: a `.test.ts` inside a `[param]` route dir is 13 * treated by Astro as a prerendered endpoint and breaks the build. 14 */ 15import { readFileSync } from 'node:fs'; 16import { fileURLToPath } from 'node:url'; 17import { describe, expect, it } from 'vitest'; 18 19const read = ( rel: string ) => 20 readFileSync( fileURLToPath( new URL( rel, import.meta.url ) ), 'utf8' ); 21 22describe( 'publication theme injection wiring', () => { 23 for ( const [ label, file ] of [ 24 [ 'publication home', '../../pages/[author]/[slug]/index.astro' ], 25 [ 'article', '../../pages/[author]/[slug]/[rkey].astro' ], 26 ] as const ) { 27 describe( label, () => { 28 const src = read( file ); 29 30 it( 'imports themeStyleBlock from the themes module', () => { 31 expect( src ).toMatch( 32 /import\s*\{\s*themeStyleBlock\s*\}\s*from\s*['"][^'"]*publish\/themes['"]/ 33 ); 34 } ); 35 36 it( 'derives the style block from the publication’s basicTheme', () => { 37 expect( src ).toMatch( /themeStyleBlock\(\s*publication\.basicTheme\s*\)/ ); 38 } ); 39 40 it( 'injects it via set:html, gated on a truthy theme', () => { 41 expect( src ).toMatch( 42 /\{\s*themeStyle\s*&&\s*<Fragment\s+set:html=\{\s*themeStyle\s*\}\s*\/>\s*\}/ 43 ); 44 } ); 45 } ); 46 } 47} );