From 1ca0038032748eadf10a448658cbf85e9fb5e7e2 Mon Sep 17 00:00:00 2001 From: Dominik Jelinek Date: Sat, 18 Feb 2023 10:11:24 +0100 Subject: [PATCH] Support for latest stable VSCode 1.75.x release (#635) Signed-off-by: Dominik Jelinek --- .github/workflows/insiders.yml | 7 +- .github/workflows/main.yml | 7 +- .../src/components/bottomBar/Views.ts | 1 + src/extester.ts | 4 +- test/test-project/.vscode/settings.json | 2 +- test/test-project/package.json | 2 +- .../test-project/src/test/debug/debug-test.ts | 12 +++- .../src/test/editor/editorView-test.ts | 67 ++++++++++--------- .../src/test/editor/textEditor-test.ts | 5 +- .../src/test/menu/titleBar-test.ts | 61 ++++++++++------- .../src/test/statusBar/statusBar-test.ts | 3 +- .../src/test/workbench/input-test.ts | 3 +- 12 files changed, 98 insertions(+), 76 deletions(-) diff --git a/.github/workflows/insiders.yml b/.github/workflows/insiders.yml index 240c877d8..5b138bf1d 100644 --- a/.github/workflows/insiders.yml +++ b/.github/workflows/insiders.yml @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true jobs: - test: + build: runs-on: ${{ matrix.os }} strategy: matrix: @@ -51,10 +51,7 @@ jobs: - name: Run Tests (linux) if: ${{ contains(matrix.os, 'ubuntu') }} run: | - sudo apt-get install xvfb - export DISPLAY=:99 - Xvfb -ac :99 -screen 0 1920x1080x16 & - npm run ci-test + xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run ci-test - name: Upload screenshots uses: actions/upload-artifact@v3 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5053d2128..838d4be5f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - version: [ min, 1.71.2, 1.72.2, 1.73.1, max ] + version: [ min, 1.72.2, 1.73.1, 1.74.3, max ] include: - os: macos-latest version: max @@ -57,10 +57,7 @@ jobs: - name: Run Tests (linux) if: ${{ contains(matrix.os, 'ubuntu') }} run: | - sudo apt-get install xvfb - export DISPLAY=:99 - Xvfb -ac :99 -screen 0 1920x1080x16 & - npm run ci-test + xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run ci-test - name: Upload Screenshots uses: actions/upload-artifact@v3 diff --git a/page-objects/src/components/bottomBar/Views.ts b/page-objects/src/components/bottomBar/Views.ts index ce935e76d..01af2d2ac 100644 --- a/page-objects/src/components/bottomBar/Views.ts +++ b/page-objects/src/components/bottomBar/Views.ts @@ -166,6 +166,7 @@ export class TerminalView extends ChannelView { } const list = await this.findElement(TerminalView.locators.TerminalView.tabList); const row = await list.findElement(TerminalView.locators.TerminalView.selectedRow); + await this.getDriver().sleep(1000); const label = (await row.getAttribute('aria-label')).split(' '); return `${label[1]}: ${label[2]}` diff --git a/src/extester.ts b/src/extester.ts index ed1d032b1..838188a47 100644 --- a/src/extester.ts +++ b/src/extester.ts @@ -26,8 +26,8 @@ export const DEFAULT_SETUP_OPTIONS = { installDependencies: false } -export const VSCODE_VERSION_MIN = '1.70.1'; -export const VSCODE_VERSION_MAX = '1.74.3'; +export const VSCODE_VERSION_MIN = '1.71.2'; +export const VSCODE_VERSION_MAX = '1.75.1'; /** * VSCode Extension Tester diff --git a/test/test-project/.vscode/settings.json b/test/test-project/.vscode/settings.json index 3f65c8f93..4c5dc4bc5 100644 --- a/test/test-project/.vscode/settings.json +++ b/test/test-project/.vscode/settings.json @@ -1,3 +1,3 @@ { - "window.title": "${activeEditorShort}${separator}${rootName}${separator}folder: ${rootPath}" + "window.title": "${activeEditorShort}${separator}folder: ${rootPath}" } \ No newline at end of file diff --git a/test/test-project/package.json b/test/test-project/package.json index ad29c8b24..a03506d94 100644 --- a/test/test-project/package.json +++ b/test/test-project/package.json @@ -131,7 +131,7 @@ "compile": "rimraf out && tsc -p ./ && npm run lint", "lint": "eslint src --ext .ts", "watch": "tsc -watch -p ./", - "ui-test": "npm run compile && extest setup-and-run './out/src/test/**/customView*test.js' -u -i -r . -e ./test-extensions ", + "ui-test": "npm run compile && extest setup-and-run './out/src/test/**/customView*test.js' -u -i -r . -e ./test-extensions", "ci-test": "npm run compile && extest setup-and-run './out/src/test/**/*test.js' -u -i -r . -e ./test-extensions" }, "devDependencies": { diff --git a/test/test-project/src/test/debug/debug-test.ts b/test/test-project/src/test/debug/debug-test.ts index 13545aaf3..e65d99a07 100644 --- a/test/test-project/src/test/debug/debug-test.ts +++ b/test/test-project/src/test/debug/debug-test.ts @@ -1,4 +1,4 @@ -import { ActivityBar, Breakpoint, DebugConsoleView, DebugToolbar, DebugView, DefaultTreeSection, EditorView, InputBox, Key, TextEditor, TitleBar, until, VSBrowser, WebDriver, Workbench } from "vscode-extension-tester"; +import { ActivityBar, BottomBarPanel, Breakpoint, DebugConsoleView, DebugToolbar, DebugView, DefaultTreeSection, EditorView, InputBox, Key, TextEditor, TitleBar, until, VSBrowser, WebDriver, Workbench } from "vscode-extension-tester"; import * as path from 'path'; import { expect } from "chai"; @@ -22,6 +22,16 @@ import { expect } from "chai"; await (await tree.findItem('test.js')).select(); view = (await (await new ActivityBar().getViewControl('Run')).openView()) as DebugView; + + // clear notifications center which causes flaky tests from VSCode version 1.75.x + await (await new Workbench().openNotificationsCenter()).clearAllNotifications(); + }); + + after('After cleanup', async function () { + this.timeout(10000); + await new EditorView().closeAllEditors(); + await (await new ActivityBar().getViewControl('Run and Debug')).closeView(); + await new BottomBarPanel().toggle(false); }); describe('Debug View', () => { diff --git a/test/test-project/src/test/editor/editorView-test.ts b/test/test-project/src/test/editor/editorView-test.ts index b1e57b701..42aa9eecb 100644 --- a/test/test-project/src/test/editor/editorView-test.ts +++ b/test/test-project/src/test/editor/editorView-test.ts @@ -1,37 +1,35 @@ import { expect } from 'chai'; import { EditorView, EditorTab, Workbench, TextEditor, SettingsEditor, WebView, QuickOpenBox, DiffEditor, Key, InputBox, VSBrowser } from 'vscode-extension-tester'; -describe('EditorView', () => { +describe('EditorView', function () { let view: EditorView; - before(async function() { + before(async function () { this.timeout(25000); view = new EditorView(); - await new Workbench().executeCommand('File: New File'); - await new Promise((res) => { setTimeout(res, 500); }); - await new Workbench().executeCommand('File: New File'); - await new Promise((res) => { setTimeout(res, 500); }); + await newUntitledFile(); + await newUntitledFile(); await new Workbench().executeCommand('Webview Test'); - await new Promise((res) => { setTimeout(res, 2500); }); + await view.getDriver().sleep(2500); await new Workbench().executeCommand('Open Settings UI'); - await new Promise((res) => { setTimeout(res, 500); }); + await view.getDriver().sleep(500); }); - after(async () => { + after(async function () { await view.closeAllEditors(); }); - it('openEditor works with text editor', async () => { + it('openEditor works with text editor', async function () { const editor = await view.openEditor('Untitled-1') as TextEditor; expect(await editor.getTitle()).equals('Untitled-1'); }); - it('openEditor works with settings editor', async () => { + it('openEditor works with settings editor', async function () { const editor = await view.openEditor('Settings') as SettingsEditor; expect(editor.findSetting).not.undefined; }); - it('openEditor works with webview editor', async () => { + it('openEditor works with webview editor', async function () { let editorTitle: string; (await view.getOpenEditorTitles()).forEach(title => { if(title.startsWith('Test WebView')) { @@ -42,7 +40,7 @@ describe('EditorView', () => { expect(editor.findWebElement).not.undefined; }); - it('openEditor works with diff editor', async () => { + it('openEditor works with diff editor', async function () { await view.openEditor('Untitled-2'); await new Workbench().executeCommand('File: Compare Active File With...'); @@ -54,68 +52,67 @@ describe('EditorView', () => { } await quickOpen.setText('Untitled-1'); await quickOpen.confirm(); - await new Promise((res) => { setTimeout(res, 500); }); + await quickOpen.getDriver().sleep(500); const diffEditor = await view.openEditor('Untitled-2 ↔ Untitled-1') as DiffEditor; - await new Promise((res) => { setTimeout(res, 500); }); + await diffEditor.getDriver().sleep(500); expect(await diffEditor.getOriginalEditor()).not.undefined; expect(await diffEditor.getModifiedEditor()).not.undefined; }); - it('getTabByTitle works', async () => { + it('getTabByTitle works', async function () { const tab = await view.getTabByTitle('Untitled-1'); expect(tab).not.undefined; }); - it('getOpenEditorTitles works', async () => { + it('getOpenEditorTitles works', async function () { const tabs = await view.getOpenEditorTitles(); expect(tabs).not.empty; expect(tabs).contains('Untitled-1'); expect(tabs).contains('Untitled-2'); }); - it('closeEditor works', async () => { + it('closeEditor works', async function () { await view.closeEditor('Untitled-1'); const tabs = await view.getOpenEditorTitles(); expect(tabs).not.contains('Untitled-1'); }); - it('getActions works', async () => { + it('getActions works', async function () { const actions = await view.getActions(); expect(actions).not.empty; }); - it('getAction works', async () => { + it('getAction works', async function () { const action = await view.getAction('More Actions...'); expect(action).not.undefined; }); - describe('Editor Tab', () => { + describe('Editor Tab', function () { let tab: EditorTab; - before(async () => { + before(async function () { tab = await view.getTabByTitle('Untitled-2'); }); - it('getTitle works', async () => { + it('getTitle works', async function () { expect(await tab.getTitle()).equals('Untitled-2'); }); }); - describe('Editor Groups', () => { + describe('Editor Groups', function () { before(async function() { this.timeout(5000); view = new EditorView(); - await new Workbench().executeCommand('File: New File'); - await new Promise((res) => { setTimeout(res, 500); }); + await newUntitledFile(); }); - it('getEditorGroups works', async () => { + it('getEditorGroups works', async function () { let driverActions = view.getDriver().actions(); driverActions.clear(); driverActions.keyDown(Key.CONTROL).sendKeys('\\').keyUp(Key.CONTROL).perform(); - await new Promise((res) => { setTimeout(res, 500); }); + await view.getDriver().sleep(500); const groups = await view.getEditorGroups(); const group1 = await view.getEditorGroup(0); const group2 = await view.getEditorGroup(1); @@ -125,22 +122,22 @@ describe('EditorView', () => { expect((await group2.getRect()).x).equals((await groups[1].getRect()).x); }); - it('openEditor works for different groups', async () => { + it('openEditor works for different groups', async function () { const editor1 = await view.openEditor('Untitled-3', 0); const editor2 = await view.openEditor('Untitled-3', 1); expect((await editor1.getRect()).x < (await editor2.getRect()).x); }); - it('closeEditor works for different groups', async () => { + it('closeEditor works for different groups', async function () { await view.getDriver().actions().keyDown(EditorView.ctlKey).sendKeys('\\').perform(); - await new Promise((res) => { setTimeout(res, 500); }); + await view.getDriver().sleep(500); await view.closeEditor('Untitled-3', 2); expect((await view.getEditorGroups()).length).equals(2); }); - it('getOpenEditorTitles works for different editor groups', async () => { + it('getOpenEditorTitles works for different editor groups', async function () { const titles = await view.getOpenEditorTitles(); const titles1 = await view.getOpenEditorTitles(0); const titles2 = await view.getOpenEditorTitles(1); @@ -149,4 +146,10 @@ describe('EditorView', () => { expect(titles).deep.equals(allTitles); }); }); + + async function newUntitledFile(): Promise { + await new Workbench().executeCommand('Create: New File...'); + await (await InputBox.create()).selectQuickPick('Text File'); + await view.getDriver().sleep(500); + } }); \ No newline at end of file diff --git a/test/test-project/src/test/editor/textEditor-test.ts b/test/test-project/src/test/editor/textEditor-test.ts index 16c901628..8b8b3eb07 100644 --- a/test/test-project/src/test/editor/textEditor-test.ts +++ b/test/test-project/src/test/editor/textEditor-test.ts @@ -55,7 +55,8 @@ describe('TextEditor', () => { before(async function() { this.timeout(8000); - await new Workbench().executeCommand('File: New File'); + await new Workbench().executeCommand('Create: New File...'); + await (await InputBox.create()).selectQuickPick('Text File'); await new Promise((res) => { setTimeout(res, 1000); }); view = new EditorView(); editor = new TextEditor(view); @@ -291,7 +292,7 @@ describe('TextEditor', () => { }); it('clicking triggers the lens command', async () => { - const lens = await editor.getCodeLens(0); + const lens = await editor.getCodeLens(2); await lens.click(); await lens.getDriver().sleep(1000); const notifications = await new Workbench().getNotifications(); diff --git a/test/test-project/src/test/menu/titleBar-test.ts b/test/test-project/src/test/menu/titleBar-test.ts index 82c3795a9..ef107355a 100644 --- a/test/test-project/src/test/menu/titleBar-test.ts +++ b/test/test-project/src/test/menu/titleBar-test.ts @@ -1,80 +1,91 @@ import { expect } from 'chai'; -import { TitleBar, ContextMenu, BottomBarPanel, TitleBarItem, VSBrowser } from 'vscode-extension-tester'; +import { ActivityBar, TitleBar, ContextMenu, TitleBarItem, EditorView, VSBrowser } from 'vscode-extension-tester'; -(process.platform === 'darwin' ? describe.skip : describe)('TitleBar', () => { +(process.platform === 'darwin' ? describe.skip : describe)('TitleBar', function () { let bar: TitleBar; - before(async () => { + before(async function () { + this.timeout(10000); + bar = new TitleBar(); + + // workspace cleanup before tests + await new EditorView().closeAllEditors(); + await (await new ActivityBar().getViewControl('Explorer')).closeView(); + }); + + after(async function () { + this.timeout(10000); + await new EditorView().closeAllEditors(); }); - it('getTitle returns the window title', async () => { + it('getTitle returns the window title', async function() { const title = await bar.getTitle(); expect(title).not.empty; expect(title).has.string('Visual Studio Code'); }); - it('getWindowControls works', async () => { + it('getWindowControls works', async function () { const controls = bar.getWindowControls(); expect(controls).not.undefined; }); - it('getItem returns an item with the given name', async () => { + it('getItem returns an item with the given name', async function () { const item = await bar.getItem('File'); expect(item.getLabel()).equals('File'); }); - it('getItems returns all top menu items', async function() { + it('getItems returns all top menu items', async function () { this.timeout(4000); const items = (await bar.getItems()).map((item) => { return item.getLabel(); }); expect(items.length).greaterThan(5); - expect(items).contains.members(['File', 'Edit', 'View', 'Help', 'Selection']); + + let lastVisibleMenuItem = 'Help'; + if(VSBrowser.instance.version >= '1.75.0') { + lastVisibleMenuItem = 'More'; + } + expect(items).contains.members(['File', 'Edit', 'Selection', 'View', lastVisibleMenuItem]); }); - it('hasItem returns true if item exists', async () => { + it('hasItem returns true if item exists', async function () { const exists = await bar.hasItem('File'); expect(exists).is.true; }); - it('hasItem returns false if item does not exist', async () => { + it('hasItem returns false if item does not exist', async function () { const exists = await bar.hasItem('whatever1234'); expect(exists).is.false; }); - it('select opens a context menu if the item has children', async () => { + it('select opens a context menu if the item has children', async function () { const menu = (await bar.select('File')) as ContextMenu; expect(await menu.isDisplayed()).is.true; await menu.close(); }); - it('select navigates a multi level path', async () => { - let showPanelName = 'Show Panel'; - if (VSBrowser.instance.version >= '1.70.0') { - showPanelName = 'Panel'; - } - const menu = await bar.select('View', 'Appearance', showPanelName); + it('select navigates a multi level path', async function () { + const menu = (await bar.select('File', 'Open Recent', 'Reopen Closed Editor')) as ContextMenu; expect(menu).is.undefined; - await new BottomBarPanel().toggle(false); }); - describe('TitleBarItem', () => { + describe('TitleBarItem', function () { let item: TitleBarItem; - before(async () => { + before(async function () { item = await bar.getItem('File'); }); - it('getParent returns the title bar', () => { - const parent = item.getParent(); + it('getParent returns the title bar', async function() { + const parent = await item.getParent(); expect(parent).equals(bar); }); - it('getLabel returns the item label', () => { - const label = item.getLabel(); + it('getLabel returns the item label', async function () { + const label = await item.getLabel(); expect(label).equals('File'); }); - it('select open the item', async () => { + it('select open the item', async function () { const menu = await item.select(); expect(await menu.isDisplayed()).is.true; await menu.close(); diff --git a/test/test-project/src/test/statusBar/statusBar-test.ts b/test/test-project/src/test/statusBar/statusBar-test.ts index 530cdc970..fa7365182 100644 --- a/test/test-project/src/test/statusBar/statusBar-test.ts +++ b/test/test-project/src/test/statusBar/statusBar-test.ts @@ -6,7 +6,8 @@ describe('StatusBar', () => { before(async function() { this.timeout(5000); - await new Workbench().executeCommand('File: New File'); + await new Workbench().executeCommand('Create: New File...'); + await (await InputBox.create()).selectQuickPick('Text File'); bar = new StatusBar(); }); diff --git a/test/test-project/src/test/workbench/input-test.ts b/test/test-project/src/test/workbench/input-test.ts index db7e1ccbb..163b2a6b5 100644 --- a/test/test-project/src/test/workbench/input-test.ts +++ b/test/test-project/src/test/workbench/input-test.ts @@ -113,7 +113,8 @@ describe('InputBox', () => { before(async function () { this.timeout(6000); - await new Workbench().executeCommand('File: New File'); + await new Workbench().executeCommand('Create: New File...'); + await (await InputBox.create()).selectQuickPick('Text File'); await new Promise(res => setTimeout(res, 500)); await new StatusBar().openLanguageSelection(); input = await InputBox.create();;