Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/src/repository/decorationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class DecorationProvider
private static DecorationGitModified: FileDecoration = {
badge: 'M',
color: new ThemeColor('gitDecoration.stageModifiedResourceForeground'),
tooltip: 'DVC tracked'
tooltip: 'DVC modified'
}

private static DecorationTracked: FileDecoration = {
Expand Down
48 changes: 48 additions & 0 deletions extension/src/test/e2e/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { join } from 'path'
import { suite, before, describe, it } from 'mocha'
import {
closeAllEditors,
dismissAllNotifications,
findDecorationTooltip,
findScmTreeItems,
getDVCActivityBarIcon,
getLabel,
waitForDvcToFinish,
waitForViewContainerToLoad
} from './util'
Expand Down Expand Up @@ -117,4 +121,48 @@ suite('DVC Extension For Visual Studio Code', () => {
await webview.unfocus()
})
})

// eslint-disable-next-line sonarjs/cognitive-complexity
describe('Source Control View', () => {
it('should show the expected changes after running an experiment', async () => {
const expectedScmItemLabels = [
'demo DVC',
'training_metrics',
'scalars, training_metrics',
`acc.tsv, ${join('training_metrics', 'scalars')}`,
`loss.tsv, ${join('training_metrics', 'scalars')}`
]
const expectedScmSet = new Set(expectedScmItemLabels)
let dvcTreeItemLabels: string[] = []

await browser.waitUntil(
async () => {
dvcTreeItemLabels = []
const treeItems = await findScmTreeItems()
for (const treeItem of treeItems) {
const treeItemLabel = await getLabel(treeItem)
if (!expectedScmSet.has(treeItemLabel)) {
continue
}
dvcTreeItemLabels.push(treeItemLabel)
if (treeItemLabel === 'demo DVC') {
continue
}

const tooltip = await findDecorationTooltip(treeItem)
expect(tooltip).toBeTruthy()
}
return expectedScmItemLabels.length === dvcTreeItemLabels.length
},
{
interval: 5000,
timeout: 60000
}
)

expect(expectedScmItemLabels.sort()).toStrictEqual(
dvcTreeItemLabels.sort()
)
})
})
})
27 changes: 26 additions & 1 deletion extension/src/test/e2e/util.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import { ChainablePromiseArray, ElementArray } from 'webdriverio'
import {
ChainablePromiseArray,
ChainablePromiseElement,
ElementArray
} from 'webdriverio'
import { ViewControl } from 'wdio-vscode-service'

const findProgressBars = (): ChainablePromiseArray<ElementArray> =>
$$('.monaco-progress-container')

const findCurrentTreeItems = (): ChainablePromiseArray<ElementArray> =>
$$('div[role="treeitem"]')

export const getLabel = (element: WebdriverIO.Element): Promise<string> =>
element.getAttribute('aria-label')

export const findDecorationTooltip = (
element: WebdriverIO.Element
): ChainablePromiseElement<WebdriverIO.Element> =>
element.$('div[title*="• DVC modified"]')

export const dismissAllNotifications = async (): Promise<void> => {
await browser.waitUntil(async () => {
const workbench = await browser.getWorkbench()
Expand Down Expand Up @@ -96,3 +111,13 @@ export const closeAllEditors = async (): Promise<void> => {
const editorView = workbench.getEditorView()
return editorView.closeAllEditors()
}

export const findScmTreeItems = async () => {
const workspace = await browser.getWorkbench()
const activityBar = workspace.getActivityBar()
const sourceControlIcon = await activityBar.getViewControl('Source Control')

await sourceControlIcon?.openView()

return findCurrentTreeItems()
}