Skip to content

Commit

Permalink
Update e2e tests for latest libs
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelLH committed Nov 26, 2024
1 parent 99d6426 commit 5e99acc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
28 changes: 17 additions & 11 deletions e2e/src/app.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,31 @@ export class AppPage {
await ionicSelect.click();
await ionicSelect.waitForStable();

return $$('div.alert-radio-group > button').map(possibleRadio => {
const possibleRadios = await $$('>>>.alert-radio-group > button'); // inc. label, clickable
const possibleOkButtons = await $$('>>>button.alert-button');

possibleRadios.map(possibleRadio => {
possibleRadio.getText().then(async possibleRadioText => {
if (possibleRadioText === valueLabel) {
possibleRadio.click();

// ion-select OK button, inside the alert group overlay, now has its copy in an inner span.
// But Webdriver.io v9+ is smart enough that we can just click whatever has 'OK' text.
await $('=OK').click();
resolve(true);
}
}).catch(error => {
// If we already found the desired radio button in another elements from the `map` and
// clicked OK, this one won't have an element to `getText()` from any more. This is fine
// and we just need to catch the WebDriver error so the test can proceed.
});
});

await ionicSelect.waitForStable();

possibleOkButtons.map(possibleOkButton => {
possibleOkButton.getText().then(async possibleOkButtonText => {
if (possibleOkButtonText === 'OK') {
possibleOkButton.click();
resolve(true);
}
});
});
});
};

Expand Down Expand Up @@ -112,11 +121,8 @@ export class AppPage {
};

async confirmRangeVisibility(elementName: string, expectedToBeVisible: boolean) {
if (expectedToBeVisible) {
expect($(`ion-range[ng-reflect-name="${elementName}"]`)).toExist();
} else {
expect($(`ion-range[ng-reflect-name="${elementName}"]`)).not.toExist();
}
const rangeElements = await $$(`ion-range[ng-reflect-name="${elementName}"]`);
expect(await rangeElements.length).toEqual(expectedToBeVisible ? 1 : 0);
};

async getPageText(pageName: string): Promise<string> {
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@wdio/jasmine-framework": "^9.0.7",
"@wdio/local-runner": "^9.0.7",
"@wdio/spec-reporter": "^9.0.7",
"chromedriver": "^127.0.0",
"chromedriver": "^131.0.0",
"eslint": "^8.57.0",
"jasmine-core": "^5.2.0",
"jasmine-spec-reporter": "^7.0.0",
Expand Down

0 comments on commit 5e99acc

Please sign in to comment.