Skip to content

Commit

Permalink
feat: Add TextEditor.getBreakpoints(): Promise<Breakpoint[]> (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
pospisilf authored Aug 30, 2024
1 parent 6977fcb commit 9221c0e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/page-objects/src/components/editor/TextEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,32 @@ export class TextEditor extends Editor {
return new Breakpoint(breakpoints[0], lineElement);
}

/**
* Get all breakpoints.
* @returns List of Breakpoints.
*/
async getBreakpoints(): Promise<Breakpoint[]> {
const breakpoints: Breakpoint[] = [];

const breakpointLocators = Breakpoint.locators.TextEditor.breakpoint;
const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(By.className('glyph-margin-widgets')) : this;
const breakpointsSelectors = await breakpointContainer.findElements(breakpointLocators.generalSelector);

for (const breakpointSelector of breakpointsSelectors) {
let lineElement: WebElement;
if (TextEditor.versionInfo.version >= '1.80.0') {
const styleTopAttr = await breakpointSelector.getCssValue('top');
lineElement = await this.findElement(TextEditor.locators.TextEditor.marginArea).findElement(
By.xpath(`.//div[contains(@style, "${styleTopAttr}")]`),
);
} else {
lineElement = await breakpointSelector.findElement(By.xpath('./..'));
}
breakpoints.push(new Breakpoint(breakpointSelector, lineElement));
}
return breakpoints;
}

/**
* Get all code lenses within the editor
* @returns list of CodeLens page objects
Expand Down
6 changes: 6 additions & 0 deletions tests/test-project/src/test/debug/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ describe('Debugging', function () {
)) as Breakpoint;
});

it('TextEditor: getBreakpoints works', async function () {
const breakpoints = editor.getBreakpoints();
expect((await breakpoints).length).equals(2);
expect(await (await breakpoints).at(0)?.getLineNumber()).equals(7);
});

it('Breakpoint: getLineNumber works', async function () {
expect(await breakpoint.getLineNumber()).equals(line);
});
Expand Down

0 comments on commit 9221c0e

Please sign in to comment.