Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Aug 10, 2022
1 parent bccb815 commit c409bb0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
48 changes: 48 additions & 0 deletions extension/src/test/suite/experiments/model/filterBy/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,5 +465,53 @@ suite('Experiments Filter By Tree Test Suite', () => {

expect(mockTreeView.description).to.be.undefined
})

it('should be able to filter to starred experiments', async () => {
const { experiments, messageSpy } = buildExperiments(disposable)

await experiments.isReady()
await experiments.showWebview()

stub(WorkspaceExperiments.prototype, 'getRepository').returns(experiments)
stub(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(WorkspaceExperiments as any).prototype,
'getFocusedOrOnlyOrPickProject'
).returns(dvcDemoPath)

const starredFilter = {
operator: Operator.IS_TRUE,
path: 'starred',
value: undefined
}

await addFilterViaQuickInput(experiments, starredFilter)

const [workspace, main] = rowsFixture

const filteredRows = [
workspace,
{
...main,
subRows: []
}
]

const filteredTableData: TableData = {
changes: workspaceChangesFixture,
columnOrder: [],
columnWidths: {},
columns: columnsFixture,
filteredCounts: { checkpoints: 9, experiments: 5 },
filters: ['starred'],
hasCheckpoints: true,
hasColumns: true,
hasRunningExperiment: true,
rows: filteredRows,
sorts: []
}

expect(messageSpy).to.be.calledWith(filteredTableData)
}).timeout(WEBVIEW_TEST_TIMEOUT)
})
})
3 changes: 2 additions & 1 deletion extension/src/test/suite/experiments/model/filterBy/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { FilterDefinition } from '../../../../../experiments/model/filterBy'
import { experimentsUpdatedEvent } from '../../../util'
import { Experiments } from '../../../../../experiments'
import { RegisteredCommands } from '../../../../../commands/external'
import { addStarredToColumns } from '../../../../../experiments/columns/like'

export const mockQuickInputFilter = (
fixtureFilter: FilterDefinition,
mockShowQuickPick = stub(window, 'showQuickPick'),
mockShowInputBox = stub(window, 'showInputBox')
) => {
const column = columnsFixture.find(
const column = addStarredToColumns(columnsFixture)?.find(
column => column.path === fixtureFilter.path
)
mockShowQuickPick
Expand Down

0 comments on commit c409bb0

Please sign in to comment.