Skip to content

Commit

Permalink
Add aliasing in Element questions
Browse files Browse the repository at this point in the history
  • Loading branch information
doe0003p committed Aug 12, 2024
1 parent b023169 commit c58060b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion qodana.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: "1.0"
linter: jetbrains/qodana-js:2023.3
linter: jetbrains/qodana-js:2024.1
include:
- name: CheckDependencyLicenses
- name: DuplicatedCode
exclude:
- name: ES6PreferShortImport
18 changes: 9 additions & 9 deletions src/web/questions/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export class Element extends FrameEnabledQuestion {
*/
public async answeredBy(actor: Actor): Promise<boolean> {
const {
mode, selector, payload, checkMode, options, frameTree,
mode, selector, payload, checkMode, options, frameTree, abilityAlias,
} = this;

if (mode === 'visible') {
const locator = await BrowseTheWeb.as(actor).resolveSelectorToLocator(selector, { ...options, state: checkMode === 'positive' ? 'visible' : 'hidden' }, frameTree);
const locator = await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(selector, { ...options, state: checkMode === 'positive' ? 'visible' : 'hidden' }, frameTree);

if (this.checkMode === 'positive') {
await expect(locator).toBeVisible({ timeout: options?.timeout });
Expand All @@ -49,7 +49,7 @@ export class Element extends FrameEnabledQuestion {
return Promise.resolve(true); // if the ability method is not the expected result there will be an exception
}
if (mode === 'enabled') {
const locator = await BrowseTheWeb.as(actor).resolveSelectorToLocator(selector, options, frameTree);
const locator = await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(selector, options, frameTree);

if (this.checkMode === 'positive') {
await expect(locator).toBeEnabled({ timeout: options?.timeout });
Expand All @@ -59,7 +59,7 @@ export class Element extends FrameEnabledQuestion {
return Promise.resolve(true); // if the ability method is not the expected result there will be an exception
}
if (mode === 'text') {
const locator = await BrowseTheWeb.as(actor).resolveSelectorToLocator(selector, options, frameTree);
const locator = await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(selector, options, frameTree);

if (this.checkMode === 'positive') {
await expect(locator).toHaveText(payload as string, { timeout: options?.timeout });
Expand All @@ -69,7 +69,7 @@ export class Element extends FrameEnabledQuestion {
return Promise.resolve(true); // if the ability method is not the expected result there will be an exception
}
if (mode === 'value') {
const locator = await BrowseTheWeb.as(actor).resolveSelectorToLocator(selector, options, frameTree);
const locator = await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(selector, options, frameTree);

if (this.checkMode === 'positive') {
await expect(locator).toHaveValue(payload as string | RegExp, { timeout: options?.timeout });
Expand All @@ -79,7 +79,7 @@ export class Element extends FrameEnabledQuestion {
return Promise.resolve(true); // if the ability method is not the expected result there will be an exception
}
if (mode === 'checked') {
const locator = await BrowseTheWeb.as(actor).resolveSelectorToLocator(selector, options, frameTree);
const locator = await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(selector, options, frameTree);

if (this.checkMode === 'positive') {
await expect(locator).toBeChecked({ timeout: options?.timeout });
Expand All @@ -89,7 +89,7 @@ export class Element extends FrameEnabledQuestion {
return Promise.resolve(true); // if the ability method is not the expected result there will be an exception
}
if (mode === 'count') {
const locator = await BrowseTheWeb.as(actor).resolveSelectorToLocator(selector, { ...options, evaluateVisible: false }, frameTree);
const locator = await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(selector, { ...options, evaluateVisible: false }, frameTree);

if (this.checkMode === 'positive') {
await expect(locator).toHaveCount(payload as number, { timeout: options?.timeout });
Expand All @@ -100,9 +100,9 @@ export class Element extends FrameEnabledQuestion {
}
if (mode === 'minCount') {
if (checkMode === 'positive') {
await BrowseTheWeb.as(actor).resolveSelectorToLocator(`${selector} >> nth=${payload as number - 1}`, options, frameTree);
await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(`${selector} >> nth=${payload as number - 1}`, options, frameTree);
} else {
await BrowseTheWeb.as(actor).resolveSelectorToLocator(`${selector} >> nth=${payload as number - 1}`, { ...options, state: 'hidden' }, frameTree);
await BrowseTheWeb.as(actor, abilityAlias).resolveSelectorToLocator(`${selector} >> nth=${payload as number - 1}`, { ...options, state: 'hidden' }, frameTree);
}

return Promise.resolve(true);
Expand Down

0 comments on commit c58060b

Please sign in to comment.