Skip to content

Commit

Permalink
Bump 'max' placeholder to latest vscode 1.80.2 (#892)
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek authored Aug 3, 2023
1 parent cbbff1f commit 68fa9fe
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 20 additions & 8 deletions page-objects/src/components/editor/TextEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,27 +422,28 @@ 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<boolean> {
const margin = await this.findElement(TextEditor.locators.TextEditor.marginArea);
const lineNum = await margin.findElement(TextEditor.locators.TextEditor.lineNumber(line));
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;
}

Expand All @@ -452,7 +453,8 @@ export class TextEditor extends Editor {
*/
async getPausedBreakpoint(): Promise<Breakpoint | undefined> {
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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -654,7 +662,8 @@ export class FindWidget extends AbstractElement {
* Close the widget.
*/
async close(): Promise<void> {
await this.clickButton('Close', 'find');
const part = TextEditor.versionInfo.version >= '1,80.0' ? 'close' : 'find';
await this.clickButton('Close', part);
}

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/extester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 15 additions & 17 deletions test/test-project/src/test/debug/debug-test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -31,51 +30,50 @@ 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();
}
await new TitleBar().select('File', 'Close Folder');
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();
Expand Down Expand Up @@ -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();
Expand All @@ -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));
Expand All @@ -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;
});
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 68fa9fe

Please sign in to comment.