Skip to content

Commit

Permalink
test: fix debug test for VS Code 1.93.x
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek committed Sep 11, 2024
1 parent 9139cc9 commit 6e4c730
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
14 changes: 7 additions & 7 deletions packages/page-objects/src/locators/locators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export interface LocatorDiff {

export function hasAttribute(attr: string, value?: string, locator?: By): (el: WebElement) => Promise<boolean> {
return async (el: WebElement) => {
el = locator ? el.findElement(locator) : el;
el = locator ? await el.findElement(locator) : el;
const attrValue = await el.getAttribute(attr);
if (value === undefined) {
return attrValue !== null;
Expand All @@ -527,7 +527,7 @@ export function hasAttribute(attr: string, value?: string, locator?: By): (el: W

export function hasClass(classOrPredicate: string | ((klass: string) => boolean), locator?: By): (el: WebElement) => Promise<boolean> {
return async (el: WebElement) => {
el = locator ? el.findElement(locator) : el;
el = locator ? await el.findElement(locator) : el;
const klasses = await el.getAttribute('class');
const segments = klasses?.split(/\s+/g);
const predicate = typeof classOrPredicate === 'string' ? (klass: string) => klass === classOrPredicate : classOrPredicate;
Expand All @@ -537,7 +537,7 @@ export function hasClass(classOrPredicate: string | ((klass: string) => boolean)

export function hasNotClass(klass: string, locator?: By): (el: WebElement) => Promise<boolean> {
return async (el: WebElement) => {
el = locator ? el.findElement(locator) : el;
el = locator ? await el.findElement(locator) : el;
return !(await hasClass(klass).call(undefined, el));
};
}
Expand All @@ -550,14 +550,14 @@ export function hasElement(locatorSelector: (l: Locators) => By): (el: WebElemen

export function fromAttribute(attribute: string, locator?: By): (el: WebElement) => Promise<string> {
return async (el: WebElement) => {
el = locator ? el.findElement(locator) : el;
return el.getAttribute(attribute);
el = locator ? await el.findElement(locator) : el;
return await el.getAttribute(attribute);
};
}

export function fromText(locator?: By): (el: WebElement) => Promise<string> {
return async (el: WebElement) => {
el = locator ? el.findElement(locator) : el;
return el.getText();
el = locator ? await el.findElement(locator) : el;
return await el.getText();
};
}
26 changes: 22 additions & 4 deletions tests/test-project/src/test/debug/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,39 @@ describe('Debugging', function () {
});

it('TextEditor: getBreakpoint works', async function () {
const breakpoint = await editor.getBreakpoint(7);
const breakpoint = (await driver.wait<Breakpoint>(
async () => await editor.getBreakpoint(7),
10000,
'could not find breakpoint at line 7',
)) as Breakpoint;
expect(breakpoint).not.undefined;
});

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);
const breakpoints = (await driver.wait<Breakpoint[]>(
async () => await editor.getBreakpoints(),
10000,
'could not find breakpoints',
)) as Breakpoint[];
expect(breakpoints.length).equals(2);
expect(await breakpoints.at(0)?.getLineNumber()).equals(7);
});

it('Breakpoint: getLineNumber works', async function () {
breakpoint = (await driver.wait<Breakpoint>(
async () => await editor.getPausedBreakpoint(),
10000,
'could not find paused breakpoint',
)) as Breakpoint;
expect(await breakpoint.getLineNumber()).equals(line);
});

it('Breakpoint: isPaused works', async function () {
breakpoint = (await driver.wait<Breakpoint>(
async () => await editor.getPausedBreakpoint(),
10000,
'could not find paused breakpoint',
)) as Breakpoint;
expect(await breakpoint.isPaused()).to.be.true;
});

Expand Down

0 comments on commit 6e4c730

Please sign in to comment.