Skip to content

Commit 50b8243

Browse files
authored
Make deeply nested experiments table test fixture static (#1745)
* make deeply nested experiments table test fixture static * remove collect columns from webview test
1 parent 38fb548 commit 50b8243

File tree

4 files changed

+341
-61
lines changed

4 files changed

+341
-61
lines changed

extension/src/experiments/columns/model.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,27 @@ import { buildMockMemento } from '../../test/util'
44
import { Status } from '../../path/selection/model'
55
import { PersistenceKey } from '../../persistence/constants'
66
import { ColumnType } from '../webview/contract'
7+
import outputFixture from '../../test/fixtures/expShow/output'
8+
import columnsFixture from '../../test/fixtures/expShow/columns'
9+
import {
10+
deeplyNestedOutput,
11+
columns as deeplyNestedColumns
12+
} from '../../test/fixtures/expShow/deeplyNested'
713

814
describe('ColumnsModel', () => {
915
const exampleDvcRoot = 'test'
1016

17+
it('should return columns that equal the columns fixture when given the output fixture', () => {
18+
const model = new ColumnsModel('', buildMockMemento())
19+
model.transformAndSet(outputFixture)
20+
expect(model.getSelected()).toStrictEqual(columnsFixture)
21+
})
22+
23+
it('should return data that equal the deeply nested output fixture', () => {
24+
const model = new ColumnsModel('', buildMockMemento())
25+
model.transformAndSet(deeplyNestedOutput)
26+
expect(model.getSelected()).toStrictEqual(deeplyNestedColumns)
27+
})
1128
describe('persistence', () => {
1229
const paramsDotYamlPath = joinColumnPath(ColumnType.PARAMS, 'params.yaml')
1330
const testParamPath = appendColumnToPath(paramsDotYamlPath, 'testparam')

extension/src/experiments/model/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { copyOriginalColors } from './status/colors'
44
import { Operator } from './filterBy'
55
import outputFixture from '../../test/fixtures/expShow/output'
66
import rowsFixture from '../../test/fixtures/expShow/rows'
7+
import {
8+
deeplyNestedOutput,
9+
rows as deeplyNestedRows
10+
} from '../../test/fixtures/expShow/deeplyNested'
711
import { buildMockMemento } from '../../test/util'
812
import { joinColumnPath } from '../columns/paths'
913
import { Experiment, ColumnType } from '../webview/contract'
@@ -66,6 +70,12 @@ describe('ExperimentsModel', () => {
6670
expect(model.getRowData()).toStrictEqual(rowsFixture)
6771
})
6872

73+
it('should return data that equal the deeply nested output fixture', () => {
74+
const model = new ExperimentsModel('', buildMockMemento())
75+
model.transformAndSet(deeplyNestedOutput)
76+
expect(model.getRowData()).toStrictEqual(deeplyNestedRows)
77+
})
78+
6979
it('should continue to apply filters to new data if selection mode is set to use filters', () => {
7080
const testPath = joinColumnPath(ColumnType.PARAMS, 'params.yaml', 'test')
7181

extension/src/test/fixtures/expShow/deeplyNested.ts

Lines changed: 207 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { ExperimentsOutput } from '../../../cli/reader'
2-
import { collectColumns } from '../../../experiments/columns/collect'
3-
import { collectExperiments } from '../../../experiments/model/collect'
4-
import { copyOriginalColors } from '../../../experiments/model/status/colors'
5-
import { TableData } from '../../../experiments/webview/contract'
2+
import {
3+
Column,
4+
ColumnType,
5+
TableData
6+
} from '../../../experiments/webview/contract'
67

78
export const deeplyNestedOutput: ExperimentsOutput = {
89
workspace: {
@@ -70,13 +71,210 @@ export const deeplyNestedOutput: ExperimentsOutput = {
7071
}
7172
}
7273

73-
export const columns = collectColumns(deeplyNestedOutput)
74+
export const columns: Column[] = [
75+
{
76+
hasChildren: true,
77+
name: 'params.yaml',
78+
parentPath: 'params',
79+
path: 'params:params.yaml',
80+
type: ColumnType.PARAMS
81+
},
82+
{
83+
hasChildren: true,
84+
name: 'nested1',
85+
parentPath: 'params:params.yaml',
86+
path: 'params:params.yaml:nested1',
87+
type: ColumnType.PARAMS
88+
},
89+
{
90+
hasChildren: false,
91+
maxStringLength: 15,
92+
name: 'doubled',
93+
parentPath: 'params:params.yaml:nested1',
94+
path: 'params:params.yaml:nested1.doubled',
95+
pathArray: ['params', 'params.yaml', 'nested1', 'doubled'],
96+
type: ColumnType.PARAMS,
97+
types: ['string']
98+
},
99+
{
100+
hasChildren: true,
101+
name: 'nested1.nested2.nested3.nested4',
102+
parentPath: 'params:params.yaml',
103+
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4',
104+
type: ColumnType.PARAMS
105+
},
106+
{
107+
hasChildren: true,
108+
name: 'nested5',
109+
parentPath: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4',
110+
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5',
111+
type: ColumnType.PARAMS
112+
},
113+
{
114+
hasChildren: true,
115+
name: 'nested6',
116+
parentPath:
117+
'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5',
118+
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5.nested6',
119+
type: ColumnType.PARAMS
120+
},
121+
{
122+
hasChildren: false,
123+
maxStringLength: 6,
124+
name: 'nested7',
125+
parentPath:
126+
'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5.nested6',
127+
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5.nested6.nested7',
128+
pathArray: [
129+
'params',
130+
'params.yaml',
131+
'nested1',
132+
'nested2',
133+
'nested3',
134+
'nested4',
135+
'nested5',
136+
'nested6',
137+
'nested7'
138+
],
139+
type: ColumnType.PARAMS,
140+
types: ['string']
141+
},
142+
{
143+
hasChildren: true,
144+
name: 'nested1.nested2.nested3',
145+
parentPath: 'params:params.yaml',
146+
path: 'params:params.yaml:nested1%2Enested2%2Enested3',
147+
type: ColumnType.PARAMS
148+
},
149+
{
150+
hasChildren: true,
151+
name: 'nested4',
152+
parentPath: 'params:params.yaml:nested1%2Enested2%2Enested3',
153+
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4',
154+
type: ColumnType.PARAMS
155+
},
156+
{
157+
hasChildren: true,
158+
name: 'nested5b',
159+
parentPath: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4',
160+
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b',
161+
type: ColumnType.PARAMS
162+
},
163+
{
164+
hasChildren: false,
165+
maxStringLength: 23,
166+
name: 'nested6',
167+
parentPath:
168+
'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b',
169+
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b.nested6',
170+
pathArray: [
171+
'params',
172+
'params.yaml',
173+
'nested1',
174+
'nested2',
175+
'nested3',
176+
'nested4',
177+
'nested5b',
178+
'nested6'
179+
],
180+
type: ColumnType.PARAMS,
181+
types: ['string']
182+
},
183+
{
184+
hasChildren: false,
185+
maxStringLength: 16,
186+
name: 'doubled',
187+
parentPath:
188+
'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b',
189+
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b.doubled',
190+
pathArray: [
191+
'params',
192+
'params.yaml',
193+
'nested1',
194+
'nested2',
195+
'nested3',
196+
'nested4',
197+
'nested5b',
198+
'doubled'
199+
],
200+
type: ColumnType.PARAMS,
201+
types: ['string']
202+
},
203+
{
204+
hasChildren: false,
205+
maxStringLength: 1,
206+
name: 'outlier',
207+
parentPath: 'params:params.yaml',
208+
path: 'params:params.yaml:outlier',
209+
pathArray: ['params', 'params.yaml', 'outlier'],
210+
type: ColumnType.PARAMS,
211+
types: ['number'],
212+
maxNumber: 1,
213+
minNumber: 1
214+
}
215+
]
74216

75-
const { workspace, branches } = collectExperiments(deeplyNestedOutput)
76-
const colors = copyOriginalColors()
77217
export const rows = [
78-
{ ...workspace, displayColor: colors[0] },
79-
...branches.map((branch, i) => ({ ...branch, displayColor: colors[i + 1] }))
218+
{
219+
id: 'workspace',
220+
label: 'workspace',
221+
timestamp: null,
222+
queued: false,
223+
running: false,
224+
executor: null,
225+
params: {
226+
'params.yaml': {
227+
nested1: {
228+
doubled: 'first instance!',
229+
nested2: {
230+
nested3: {
231+
nested4: {
232+
nested5: { nested6: { nested7: 'Lucky!' } },
233+
nested5b: {
234+
nested6: 'Wow!!!!!!!!!!!!!!!!!!!!',
235+
doubled: 'second instance!'
236+
}
237+
}
238+
}
239+
}
240+
},
241+
outlier: 1
242+
}
243+
},
244+
displayColor: '#945dd6',
245+
selected: true
246+
},
247+
{
248+
id: 'main',
249+
label: 'main',
250+
timestamp: '2020-11-21T19:58:22',
251+
queued: false,
252+
running: false,
253+
executor: null,
254+
name: 'main',
255+
sha: '53c3851f46955fa3e2b8f6e1c52999acc8c9ea77',
256+
params: {
257+
'params.yaml': {
258+
nested1: {
259+
doubled: 'first instance!',
260+
nested2: {
261+
nested3: {
262+
nested4: {
263+
nested5: { nested6: { nested7: 'Lucky!' } },
264+
nested5b: {
265+
nested6: 'Wow!!!!!!!!!!!!!!!!!!!!',
266+
doubled: 'second instance!'
267+
}
268+
}
269+
}
270+
}
271+
},
272+
outlier: 1
273+
}
274+
},
275+
displayColor: '#13adc7',
276+
selected: true
277+
}
80278
]
81279

82280
const deeplyNestedTableData: TableData = {

0 commit comments

Comments
 (0)