From 1942cd28ebe0b16283dda3292107f9eea1ed99c9 Mon Sep 17 00:00:00 2001 From: julieg18 Date: Wed, 5 Apr 2023 11:32:36 -0500 Subject: [PATCH 1/3] Add custom plot to e2e test --- extension/src/test/e2e/extension.test.ts | 4 +++- extension/src/test/e2e/util.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/extension/src/test/e2e/extension.test.ts b/extension/src/test/e2e/extension.test.ts index 62c976e6e2..f0dba04389 100644 --- a/extension/src/test/e2e/extension.test.ts +++ b/extension/src/test/e2e/extension.test.ts @@ -1,6 +1,7 @@ import { join } from 'path' import { closeAllEditors, + createCustomPlot, deleteAllExistingExperiments, dismissAllNotifications, findDecorationTooltip, @@ -133,6 +134,7 @@ describe('Plots Webview', function () { it('should load the plots webview with non-empty plots', async function () { this.timeout(60000) const webview = new PlotsWebview('plots') + await createCustomPlot() const workbench = await browser.getWorkbench() await workbench.openCommandPrompt() await browser.keys([...'DVC: Show Plots', 'ArrowDown', 'Enter']) @@ -143,7 +145,7 @@ describe('Plots Webview', function () { await browser.waitUntil( async () => { - return (await webview.vegaVisualization$$.length) === 5 + return (await webview.vegaVisualization$$.length) === 6 }, { timeout: 30000 } ) diff --git a/extension/src/test/e2e/util.ts b/extension/src/test/e2e/util.ts index fa9dd650f0..c67d029100 100644 --- a/extension/src/test/e2e/util.ts +++ b/extension/src/test/e2e/util.ts @@ -153,6 +153,15 @@ export const closeAllEditors = async (): Promise => { return editorView.closeAllEditors() } +export const createCustomPlot = async (): Promise => { + const workbench = await browser.getWorkbench() + const addCustomPlot = await workbench.executeCommand('DVC: Add Custom Plot') + await browser.waitUntil(() => addCustomPlot.elem.isDisplayed()) + await browser.keys('Enter') + await browser.waitUntil(() => addCustomPlot.elem.isDisplayed()) + return browser.keys('Enter') +} + export const findScmTreeItems = async () => { const workspace = await browser.getWorkbench() const activityBar = workspace.getActivityBar() From 695dc11f5d899aa609b442c5e769fec1c763826b Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 6 Apr 2023 20:51:04 -0500 Subject: [PATCH 2/3] Move custom plot logic to separate test --- extension/src/test/e2e/extension.test.ts | 61 ++++++++++++++++++++---- extension/src/test/e2e/util.ts | 24 ++++++++++ 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/extension/src/test/e2e/extension.test.ts b/extension/src/test/e2e/extension.test.ts index f0dba04389..3ef70ccc50 100644 --- a/extension/src/test/e2e/extension.test.ts +++ b/extension/src/test/e2e/extension.test.ts @@ -3,12 +3,14 @@ import { closeAllEditors, createCustomPlot, deleteAllExistingExperiments, + deleteCustomPlot, dismissAllNotifications, findDecorationTooltip, findScmTreeItems, getDVCActivityBarIcon, getLabel, runModifiedExperiment, + waitForAllPlotsToRender, waitForDvcToFinish, waitForViewContainerToLoad } from './util.js' @@ -131,33 +133,74 @@ describe('Experiments Table Webview', function () { }) describe('Plots Webview', function () { + const webview = new PlotsWebview('plots') + it('should load the plots webview with non-empty plots', async function () { this.timeout(60000) - const webview = new PlotsWebview('plots') - await createCustomPlot() const workbench = await browser.getWorkbench() await workbench.openCommandPrompt() await browser.keys([...'DVC: Show Plots', 'ArrowDown', 'Enter']) await waitForDvcToFinish() - await webview.focus() - await browser.waitUntil( - async () => { - return (await webview.vegaVisualization$$.length) === 6 - }, - { timeout: 30000 } - ) + await waitForAllPlotsToRender(webview, 5) const plots = await webview.vegaVisualization$$ + for (const plot of plots) { + const plotNotEmpty = await webview.plotNotEmpty(plot) + expect(plotNotEmpty).toBe(true) + } + await webview.unfocus() + await closeAllEditors() + }) + + it('should create and delete a custom plot', async function () { + this.timeout(60000) + await createCustomPlot() + const workbench = await browser.getWorkbench() + await workbench.openCommandPrompt() + await workbench.executeCommand('DVC: Show Plots') + + await waitForDvcToFinish() + await webview.focus() + + await waitForAllPlotsToRender(webview, 6) + + let plots = await webview.vegaVisualization$$ + for (const plot of plots) { + const plotNotEmpty = await webview.plotNotEmpty(plot) + expect(plotNotEmpty).toBe(true) + } + + await webview.unfocus() + await closeAllEditors() + + await deleteCustomPlot() + await workbench.executeCommand('DVC: Show Plots') + + await waitForDvcToFinish() + await webview.focus() + + await waitForAllPlotsToRender(webview, 5) + + plots = await webview.vegaVisualization$$ for (const plot of plots) { const plotNotEmpty = await webview.plotNotEmpty(plot) expect(plotNotEmpty).toBe(true) } await webview.unfocus() + await closeAllEditors() + }) + + after(async function () { + this.timeout(60000) + try { + await deleteCustomPlot() + } catch {} + await dismissAllNotifications() }) }) diff --git a/extension/src/test/e2e/util.ts b/extension/src/test/e2e/util.ts index c67d029100..ee99f7e4c6 100644 --- a/extension/src/test/e2e/util.ts +++ b/extension/src/test/e2e/util.ts @@ -1,5 +1,6 @@ import { Key } from 'webdriverio' import { ViewControl } from 'wdio-vscode-service' +import { PlotsWebview } from './pageObjects/plotsWebview' const findProgressBars = () => $$('.monaco-progress-container') @@ -162,6 +163,29 @@ export const createCustomPlot = async (): Promise => { return browser.keys('Enter') } +export const deleteCustomPlot = async (): Promise => { + const workbench = await browser.getWorkbench() + const removeCustomPlot = await workbench.executeCommand( + 'DVC: Remove Custom Plot(s)' + ) + await browser.waitUntil(() => removeCustomPlot.elem.isDisplayed()) + await browser.keys('ArrowDown') + await browser.keys('Space') + return browser.keys('Enter') +} + +export const waitForAllPlotsToRender = ( + webview: PlotsWebview, + plotsAmount: number +): Promise => { + return browser.waitUntil( + async () => { + return (await webview.vegaVisualization$$.length) === plotsAmount + }, + { timeout: 30000 } + ) +} + export const findScmTreeItems = async () => { const workspace = await browser.getWorkbench() const activityBar = workspace.getActivityBar() From c7e525684254a322376ee0fe11c9699923cbf72f Mon Sep 17 00:00:00 2001 From: julieg18 Date: Mon, 10 Apr 2023 09:37:44 -0500 Subject: [PATCH 3/3] Resolve comments --- extension/src/test/e2e/extension.test.ts | 37 +++++++++--------------- extension/src/test/e2e/util.ts | 8 +++++ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/extension/src/test/e2e/extension.test.ts b/extension/src/test/e2e/extension.test.ts index 3ef70ccc50..9c7cf4f920 100644 --- a/extension/src/test/e2e/extension.test.ts +++ b/extension/src/test/e2e/extension.test.ts @@ -5,6 +5,7 @@ import { deleteAllExistingExperiments, deleteCustomPlot, dismissAllNotifications, + expectAllPlotsToBeFilled, findDecorationTooltip, findScmTreeItems, getDVCActivityBarIcon, @@ -24,8 +25,14 @@ before('should finish loading the extension', async function () { return dismissAllNotifications() }) -after(function () { +after(async function () { this.timeout(60000) + + try { + await deleteCustomPlot() + } catch {} + await dismissAllNotifications() + return waitForDvcToFinish() }) @@ -135,6 +142,7 @@ describe('Experiments Table Webview', function () { describe('Plots Webview', function () { const webview = new PlotsWebview('plots') + // eslint-disable-next-line jest/expect-expect it('should load the plots webview with non-empty plots', async function () { this.timeout(60000) const workbench = await browser.getWorkbench() @@ -146,16 +154,13 @@ describe('Plots Webview', function () { await waitForAllPlotsToRender(webview, 5) - const plots = await webview.vegaVisualization$$ - for (const plot of plots) { - const plotNotEmpty = await webview.plotNotEmpty(plot) - expect(plotNotEmpty).toBe(true) - } + await expectAllPlotsToBeFilled(webview) await webview.unfocus() await closeAllEditors() }) + // eslint-disable-next-line jest/expect-expect it('should create and delete a custom plot', async function () { this.timeout(60000) await createCustomPlot() @@ -168,11 +173,7 @@ describe('Plots Webview', function () { await waitForAllPlotsToRender(webview, 6) - let plots = await webview.vegaVisualization$$ - for (const plot of plots) { - const plotNotEmpty = await webview.plotNotEmpty(plot) - expect(plotNotEmpty).toBe(true) - } + await expectAllPlotsToBeFilled(webview) await webview.unfocus() await closeAllEditors() @@ -185,23 +186,11 @@ describe('Plots Webview', function () { await waitForAllPlotsToRender(webview, 5) - plots = await webview.vegaVisualization$$ - for (const plot of plots) { - const plotNotEmpty = await webview.plotNotEmpty(plot) - expect(plotNotEmpty).toBe(true) - } + await expectAllPlotsToBeFilled(webview) await webview.unfocus() await closeAllEditors() }) - - after(async function () { - this.timeout(60000) - try { - await deleteCustomPlot() - } catch {} - await dismissAllNotifications() - }) }) describe('Source Control View', function () { diff --git a/extension/src/test/e2e/util.ts b/extension/src/test/e2e/util.ts index ee99f7e4c6..a3f007f839 100644 --- a/extension/src/test/e2e/util.ts +++ b/extension/src/test/e2e/util.ts @@ -186,6 +186,14 @@ export const waitForAllPlotsToRender = ( ) } +export const expectAllPlotsToBeFilled = async (webview: PlotsWebview) => { + const plots = await webview.vegaVisualization$$ + for (const plot of plots) { + const plotNotEmpty = await webview.plotNotEmpty(plot) + expect(plotNotEmpty).toBe(true) + } +} + export const findScmTreeItems = async () => { const workspace = await browser.getWorkbench() const activityBar = workspace.getActivityBar()