Skip to content

Commit

Permalink
Clean the file segment of column paths before using them
Browse files Browse the repository at this point in the history
  • Loading branch information
wolmir committed May 31, 2022
1 parent 1e490fd commit f45831d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions extension/src/experiments/columns/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ export const splitColumnPath = (path: string) => {
if (!fileSegment) {
return [baseSegment]
}
const cleanFileSegment = fileSegment.replace(/_\d+$/g, '')
if (!paramPath) {
return [baseSegment, fileSegment]
return [baseSegment, cleanFileSegment]
}
return [
baseSegment,
fileSegment,
cleanFileSegment,
...paramPath.split(METRIC_PARAM_SEPARATOR).map(decodeColumn)
]
}
24 changes: 23 additions & 1 deletion extension/src/test/suite/experiments/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ suite('Experiments Test Suite', () => {
const mockShowTextDocument = stub(window, 'showTextDocument')
const webview = await experiments.showWebview()
const mockMessageReceived = getMessageReceivedEmitter(webview)
const mockColumnId = 'params:params.yaml:lr'
const mockColumnId = 'params:params.yaml_5'

mockMessageReceived.fire({
payload: mockColumnId,
Expand All @@ -413,6 +413,28 @@ suite('Experiments Test Suite', () => {
)
})

it('should be able to handle a message to open different params files than the default one', async () => {
const { experiments } = setupExperimentsAndMockCommands()

const mockShowTextDocument = stub(window, 'showTextDocument')
const webview = await experiments.showWebview()
const mockMessageReceived = getMessageReceivedEmitter(webview)
const mockColumnId = 'params:params_alt.json_5:nested1.nested2'

mockMessageReceived.fire({
payload: mockColumnId,
type: MessageFromWebviewType.OPEN_PARAMS_FILE_TO_THE_SIDE
})

expect(mockShowTextDocument).to.be.calledOnce
expect(mockShowTextDocument).to.be.calledWithExactly(
Uri.file(join(dvcDemoPath, 'params_alt.json')),
{
viewColumn: ViewColumn.Beside
}
)
})

it('should be able to handle a message to apply an experiment to workspace', async () => {
const { experiments, mockExecuteCommand } =
setupExperimentsAndMockCommands()
Expand Down

0 comments on commit f45831d

Please sign in to comment.