Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom plot to e2e test #3646

Merged
merged 7 commits into from
Apr 10, 2023
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
60 changes: 47 additions & 13 deletions extension/src/test/e2e/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { join } from 'path'
import {
closeAllEditors,
createCustomPlot,
deleteAllExistingExperiments,
deleteCustomPlot,
dismissAllNotifications,
expectAllPlotsToBeFilled,
findDecorationTooltip,
findScmTreeItems,
getDVCActivityBarIcon,
getLabel,
runModifiedExperiment,
waitForAllPlotsToRender,
waitForDvcToFinish,
waitForViewContainerToLoad
} from './util.js'
Expand All @@ -21,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()
})

Expand Down Expand Up @@ -130,32 +140,56 @@ 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 webview = new PlotsWebview('plots')
const workbench = await browser.getWorkbench()
await workbench.openCommandPrompt()
await browser.keys([...'DVC: Show Plots', 'ArrowDown', 'Enter'])

await waitForDvcToFinish()
await webview.focus()

await waitForAllPlotsToRender(webview, 5)

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()
const workbench = await browser.getWorkbench()
await workbench.openCommandPrompt()
await workbench.executeCommand('DVC: Show Plots')

await waitForDvcToFinish()
await webview.focus()

await browser.waitUntil(
async () => {
return (await webview.vegaVisualization$$.length) === 5
},
{ timeout: 30000 }
)
await waitForAllPlotsToRender(webview, 6)

await expectAllPlotsToBeFilled(webview)

await webview.unfocus()
await closeAllEditors()

const plots = await webview.vegaVisualization$$
await deleteCustomPlot()
await workbench.executeCommand('DVC: Show Plots')

for (const plot of plots) {
const plotNotEmpty = await webview.plotNotEmpty(plot)
expect(plotNotEmpty).toBe(true)
}
await waitForDvcToFinish()
await webview.focus()

await waitForAllPlotsToRender(webview, 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[C] Seeing as you have made this helper you might want to make another one for checking the plots are not empty.

Copy link
Contributor Author

@julieg18 julieg18 Apr 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the code to a helper but ran into the expect-expect eslint warning. I disabled it with a comment for now but can revert the change or adjust our configuration if preferred!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a comment to update the expect function names:

/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["expect", "expectHeaders"] }] */


await expectAllPlotsToBeFilled(webview)

await webview.unfocus()
await closeAllEditors()
})
})

Expand Down
41 changes: 41 additions & 0 deletions extension/src/test/e2e/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Key } from 'webdriverio'
import { ViewControl } from 'wdio-vscode-service'
import { PlotsWebview } from './pageObjects/plotsWebview'

const findProgressBars = () => $$('.monaco-progress-container')

Expand Down Expand Up @@ -153,6 +154,46 @@ export const closeAllEditors = async (): Promise<void> => {
return editorView.closeAllEditors()
}

export const createCustomPlot = async (): Promise<void> => {
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 deleteCustomPlot = async (): Promise<void> => {
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<true | void> => {
return browser.waitUntil(
async () => {
return (await webview.vegaVisualization$$.length) === plotsAmount
},
{ timeout: 30000 }
)
}

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()
Expand Down