11import { describe , it , expect } from 'vitest' ;
22
3+ /** Resolve an I18nLabel (string or { key, defaultValue }) to a plain string for test assertions */
4+ function resolveTitle ( title : string | { key : string ; defaultValue ?: string } | undefined ) : string {
5+ if ( ! title ) return '' ;
6+ if ( typeof title === 'string' ) return title ;
7+ return title . defaultValue || title . key ;
8+ }
9+
310// --- Metadata imports ---
411import { AccountObject } from '../objects/account.object' ;
512import { ContactObject } from '../objects/contact.object' ;
@@ -235,7 +242,7 @@ describe('CRM Metadata Spec Compliance', () => {
235242 } ) ;
236243
237244 it ( 'all widgets have unique title' , ( ) => {
238- const titles = CrmDashboard . widgets . map ( ( w ) => w . title ) ;
245+ const titles = CrmDashboard . widgets . map ( ( w ) => resolveTitle ( w . title ) ) ;
239246 for ( const title of titles ) {
240247 expect ( typeof title ) . toBe ( 'string' ) ;
241248 expect ( title ! . length ) . toBeGreaterThan ( 0 ) ;
@@ -245,16 +252,17 @@ describe('CRM Metadata Spec Compliance', () => {
245252
246253 it ( 'all widgets have title' , ( ) => {
247254 for ( const widget of CrmDashboard . widgets ) {
248- expect ( typeof widget . title ) . toBe ( 'string' ) ;
249- expect ( widget . title ! . length ) . toBeGreaterThan ( 0 ) ;
255+ const title = resolveTitle ( widget . title ) ;
256+ expect ( typeof title ) . toBe ( 'string' ) ;
257+ expect ( title ! . length ) . toBeGreaterThan ( 0 ) ;
250258 }
251259 } ) ;
252260
253261 it ( 'metric widgets have title matching options.label' , ( ) => {
254262 const metrics = CrmDashboard . widgets . filter ( ( w ) => w . type === 'metric' ) ;
255263 for ( const widget of metrics ) {
256264 const opts = widget . options as { label ?: string } ;
257- expect ( widget . title ) . toBe ( opts . label ) ;
265+ expect ( resolveTitle ( widget . title ) ) . toBe ( opts . label ) ;
258266 }
259267 } ) ;
260268
0 commit comments