@@ -10,6 +10,7 @@ import {
1010 writeJson ,
1111 loadProviderCatalog ,
1212} from "../src/provider-catalog.mjs" ;
13+ import { applyCommittedProviderNames } from "../src/provider-branding.mjs" ;
1314
1415const general = JSON . parse ( fs . readFileSync ( "manifest.json" , "utf8" ) ) ;
1516const vf = JSON . parse ( fs . readFileSync ( "vf/manifest.json" , "utf8" ) ) ;
@@ -25,6 +26,35 @@ const rendered = manifestsFromCatalog(catalog);
2526assert . deepEqual ( rendered . general , general , "general manifest must round-trip byte-semantically through catalog" ) ;
2627assert . deepEqual ( rendered . vf , vf , "VF manifest must round-trip byte-semantically through catalog" ) ;
2728
29+ const brandingIndex = JSON . parse ( fs . readFileSync ( "assets/providers/emojis.json" , "utf8" ) ) ;
30+ const brandingCatalog = applyCommittedProviderNames ( structuredClone ( catalog ) , brandingIndex ) ;
31+ const expectedNameRows = Object . keys ( brandingIndex . providers ?? { } ) . length ;
32+ assert . equal ( brandingCatalog . policy . committedProviderNames , true ) ;
33+ assert . equal (
34+ brandingCatalog . policy . committedProviderNameCount ,
35+ expectedNameRows ,
36+ "catalog must bind every committed provider display name" ,
37+ ) ;
38+ assert . equal ( expectedNameRows , catalog . providers . length , "branding map must cover the complete provider catalog" ) ;
39+ const brandingRendered = manifestsFromCatalog ( brandingCatalog ) ;
40+ for ( const scraper of brandingRendered . general . scrapers ) {
41+ const branding = brandingIndex . providers ?. [ String ( scraper . id ) . toLowerCase ( ) ] ;
42+ assert . ok ( branding , `${ scraper . id } : branding row missing` ) ;
43+ assert . equal ( scraper . name , `${ branding . emoji } ${ branding . name } ` , `${ scraper . id } : general display branding mismatch` ) ;
44+ }
45+ for ( const scraper of brandingRendered . vf . scrapers ) {
46+ const branding = brandingIndex . providers ?. [ String ( scraper . id ) . toLowerCase ( ) ] ;
47+ assert . ok ( branding , `${ scraper . id } : VF branding row missing` ) ;
48+ assert . equal ( scraper . name , `${ branding . emoji } ${ branding . name } ` , `${ scraper . id } : VF display branding mismatch` ) ;
49+ }
50+ const incompleteBranding = structuredClone ( brandingIndex ) ;
51+ delete incompleteBranding . providers [ Object . keys ( incompleteBranding . providers ) [ 0 ] ] ;
52+ assert . throws (
53+ ( ) => applyCommittedProviderNames ( structuredClone ( catalog ) , incompleteBranding ) ,
54+ / c o v e r a g e m i s m a t c h / i,
55+ "catalog must reject incomplete provider branding coverage" ,
56+ ) ;
57+
2858const logoIndex = JSON . parse ( fs . readFileSync ( "assets/providers/index.json" , "utf8" ) ) ;
2959const logoCatalog = applyCommittedProviderLogos ( structuredClone ( catalog ) , logoIndex ) ;
3060const expectedLogoRows = Object . values ( logoIndex . providers ?? { } ) . filter (
@@ -76,5 +106,5 @@ unsafe.policy.repairBeforeTriage = false;
76106assert . throws ( ( ) => validateProviderCatalog ( unsafe ) , / r e p a i r - b e f o r e - t r i a g e / i) ;
77107
78108console . log (
79- `provider catalog tests passed: general=${ general . scrapers . length } vf=${ vf . scrapers . length } committed_logos=${ expectedLogoRows . length } ` ,
109+ `provider catalog tests passed: general=${ general . scrapers . length } vf=${ vf . scrapers . length } committed_names= ${ expectedNameRows } committed_logos=${ expectedLogoRows . length } ` ,
80110) ;
0 commit comments