diff --git a/extension/src/repository/decorationProvider.ts b/extension/src/repository/decorationProvider.ts index 3e42be857d..02cc4b43d4 100644 --- a/extension/src/repository/decorationProvider.ts +++ b/extension/src/repository/decorationProvider.ts @@ -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 = { diff --git a/extension/src/test/e2e/extension.test.ts b/extension/src/test/e2e/extension.test.ts index 585f225b02..008794a235 100644 --- a/extension/src/test/e2e/extension.test.ts +++ b/extension/src/test/e2e/extension.test.ts @@ -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' @@ -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() + ) + }) + }) }) diff --git a/extension/src/test/e2e/util.ts b/extension/src/test/e2e/util.ts index d6c66b3ed6..f47c1d305d 100644 --- a/extension/src/test/e2e/util.ts +++ b/extension/src/test/e2e/util.ts @@ -1,9 +1,24 @@ -import { ChainablePromiseArray, ElementArray } from 'webdriverio' +import { + ChainablePromiseArray, + ChainablePromiseElement, + ElementArray +} from 'webdriverio' import { ViewControl } from 'wdio-vscode-service' const findProgressBars = (): ChainablePromiseArray => $$('.monaco-progress-container') +const findCurrentTreeItems = (): ChainablePromiseArray => + $$('div[role="treeitem"]') + +export const getLabel = (element: WebdriverIO.Element): Promise => + element.getAttribute('aria-label') + +export const findDecorationTooltip = ( + element: WebdriverIO.Element +): ChainablePromiseElement => + element.$('div[title*="• DVC modified"]') + export const dismissAllNotifications = async (): Promise => { await browser.waitUntil(async () => { const workbench = await browser.getWorkbench() @@ -96,3 +111,13 @@ export const closeAllEditors = async (): Promise => { 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() +}