-
Notifications
You must be signed in to change notification settings - Fork 28
Add e2e tests (wdio-vscode-service) #1993
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b5ee78a
get basic webview test working
mattseddon d114312
split startup function
mattseddon f516807
expand testing of the webview
mattseddon f32e33a
update before hook
mattseddon d2c2d40
add basic test for plots webview
mattseddon 054333a
add custom page objects
mattseddon f86e13b
add utils
mattseddon 4d637c7
move more logic into page object
mattseddon 27e1494
scroll plots into view
mattseddon 3020019
add test e2e command
mattseddon 3cc13ef
Merge branch 'main' into end-to-end
mattseddon f6a3659
Merge branch 'end-to-end' of https://github.com/iterative/vscode-dvc …
mattseddon f98d17a
Merge branch 'main' into end-to-end
mattseddon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| *.vsix | ||
| .vscode-test | ||
| .wdio-vscode-service | ||
| README.md | ||
| LICENSE | ||
| CHANGELOG.md | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import { suite, before, describe, it } from 'mocha' | ||
| import { | ||
| closeAllEditors, | ||
| dismissAllNotifications, | ||
| getDVCActivityBarIcon, | ||
| waitForViewContainerToLoad | ||
| } from './util' | ||
| import { ExperimentsWebview } from './pageObjects/experimentsWebview' | ||
| import { PlotsWebview } from './pageObjects/plotsWebview' | ||
| import { delay } from '../../util/time' | ||
|
|
||
| suite('DVC Extension For Visual Studio Code', () => { | ||
| before('should finish loading the extension', async () => { | ||
| await waitForViewContainerToLoad() | ||
| return dismissAllNotifications() | ||
| }) | ||
|
|
||
| // avoid killing any background process after experiments have finished run | ||
| after(() => delay(30000)) | ||
|
|
||
| afterEach(() => browser.switchToFrame(null)) | ||
|
|
||
| describe('Activity Bar', () => { | ||
| it('should show the DVC Icon', async () => { | ||
| const dvcIcon = await getDVCActivityBarIcon() | ||
| expect(await dvcIcon.getTitle()).toBe('DVC') | ||
| }) | ||
| }) | ||
|
|
||
| describe('Experiments Table Webview', () => { | ||
| const webview = new ExperimentsWebview('experiments') | ||
|
|
||
| it('should load as an editor', async () => { | ||
| const workbench = await browser.getWorkbench() | ||
|
|
||
| await workbench.executeCommand('DVC: Show Experiments') | ||
|
|
||
| await webview.open() | ||
|
|
||
| await browser.waitUntil(async () => { | ||
| const table = await webview.table$ | ||
| return table.isDisplayed() | ||
| }) | ||
|
|
||
| expect(await webview.table$$).toHaveLength(1) | ||
|
|
||
| await webview.close() | ||
| }) | ||
|
|
||
| it('should update with a new row for each checkpoint when an experiment is running', async () => { | ||
| const workbench = await browser.getWorkbench() | ||
| const epochs = 15 | ||
| await workbench.executeCommand('DVC: Reset and Run Experiment') | ||
|
|
||
| await webview.open() | ||
|
|
||
| await browser.waitUntil(() => webview.expandAllRows()) | ||
|
|
||
| const initialRows = await webview.row$$ | ||
|
|
||
| expect(initialRows.length).toBeGreaterThanOrEqual(4) | ||
|
|
||
| await browser.waitUntil( | ||
| async () => { | ||
| await webview.expandAllRows() | ||
| const currentRows = await webview.row$$ | ||
| return currentRows.length >= initialRows.length + epochs | ||
| }, | ||
| { timeout: 120000 } | ||
| ) | ||
|
|
||
| const finalRows = await webview.row$$ | ||
|
|
||
| expect(finalRows.length).toStrictEqual(initialRows.length + epochs) | ||
| await webview.close() | ||
| }).timeout(180000) | ||
| }) | ||
|
|
||
| describe('Plots Webview', () => { | ||
| before(async () => { | ||
| await closeAllEditors() | ||
| }) | ||
|
|
||
| const webview = new PlotsWebview('plots') | ||
|
|
||
| it('should load the plots webview with non-empty plots', async () => { | ||
| const workbench = await browser.getWorkbench() | ||
| await workbench.executeCommand('DVC: Show Plots') | ||
|
|
||
| await webview.open() | ||
|
|
||
| await browser.waitUntil(async () => { | ||
| return (await webview.vegaVisualization$$.length) === 6 | ||
| }) | ||
|
|
||
| const plots = await webview.vegaVisualization$$ | ||
|
|
||
| for (const plot of plots) { | ||
| await plot.scrollIntoView() | ||
| const plotNotEmpty = await webview.plotNotEmpty(plot) | ||
| expect(plotNotEmpty).toBe(true) | ||
| } | ||
|
|
||
| await webview.close() | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { BasePage, IPageDecorator, PageDecorator } from 'wdio-vscode-service' | ||
| import { webview as webviewLocators } from './locators' | ||
| import * as locators from './locators' | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
| export interface BaseWebview extends IPageDecorator<typeof webviewLocators> {} | ||
|
|
||
| @PageDecorator(webviewLocators) | ||
| export class BaseWebview extends BasePage< | ||
| typeof webviewLocators, | ||
| typeof locators | ||
| > { | ||
| public locatorKey: 'webview' | 'experiments' | 'plots' | ||
|
|
||
| constructor(locatorKey: keyof typeof locators) { | ||
| super(locators) | ||
| this.locatorKey = locatorKey | ||
| } | ||
|
|
||
| public async open() { | ||
| const webviewContainer = await this.outerFrame$ | ||
|
|
||
| await this.outerFrame$.waitForDisplayed() | ||
|
|
||
| await browser.switchToFrame(webviewContainer) | ||
| await this.innerFrame$.waitForDisplayed() | ||
| const webviewInner = await browser.findElement( | ||
| 'css selector', | ||
| this.locators.innerFrame | ||
| ) | ||
| return browser.switchToFrame(webviewInner) | ||
| } | ||
|
|
||
| public async close() { | ||
| await browser.switchToFrame(null) | ||
| await browser.switchToFrame(null) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { IPageDecorator, PageDecorator } from 'wdio-vscode-service' | ||
| import { BaseWebview } from './baseWebview' | ||
| import { experiments } from './locators' | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
| export interface ExperimentsWebview | ||
| extends IPageDecorator<typeof experiments> {} | ||
|
|
||
| @PageDecorator(experiments) | ||
| export class ExperimentsWebview extends BaseWebview { | ||
| public async expandAllRows() { | ||
| const expandRowButtons = await this.expandRowButton$$ | ||
| for (const button of expandRowButtons) { | ||
| button.click() | ||
| } | ||
| return expandRowButtons.length === 0 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| export const webview = { | ||
| innerFrame: '#active-frame', | ||
| outerFrame: '.webview.ready' | ||
| } | ||
|
|
||
| export const experiments = { | ||
| ...webview, | ||
| expandRowButton: 'button[title="Expand Row"]', | ||
| row: '[role=row]', | ||
| table: '[role=table]' | ||
| } | ||
|
|
||
| export const plots = { | ||
| ...webview, | ||
| vegaVisualization: 'div[aria-label="Vega visualization"]' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { IPageDecorator, PageDecorator } from 'wdio-vscode-service' | ||
| import { BaseWebview } from './baseWebview' | ||
| import { plots } from './locators' | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
| export interface PlotsWebview extends IPageDecorator<typeof plots> {} | ||
|
|
||
| @PageDecorator(plots) | ||
| export class PlotsWebview extends BaseWebview { | ||
| public async plotNotEmpty(plot: WebdriverIO.Element) { | ||
| return (await this.plotHasRects(plot)) || (await this.plotHasLines(plot)) | ||
| } | ||
|
|
||
| private async plotHasRects(plot: WebdriverIO.Element) { | ||
| return (await plot.$$('[aria-roledescription="rect mark"]').length) > 0 | ||
| } | ||
|
|
||
| private async plotHasLines(plot: WebdriverIO.Element) { | ||
| return (await plot.$$('[aria-roledescription="line mark"]').length) > 0 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { ViewControl } from 'wdio-vscode-service' | ||
|
|
||
| export const dismissAllNotifications = () => | ||
| browser.waitUntil(async () => { | ||
| const workbench = await browser.getWorkbench() | ||
| const notifications = await workbench.getNotifications() | ||
| for (const n of notifications) { | ||
| await n.dismiss() | ||
| } | ||
| const openNotifications = await workbench.getNotifications() | ||
| return openNotifications.length === 0 | ||
| }) | ||
|
|
||
| export const getDVCActivityBarIcon = async (): Promise<ViewControl> => { | ||
| const workbench = await browser.getWorkbench() | ||
|
|
||
| const activityBar = workbench.getActivityBar() | ||
|
|
||
| await browser.waitUntil( | ||
| async () => !!(await activityBar.getViewControl('DVC')) | ||
| ) | ||
| return activityBar.getViewControl('DVC') as Promise<ViewControl> | ||
| } | ||
|
|
||
| export const waitForViewContainerToLoad = async () => { | ||
| const initialProgressBars = await $$('.monaco-progress-container') | ||
| await browser.waitUntil(async () => { | ||
| const dvcIcon = await getDVCActivityBarIcon() | ||
| if (!dvcIcon) { | ||
| return false | ||
| } | ||
|
|
||
| const view = await dvcIcon.openView() | ||
|
|
||
| return !!view | ||
| }) | ||
|
|
||
| return browser.waitUntil(async () => { | ||
| const numberOfProgressBarsInContainer = 7 | ||
| const currentProgressBars = await $$('.monaco-progress-container') | ||
|
|
||
| if ( | ||
| currentProgressBars.length < | ||
| initialProgressBars.length + numberOfProgressBarsInContainer | ||
| ) { | ||
| return false | ||
| } | ||
|
|
||
| for (const progress of currentProgressBars) { | ||
| if ((await progress.getAttribute('aria-hidden')) !== 'true') { | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| return true | ||
| }) | ||
| } | ||
|
|
||
| export const closeAllEditors = async () => { | ||
| const workbench = await browser.getWorkbench() | ||
| const editorView = workbench.getEditorView() | ||
| return editorView.closeAllEditors() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { join, resolve } from 'path' | ||
| import { Options } from '@wdio/types' | ||
|
|
||
| export const config: Options.Testrunner = { | ||
| after: async function () { | ||
| await browser.switchToFrame(null) | ||
| await browser.switchToFrame(null) | ||
| }, | ||
| baseUrl: 'http://localhost', | ||
| before: async function () { | ||
| await browser.setWindowSize(1600, 1200) | ||
| }, | ||
| capabilities: [ | ||
| { | ||
| browserName: 'vscode', | ||
| browserVersion: 'insiders', | ||
| // @ts-expect-error these caps are not typed in WebdriverIO | ||
| 'wdio:vscodeOptions': { | ||
| extensionPath: resolve(__dirname, '..', '..', '..'), | ||
| verboseLogging: false, | ||
| workspacePath: resolve(__dirname, '..', '..', '..', '..', 'demo') | ||
| } | ||
| } | ||
| ], | ||
| connectionRetryCount: 3, | ||
| connectionRetryTimeout: 120000, | ||
| framework: 'mocha', | ||
| maxInstances: 1, | ||
| mochaOpts: { | ||
| bail: true, | ||
| parallel: false, | ||
| retries: 0, | ||
| timeout: 60000, | ||
| ui: 'bdd' | ||
| }, | ||
| outputDir: join(__dirname, 'logs'), | ||
| reporters: ['spec'], | ||
| services: ['vscode'], | ||
| specs: ['./src/test/e2e/*.test.ts'], | ||
| waitforTimeout: 10000 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mention
test:e2ein the OP, but it'stest-e2ehere. Also, do we want to add an alias to this script in the workspace root?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was really confused by this. The problem is that I was working on this late last night and didn't push my final commit up. What you asked for is here. Sorry.