@@ -10,11 +10,13 @@ import {
1010 mockCatalogPerformanceMetricsArtifact ,
1111 mockCatalogSource ,
1212 mockCatalogSourceList ,
13+ mockDefaultSources ,
14+ mockProviderAndCustomSources ,
15+ mockTwoProviderSources ,
1316} from '~/__mocks__' ;
14- import type { CatalogSource } from '~/app/modelCatalogTypes' ;
1517import { MODEL_CATALOG_API_VERSION } from '~/__tests__/cypress/cypress/support/commands/api' ;
1618import { mockCatalogFilterOptionsList } from '~/__mocks__/mockCatalogFilterOptionsList' ;
17- import { SourceLabel } from '~/app/modelCatalogTypes' ;
19+ import { SourceLabel , type CatalogSource } from '~/app/modelCatalogTypes' ;
1820import { ModelRegistryMetadataType } from '~/app/types' ;
1921
2022type FilteredModelsInterceptConfig = {
@@ -90,7 +92,7 @@ const calculateExpectedCategoryCount = (sources: CatalogSource[]): number => {
9092} ;
9193
9294const initIntercepts = ( {
93- sources = [ mockCatalogSource ( { } ) , mockCatalogSource ( { id : 'source-2' , name : 'source 2' } ) ] ,
95+ sources = mockDefaultSources ( ) ,
9496 modelsPerCategory = 4 ,
9597 hasValidatedModels = false ,
9698 includeAllModelsIntercept = true ,
@@ -269,15 +271,9 @@ describe('Model Catalog Page', () => {
269271 } ) ;
270272
271273 it ( 'checkbox should work' , ( ) => {
272- // Calculate expected category count based on sources
273- const defaultSources = [
274- mockCatalogSource ( { } ) ,
275- mockCatalogSource ( { id : 'source-2' , name : 'source 2' } ) ,
276- ] ;
277-
278- const expectedCategoryCount = calculateExpectedCategoryCount ( defaultSources ) ;
274+ const expectedCategoryCount = calculateExpectedCategoryCount ( mockDefaultSources ( ) ) ;
279275
280- initIntercepts ( { sources : defaultSources , includeAllModelsIntercept : false } ) ;
276+ initIntercepts ( { sources : mockDefaultSources ( ) , includeAllModelsIntercept : false } ) ;
281277
282278 setupFilteredModelsIntercept ( {
283279 returnModelsForFilters : true ,
@@ -322,14 +318,9 @@ describe('Model Catalog Page', () => {
322318 } ) ;
323319
324320 it ( 'tensor type filter combined with other filters should work' , ( ) => {
325- const defaultSources = [
326- mockCatalogSource ( { } ) ,
327- mockCatalogSource ( { id : 'source-2' , name : 'source 2' } ) ,
328- ] ;
321+ const expectedCategoryCount = calculateExpectedCategoryCount ( mockDefaultSources ( ) ) ;
329322
330- const expectedCategoryCount = calculateExpectedCategoryCount ( defaultSources ) ;
331-
332- initIntercepts ( { sources : defaultSources , includeAllModelsIntercept : false } ) ;
323+ initIntercepts ( { sources : mockDefaultSources ( ) , includeAllModelsIntercept : false } ) ;
333324
334325 setupFilteredModelsIntercept ( {
335326 returnModelsForFilters : true ,
@@ -357,10 +348,7 @@ describe('Performance Empty State', () => {
357348 describe ( 'Community & Custom Section' , ( ) => {
358349 it ( 'should show performance empty state when toggle is ON' , ( ) => {
359350 initIntercepts ( {
360- sources : [
361- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
362- mockCatalogSource ( { id : 'custom-source' , name : 'Custom Source' , labels : [ ] } ) ,
363- ] ,
351+ sources : mockProviderAndCustomSources ( ) ,
364352 hasValidatedModels : true ,
365353 } ) ;
366354 setupFilteredModelsIntercept ( { returnModelsForFilters : false } ) ;
@@ -380,10 +368,7 @@ describe('Performance Empty State', () => {
380368
381369 it ( 'should show models when toggle is OFF' , ( ) => {
382370 initIntercepts ( {
383- sources : [
384- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
385- mockCatalogSource ( { id : 'custom-source' , name : 'Custom Source' , labels : [ ] } ) ,
386- ] ,
371+ sources : mockProviderAndCustomSources ( ) ,
387372 } ) ;
388373 modelCatalog . visit ( ) ;
389374
@@ -397,14 +382,7 @@ describe('Performance Empty State', () => {
397382 describe ( 'Labeled Section Without Validated Models' , ( ) => {
398383 it ( 'should show performance empty state when toggle is ON and no validated models' , ( ) => {
399384 initIntercepts ( {
400- sources : [
401- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
402- mockCatalogSource ( {
403- id : 'source-2' ,
404- name : 'Provider Two Source' ,
405- labels : [ 'Provider two' ] ,
406- } ) ,
407- ] ,
385+ sources : mockTwoProviderSources ( ) ,
408386 hasValidatedModels : false ,
409387 } ) ;
410388 // No user filters/search; this scenario should hit the special "No performance data" state.
@@ -421,14 +399,7 @@ describe('Performance Empty State', () => {
421399
422400 it ( 'should show models when toggle is OFF' , ( ) => {
423401 initIntercepts ( {
424- sources : [
425- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
426- mockCatalogSource ( {
427- id : 'source-2' ,
428- name : 'Provider Two Source' ,
429- labels : [ 'Provider two' ] ,
430- } ) ,
431- ] ,
402+ sources : mockTwoProviderSources ( ) ,
432403 hasValidatedModels : false ,
433404 } ) ;
434405 modelCatalog . visit ( ) ;
@@ -442,14 +413,7 @@ describe('Performance Empty State', () => {
442413 describe ( 'Labeled Section With Validated Models' , ( ) => {
443414 it ( 'should show models when toggle is ON and section has validated models' , ( ) => {
444415 initIntercepts ( {
445- sources : [
446- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
447- mockCatalogSource ( {
448- id : 'source-2' ,
449- name : 'Provider Two Source' ,
450- labels : [ 'Provider two' ] ,
451- } ) ,
452- ] ,
416+ sources : mockTwoProviderSources ( ) ,
453417 hasValidatedModels : true ,
454418 } ) ;
455419 modelCatalog . visit ( ) ;
@@ -465,10 +429,7 @@ describe('Performance Empty State', () => {
465429 describe ( 'Empty State Actions' , ( ) => {
466430 it ( 'should turn off toggle when clicking "Turn Model performance view off"' , ( ) => {
467431 initIntercepts ( {
468- sources : [
469- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
470- mockCatalogSource ( { id : 'custom-source' , name : 'Custom Source' , labels : [ ] } ) ,
471- ] ,
432+ sources : mockProviderAndCustomSources ( ) ,
472433 hasValidatedModels : true ,
473434 } ) ;
474435 setupFilteredModelsIntercept ( { returnModelsForFilters : false } ) ;
@@ -486,10 +447,7 @@ describe('Performance Empty State', () => {
486447
487448 it ( 'should navigate to All models when clicking "View all models with performance data"' , ( ) => {
488449 initIntercepts ( {
489- sources : [
490- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
491- mockCatalogSource ( { id : 'custom-source' , name : 'Custom Source' , labels : [ ] } ) ,
492- ] ,
450+ sources : mockProviderAndCustomSources ( ) ,
493451 hasValidatedModels : true ,
494452 } ) ;
495453 setupFilteredModelsIntercept ( { returnModelsForFilters : false } ) ;
@@ -506,14 +464,7 @@ describe('Performance Empty State', () => {
506464
507465 it ( 'should show performance empty state after clicking Reset filters when toggle is ON' , ( ) => {
508466 initIntercepts ( {
509- sources : [
510- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
511- mockCatalogSource ( {
512- id : 'source-2' ,
513- name : 'Provider Two Source' ,
514- labels : [ 'Provider two' ] ,
515- } ) ,
516- ] ,
467+ sources : mockTwoProviderSources ( ) ,
517468 hasValidatedModels : false ,
518469 } ) ;
519470 setupFilteredModelsIntercept ( { returnModelsForFilters : false } ) ;
@@ -536,10 +487,7 @@ describe('Performance Empty State', () => {
536487
537488 it ( 'should work correctly when toggling performance view' , ( ) => {
538489 initIntercepts ( {
539- sources : [
540- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
541- mockCatalogSource ( { id : 'custom-source' , name : 'Custom Source' , labels : [ ] } ) ,
542- ] ,
490+ sources : mockProviderAndCustomSources ( ) ,
543491 hasValidatedModels : true ,
544492 } ) ;
545493 setupFilteredModelsIntercept ( { returnModelsForFilters : false } ) ;
@@ -563,14 +511,7 @@ describe('Performance Empty State', () => {
563511
564512 it ( 'should show "No results found" when toggle is ON and user applies filter that returns 0 results' , ( ) => {
565513 initIntercepts ( {
566- sources : [
567- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
568- mockCatalogSource ( {
569- id : 'source-2' ,
570- name : 'Provider Two Source' ,
571- labels : [ 'Provider two' ] ,
572- } ) ,
573- ] ,
514+ sources : mockTwoProviderSources ( ) ,
574515 hasValidatedModels : true ,
575516 } ) ;
576517 setupFilteredModelsIntercept ( { returnModelsForFilters : false } ) ;
@@ -591,14 +532,7 @@ describe('Performance Empty State', () => {
591532describe ( 'All Models Section' , ( ) => {
592533 it ( 'should show models in All models section even when toggle is ON' , ( ) => {
593534 initIntercepts ( {
594- sources : [
595- mockCatalogSource ( { labels : [ 'Provider one' ] } ) ,
596- mockCatalogSource ( {
597- id : 'source-2' ,
598- name : 'Provider Two Source' ,
599- labels : [ 'Provider two' ] ,
600- } ) ,
601- ] ,
535+ sources : mockTwoProviderSources ( ) ,
602536 hasValidatedModels : true ,
603537 } ) ;
604538 modelCatalog . visit ( ) ;
0 commit comments