@@ -8,20 +8,16 @@ import { describe, expect, it } from "vitest";
88const blocksDir = resolve ( dirname ( fileURLToPath ( import . meta. url ) ) , "../../../../registry/blocks" ) ;
99
1010interface RegistryManifest {
11+ name : string ;
12+ tags ?: string [ ] ;
1113 files : Array < { path : string ; target : string ; type : string } > ;
1214}
1315
14- const promotedTemplateIds = [
15- "notification-cascade" ,
16- "share-sheet-carousel" ,
17- "ai-chat-reveal" ,
18- "message-thread-reveal" ,
19- "notes-reveal" ,
20- "chatgpt-exchange" ,
21- "claude-exchange" ,
22- "heygen-avatar-promo-card" ,
23- "slack-notification-ad" ,
24- ] as const ;
16+ const promotedTemplateTag = "ad-template" ;
17+
18+ function loadRegistryManifest ( itemDir : string ) : RegistryManifest {
19+ return JSON . parse ( readFileSync ( join ( itemDir , "registry-item.json" ) , "utf8" ) ) as RegistryManifest ;
20+ }
2521
2622function findMissingLocalScripts ( itemDir : string , manifest : RegistryManifest ) : string [ ] {
2723 const manifestPaths = new Set ( manifest . files . map ( ( file ) => file . path ) ) ;
@@ -45,11 +41,17 @@ function findMissingLocalScripts(itemDir: string, manifest: RegistryManifest): s
4541
4642describe ( "registry blocks" , ( ) => {
4743 it ( "ships an editing contract and declared variables for every promoted template" , ( ) => {
48- for ( const templateId of promotedTemplateIds ) {
49- const itemDir = join ( blocksDir , templateId ) ;
50- const manifest = JSON . parse (
51- readFileSync ( join ( itemDir , "registry-item.json" ) , "utf8" ) ,
52- ) as RegistryManifest ;
44+ const promotedManifests = readdirSync ( blocksDir , { withFileTypes : true } )
45+ . filter ( ( entry ) => entry . isDirectory ( ) )
46+ . map ( ( entry ) => ( {
47+ itemDir : join ( blocksDir , entry . name ) ,
48+ manifest : loadRegistryManifest ( join ( blocksDir , entry . name ) ) ,
49+ } ) )
50+ . filter ( ( { manifest } ) => manifest . tags ?. includes ( promotedTemplateTag ) ) ;
51+
52+ expect ( promotedManifests . length ) . toBeGreaterThan ( 0 ) ;
53+ for ( const { itemDir, manifest } of promotedManifests ) {
54+ const templateId = manifest . name ;
5355 const contractFiles = manifest . files . filter (
5456 ( file ) =>
5557 file . path === "TEMPLATE.md" &&
@@ -76,9 +78,7 @@ describe("registry blocks", () => {
7678 if ( ! entry . isDirectory ( ) ) continue ;
7779
7880 const itemDir = join ( blocksDir , entry . name ) ;
79- const manifest = JSON . parse (
80- readFileSync ( join ( itemDir , "registry-item.json" ) , "utf8" ) ,
81- ) as RegistryManifest ;
81+ const manifest = loadRegistryManifest ( itemDir ) ;
8282
8383 for ( const src of findMissingLocalScripts ( itemDir , manifest ) ) {
8484 missing . push ( `${ entry . name } : ${ src } ` ) ;
0 commit comments