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 multipple breakpoints to editor #905

Merged
merged 1 commit into from
Oct 3, 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
12 changes: 8 additions & 4 deletions page-objects/src/components/editor/TextEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class BreakpointError extends Error { }
* Page object representing the active text editor
*/
export class TextEditor extends Editor {
breakPoints: number[] = [];

/**
* Find whether the active editor has unsaved changes
Expand Down Expand Up @@ -433,15 +434,18 @@ export class TextEditor extends Editor {
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;
if (this.breakPoints.indexOf(line) != -1) {
await breakPoint[this.breakPoints.indexOf(line)].click();
await new Promise(res => setTimeout(res, 200));
this.breakPoints.splice(this.breakPoints.indexOf(line), 1);
return false;
}
}

const noBreak = await breakpointContainer.findElements(TextEditor.locators.TextEditor.debugHint);
if (noBreak.length > 0) {
await noBreak[0].click();
await new Promise(res => setTimeout(res, 200));
this.breakPoints.push(line);
return true;
}
return false;
Expand Down
14 changes: 12 additions & 2 deletions test/test-project/src/test/debug/debug-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ describe('Debugging', function () {
await new Promise(res => setTimeout(res, 5000));
});

it('set a breakpoint', async function () {
it('set first breakpoint', async function () {
const result = await editor.toggleBreakpoint(line + 1);
expect(result).to.be.true;
});

it('set second breakpoint', async function () {
const result = await editor.toggleBreakpoint(line);
expect(result).to.be.true;
});
Expand Down Expand Up @@ -221,7 +226,12 @@ describe('Debugging', function () {
await editor.getDriver().wait(until.elementIsNotVisible(debugBar));
});

it('remove the breakpoint', async function () {
it('remove the second breakpoint', async function () {
const result = await editor.toggleBreakpoint(line + 1);
expect(result).to.be.false;
});

it('remove the first breakpoint', async function () {
const result = await editor.toggleBreakpoint(line);
expect(result).to.be.false;
});
Expand Down