@@ -89,8 +89,52 @@ describe('metrics effects', () => {
89
89
selectors . getMetricsTooltipSort ,
90
90
TooltipSort . ALPHABETICAL
91
91
) ;
92
+
93
+ overrideTagMetadata ( ) ;
94
+ overrideRunToEid ( ) ;
92
95
} ) ;
93
96
97
+ function overrideTagMetadata ( ) {
98
+ store . overrideSelector ( selectors . getMetricsTagMetadata , {
99
+ scalars : {
100
+ tagDescriptions : { } as any ,
101
+ tagToRuns : {
102
+ tagA : [ 'run1' ] ,
103
+ tagB : [ 'run2' , 'run3' ] ,
104
+ tagC : [ 'run4' , 'run5' ] ,
105
+ tagD : [ 'run6' ] ,
106
+ } ,
107
+ } ,
108
+ histograms : {
109
+ tagDescriptions : { } as any ,
110
+ tagToRuns : {
111
+ tagA : [ 'run1' ] ,
112
+ tagB : [ 'run4' ] ,
113
+ } ,
114
+ } ,
115
+ images : {
116
+ tagDescriptions : { } ,
117
+ tagRunSampledInfo : {
118
+ tagC : {
119
+ 'defaultExperimentId/run1' : { } as any ,
120
+ 'exp1/run3' : { } as any ,
121
+ } ,
122
+ } ,
123
+ } ,
124
+ } ) ;
125
+ }
126
+
127
+ function overrideRunToEid ( ) {
128
+ store . overrideSelector ( selectors . getRunIdToExperimentId , {
129
+ run1 : 'exp1' ,
130
+ run2 : 'exp1' ,
131
+ run3 : 'exp2' ,
132
+ run4 : 'defaultExperimentId' ,
133
+ run5 : 'defaultExperimentId' ,
134
+ run6 : 'defaultExperimentId' ,
135
+ } ) ;
136
+ }
137
+
94
138
afterEach ( ( ) => {
95
139
store ?. resetSelectors ( ) ;
96
140
} ) ;
@@ -365,35 +409,25 @@ describe('metrics effects', () => {
365
409
actions$ . next ( reloadAction ( ) ) ;
366
410
367
411
expect ( fetchTagMetadataSpy ) . toHaveBeenCalled ( ) ;
368
- expect ( fetchTimeSeriesSpy ) . toHaveBeenCalledTimes ( 2 ) ;
412
+ expect ( fetchTimeSeriesSpy ) . toHaveBeenCalledTimes ( 1 ) ;
369
413
expect ( actualActions ) . toEqual ( [
370
414
actions . metricsTagMetadataRequested ( ) ,
371
415
actions . metricsTagMetadataLoaded ( {
372
416
tagMetadata : buildDataSourceTagMetadata ( ) ,
373
417
} ) ,
374
418
375
- // Currently we expect 2x the same requests if the cards are the same.
376
- // Ideally we should dedupe requests for the same info.
377
419
actions . multipleTimeSeriesRequested ( {
378
420
requests : [
379
421
{
380
422
plugin : PluginType . SCALARS as MultiRunPluginType ,
381
423
tag : 'tagA' ,
382
424
experimentIds : [ 'exp1' ] ,
383
425
} ,
384
- {
385
- plugin : PluginType . SCALARS as MultiRunPluginType ,
386
- tag : 'tagA' ,
387
- experimentIds : [ 'exp1' ] ,
388
- } ,
389
426
] ,
390
427
} ) ,
391
428
actions . fetchTimeSeriesLoaded ( {
392
429
response : buildTimeSeriesResponse ( ) ,
393
430
} ) ,
394
- actions . fetchTimeSeriesLoaded ( {
395
- response : buildTimeSeriesResponse ( ) ,
396
- } ) ,
397
431
] ) ;
398
432
} ) ;
399
433
@@ -487,6 +521,8 @@ describe('metrics effects', () => {
487
521
it ( 'does not re-fetch time series, until a valid experiment id' , ( ) => {
488
522
// Reset any `getExperimentIdsFromRoute` overrides above.
489
523
store . resetSelectors ( ) ;
524
+ overrideTagMetadata ( ) ;
525
+ overrideRunToEid ( ) ;
490
526
store . overrideSelector ( getActivePlugin , METRICS_PLUGIN_ID ) ;
491
527
store . overrideSelector (
492
528
selectors . getVisibleCardIdSet ,
@@ -510,6 +546,43 @@ describe('metrics effects', () => {
510
546
511
547
expect ( fetchTimeSeriesSpy ) . toHaveBeenCalledTimes ( 2 ) ;
512
548
} ) ;
549
+
550
+ it ( 'does not send requests to experiments lacking a cards tag' , ( ) => {
551
+ store . overrideSelector ( getActivePlugin , METRICS_PLUGIN_ID ) ;
552
+ store . overrideSelector ( selectors . getExperimentIdsFromRoute , [
553
+ 'exp1' ,
554
+ 'exp2' ,
555
+ ] ) ;
556
+ store . overrideSelector (
557
+ selectors . getVisibleCardIdSet ,
558
+ new Set ( [ 'card1' , 'card2' ] )
559
+ ) ;
560
+ provideCardFetchInfo ( [
561
+ { id : 'card1' , tag : 'tagA' } ,
562
+ { id : 'card2' , tag : 'tagB' } ,
563
+ ] ) ;
564
+ store . refreshState ( ) ;
565
+
566
+ const effectFetchTimeSeriesSpy = spyOn (
567
+ effects as any ,
568
+ 'fetchTimeSeries'
569
+ ) . and . stub ( ) ;
570
+
571
+ actions$ . next ( coreActions . manualReload ( ) ) ;
572
+
573
+ expect ( effectFetchTimeSeriesSpy ) . toHaveBeenCalledTimes ( 2 ) ;
574
+ expect ( effectFetchTimeSeriesSpy ) . toHaveBeenCalledWith ( {
575
+ plugin : 'scalars' ,
576
+ tag : 'tagA' ,
577
+ experimentIds : [ 'exp1' ] ,
578
+ } ) ;
579
+
580
+ expect ( effectFetchTimeSeriesSpy ) . toHaveBeenCalledWith ( {
581
+ plugin : 'scalars' ,
582
+ tag : 'tagB' ,
583
+ experimentIds : [ 'exp1' , 'exp2' ] ,
584
+ } ) ;
585
+ } ) ;
513
586
} ) ;
514
587
515
588
describe ( 'loadTimeSeriesForVisibleCardsWithoutData' , ( ) => {
@@ -778,4 +851,24 @@ describe('metrics effects', () => {
778
851
}
779
852
} ) ;
780
853
} ) ;
854
+
855
+ describe ( '#utilities' , ( ) => {
856
+ describe ( 'parseRunIdFromSampledRunInfoName' , ( ) => {
857
+ it ( 'removes prefixed experiment id' , ( ) => {
858
+ expect (
859
+ TEST_ONLY . parseRunIdFromSampledRunInfoName ( 'experimentId/someRun' )
860
+ ) . toEqual ( 'someRun' ) ;
861
+ } ) ;
862
+
863
+ it ( 'preserves "/" characters in run names' , ( ) => {
864
+ expect (
865
+ TEST_ONLY . parseRunIdFromSampledRunInfoName ( 'experimentId/some/run' )
866
+ ) . toEqual ( 'some/run' ) ;
867
+ } ) ;
868
+
869
+ it ( 'returns an empty string when an empty string is provided' , ( ) => {
870
+ expect ( TEST_ONLY . parseRunIdFromSampledRunInfoName ( '' ) ) . toEqual ( '' ) ;
871
+ } ) ;
872
+ } ) ;
873
+ } ) ;
781
874
} ) ;
0 commit comments