11import { PlotsModel } from '.'
22import {
3+ CustomPlotType ,
34 DEFAULT_NB_ITEMS_PER_ROW ,
45 DEFAULT_SECTION_COLLAPSED ,
56 DEFAULT_SECTION_NB_ITEMS_PER_ROW_OR_WIDTH ,
@@ -22,7 +23,7 @@ const mockedRevisions = [
2223describe ( 'plotsModel' , ( ) => {
2324 let model : PlotsModel
2425 const exampleDvcRoot = 'test'
25- const memento = buildMockMemento ( {
26+ let memento = buildMockMemento ( {
2627 [ PersistenceKey . PLOTS_CUSTOM_ORDER + exampleDvcRoot ] :
2728 customPlotsOrderFixture ,
2829 [ PersistenceKey . PLOT_NB_ITEMS_PER_ROW_OR_WIDTH + exampleDvcRoot ] :
@@ -45,6 +46,41 @@ describe('plotsModel', () => {
4546 jest . clearAllMocks ( )
4647 } )
4748
49+ it ( 'should update outdated custom and trends state' , ( ) => {
50+ memento = buildMockMemento ( {
51+ [ PersistenceKey . PLOTS_CUSTOM_ORDER + exampleDvcRoot ] : [
52+ {
53+ metric : 'metrics:summary.json:loss' ,
54+ param : 'params:params.yaml:dropout'
55+ }
56+ ] ,
57+ [ PersistenceKey . PLOT_SELECTED_METRICS + exampleDvcRoot ] : [ 'string' ] ,
58+ [ PersistenceKey . PLOT_METRIC_ORDER + exampleDvcRoot ] : [ 'string' ]
59+ } )
60+ model = new PlotsModel (
61+ exampleDvcRoot ,
62+ {
63+ getFirstThreeColumnOrder : mockedGetFirstThreeColumnOrder ,
64+ getSelectedRevisions : mockedGetSelectedRevisions ,
65+ isReady : ( ) => Promise . resolve ( undefined )
66+ } as unknown as Experiments ,
67+ memento
68+ )
69+ expect ( model . getCustomPlotsOrder ( ) ) . toStrictEqual ( [
70+ {
71+ metric : 'summary.json:loss' ,
72+ param : 'params.yaml:dropout' ,
73+ type : CustomPlotType . METRIC_VS_PARAM
74+ }
75+ ] )
76+ expect (
77+ memento . get ( PersistenceKey . PLOT_SELECTED_METRICS + exampleDvcRoot )
78+ ) . toStrictEqual ( undefined )
79+ expect (
80+ memento . get ( PersistenceKey . PLOT_METRIC_ORDER + exampleDvcRoot )
81+ ) . toStrictEqual ( undefined )
82+ } )
83+
4884 it ( 'should change the plotSize when calling setPlotSize' , ( ) => {
4985 expect (
5086 model . getNbItemsPerRowOrWidth ( PlotsSection . CUSTOM_PLOTS )
0 commit comments