From 68fa9feac8acb6ca6259fec79c61344600942d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Jel=C3=ADnek?= Date: Fri, 4 Aug 2023 00:54:02 +0200 Subject: [PATCH] Bump 'max' placeholder to latest vscode 1.80.2 (#892) Signed-off-by: Dominik Jelinek --- .github/workflows/main.yml | 2 +- .../src/components/editor/TextEditor.ts | 28 +++++++++++----- src/extester.ts | 4 +-- .../test-project/src/test/debug/debug-test.ts | 32 +++++++++---------- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c4f89de32..39da0d5ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - version: [ min, 1.78.2, max ] + version: [ min, 1.79.2, max ] fail-fast: false env: diff --git a/page-objects/src/components/editor/TextEditor.ts b/page-objects/src/components/editor/TextEditor.ts index 384b2c837..24b8a2b84 100644 --- a/page-objects/src/components/editor/TextEditor.ts +++ b/page-objects/src/components/editor/TextEditor.ts @@ -422,7 +422,7 @@ export class TextEditor extends Editor { * Toggle breakpoint on a given line * * @param line target line number - * @returns promise resolving to true when a breakpoint was added, false when removed or + * @returns promise resolving to True when a breakpoint was added, False when removed */ async toggleBreakpoint(line: number): Promise { const margin = await this.findElement(TextEditor.locators.TextEditor.marginArea); @@ -430,19 +430,20 @@ export class TextEditor extends Editor { await this.getDriver().actions().move({origin: lineNum}).perform(); const lineOverlay = await margin.findElement(TextEditor.locators.TextEditor.lineOverlay(line)); - const breakPoint = await lineOverlay.findElements(TextEditor.locators.TextEditor.breakpoint.generalSelector); + const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(By.className('glyph-margin-widgets')) : lineOverlay; + const breakPoint = await breakpointContainer.findElements(TextEditor.locators.TextEditor.breakpoint.generalSelector); if (breakPoint.length > 0) { await breakPoint[0].click(); await new Promise(res => setTimeout(res, 200)); return false; } - const noBreak = await lineOverlay.findElements(TextEditor.locators.TextEditor.debugHint); + const noBreak = await breakpointContainer.findElements(TextEditor.locators.TextEditor.debugHint); if (noBreak.length > 0) { await noBreak[0].click(); await new Promise(res => setTimeout(res, 200)); return true; - } + } return false; } @@ -452,7 +453,8 @@ export class TextEditor extends Editor { */ async getPausedBreakpoint(): Promise { const breakpointLocators = Breakpoint.locators.TextEditor.breakpoint; - const breakpoints = await this.findElements(breakpointLocators.pauseSelector); + const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(By.className('glyph-margin-widgets')) : this; + const breakpoints = await breakpointContainer.findElements(breakpointLocators.pauseSelector); if (breakpoints.length === 0) { return undefined; @@ -463,7 +465,13 @@ export class TextEditor extends Editor { } // get parent - const lineElement = breakpoints[0].findElement(By.xpath('./..')); + let lineElement: WebElement; + if(TextEditor.versionInfo.version >= '1.80.0') { + const styleTopAttr = await breakpoints[0].getCssValue('top'); + lineElement = await this.findElement(TextEditor.locators.TextEditor.marginArea).findElement(By.xpath(`.//div[contains(@style, "${styleTopAttr}")]`)) + } else { + lineElement = await breakpoints[0].findElement(By.xpath('./..')); + } return new Breakpoint(breakpoints[0], lineElement); } @@ -654,7 +662,8 @@ export class FindWidget extends AbstractElement { * Close the widget. */ async close(): Promise { - await this.clickButton('Close', 'find'); + const part = TextEditor.versionInfo.version >= '1,80.0' ? 'close' : 'find'; + await this.clickButton('Close', part); } /** @@ -721,7 +730,7 @@ export class FindWidget extends AbstractElement { } } - private async clickButton(title: string, part: 'find'|'replace') { + private async clickButton(title: string, part: 'find'|'replace'|'close') { let element!: WebElement; if (part === 'find') { element = await this.findElement(FindWidget.locators.FindWidget.findPart); @@ -730,6 +739,9 @@ export class FindWidget extends AbstractElement { element = await this.findElement(FindWidget.locators.FindWidget.replacePart); await this.toggleReplace(true); } + if (part === 'close') { + element = this; + } const btn = await element.findElement(FindWidget.locators.FindWidget.button(title)); await btn.click(); diff --git a/src/extester.ts b/src/extester.ts index 081f57f12..de1ca69e3 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.77.3'; -export const VSCODE_VERSION_MAX = '1.79.2'; +export const VSCODE_VERSION_MIN = '1.78.2'; +export const VSCODE_VERSION_MAX = '1.80.2'; /** * VSCode Extension Tester diff --git a/test/test-project/src/test/debug/debug-test.ts b/test/test-project/src/test/debug/debug-test.ts index b64467c26..6cbbf985e 100644 --- a/test/test-project/src/test/debug/debug-test.ts +++ b/test/test-project/src/test/debug/debug-test.ts @@ -1,11 +1,10 @@ -import { ActivityBar, BottomBarPanel, Breakpoint, BreakpointSectionItem, DebugBreakpointSection, DebugConsoleView, DebugToolbar, DebugView, EditorView, error, Key, TextEditor, TitleBar, TreeItemNotFoundError, until, VSBrowser, WebDriver, Workbench } from "vscode-extension-tester"; +import { ActivityBar, BottomBarPanel, Breakpoint, BreakpointSectionItem, DebugConsoleView, DebugToolbar, DebugView, EditorView, error, Key, TextEditor, TitleBar, until, VSBrowser, WebDriver, Workbench } from "vscode-extension-tester"; import * as path from 'path'; import { expect } from "chai"; -import { stat } from "fs"; const line = 7; -describe('Debugging', () => { +describe('Debugging', function () { process.env.NODE = process.execPath; const folder = path.resolve(__dirname, '..', '..', '..', '..', '..', 'debug-project'); let view: DebugView; @@ -31,38 +30,37 @@ describe('Debugging', () => { }); describe('Debug View', () => { - it('getLaunchConfiguration works', async () => { + it('getLaunchConfiguration works', async function () { const config = await view.getLaunchConfiguration(); expect(config).equals('Test Launch'); }); - it('getLaunchConfigurations works', async () => { + it('getLaunchConfigurations works', async function () { const configs = await view.getLaunchConfigurations(); expect(configs).contains('Test Launch'); expect(configs).contains('Test Launch2'); }); - it('selectLaunchConfiguration works', async () => { + it('selectLaunchConfiguration works', async function () { await view.selectLaunchConfiguration('Test Launch2'); const config = await view.getLaunchConfiguration(); expect(config).equals('Test Launch2'); }); }); - describe('Debug Session', () => { + describe('Debug Session', function () { let editor: TextEditor; let debugBar: DebugToolbar; let driver: WebDriver; let breakpoint!: Breakpoint; - before(async () => { - editor = (await new EditorView().openEditor('test.js')) as TextEditor; + before(async function () { + editor = await new EditorView().openEditor('test.js') as TextEditor; driver = editor.getDriver(); }); after(async function () { this.timeout(15000); - await editor.toggleBreakpoint(5); if (await debugBar.isDisplayed()) { await debugBar.stop(); } @@ -70,12 +68,12 @@ describe('Debugging', () => { await new Promise(res => setTimeout(res, 5000)); }); - it('set a breakpoint', async () => { + it('set a breakpoint', async function () { const result = await editor.toggleBreakpoint(line); expect(result).to.be.true; }); - it('start the debug session', async () => { + it('start the debug session', async function () { await view.start(); debugBar = await DebugToolbar.create(); await debugBar.waitForBreakPoint(); @@ -189,7 +187,7 @@ describe('Debugging', () => { expect(await item.getVariableValue()).equals('42'); }); - it('evaluate an expression', async () => { + it('evaluate an expression', async function () { const debugConsole = new DebugConsoleView(); await debugConsole.setExpression(`console.log('foo')`); await debugConsole.evaluateExpression(); @@ -202,7 +200,7 @@ describe('Debugging', () => { expect(text).to.have.string('bar'); }); - it('check content assist', async () => { + it('check content assist', async function () { const debugConsole = new DebugConsoleView(); await debugConsole.setExpression('i'); await new Promise(res => setTimeout(res, 1000)); @@ -218,12 +216,12 @@ describe('Debugging', () => { expect(list).not.to.be.empty; }); - it('stop the debug session', async () => { + it('stop the debug session', async function () { await debugBar.stop(); await editor.getDriver().wait(until.elementIsNotVisible(debugBar)); }); - it('remove the breakpoint', async () => { + it('remove the breakpoint', async function () { const result = await editor.toggleBreakpoint(line); expect(result).to.be.false; }); @@ -263,7 +261,7 @@ async function getNumVariable(view: DebugView, timeout: number) { async function getBreakpointItem(view: DebugView, timeout: number) { try { - return await view.getDriver().wait(async () => { + return await view.getDriver().wait(async function () { try { const breakpointSection = await view.getBreakpointSection(); return await breakpointSection.findItem(async (item: BreakpointSectionItem) => await item.getBreakpointLine() === line);