Skip to content

Commit

Permalink
Add multipple breakpoints to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
unsortedhashsets authored and djelinek committed Aug 22, 2023
1 parent 09c6b4a commit d41bcf1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
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 fisrt breakpoint', async function () {
const result = await editor.toggleBreakpoint(line);
expect(result).to.be.false;
});
Expand Down

0 comments on commit d41bcf1

Please sign in to comment.