Skip to content

Commit

Permalink
Attempt to fix f-account-info tests
Browse files Browse the repository at this point in the history
  • Loading branch information
siggerzz committed Nov 15, 2023
1 parent a472b05 commit 207a90f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,72 +11,72 @@ import {
} from './f-account-info-selectors';

class AccountInfo extends Page {
constructor () {
constructor() {
super('page', 'account-info-component');
}

get errorCardComponent () { return $(ERROR_CARD); }
get errorCardComponent() { return $(ERROR_CARD); }

get errorAlert () { return $(ERROR_ALERT); }
get errorAlert() { return $(ERROR_ALERT); }

get successAlert () { return $(SUCCESS_ALERT); }
get successAlert() { return $(SUCCESS_ALERT); }

LinksAndButtons = {
changeEmailAddressLink: {
get cta () { return $(CHANGE_EMAIL_ADDRESS_LINK); }
get cta() { return $(CHANGE_EMAIL_ADDRESS_LINK); }
},
saveChangesButton: {
get cta () { return $(SAVE_CHANGES_BUTTON); }
get cta() { return $(SAVE_CHANGES_BUTTON); }
},
changePasswordButton: {
get cta () { return $(CHANGE_PASSWORD_BUTTON); }
get cta() { return $(CHANGE_PASSWORD_BUTTON); }
},
deleteAccountLink: {
get cta () { return $(DELETE_ACCOUNT_LINK); }
get cta() { return $(DELETE_ACCOUNT_LINK); }
}
};

fields = {
firstName: {
get input () { return $(FIELDS.firstName.input); },
get emptyError () { return $(FIELDS.firstName.emptyError); },
get invalidError () { return $(FIELDS.firstName.invalidError); }
get input() { return $(FIELDS.firstName.input); },
get emptyError() { return $(FIELDS.firstName.emptyError); },
get invalidError() { return $(FIELDS.firstName.invalidError); }
},
lastName: {
get input () { return $(FIELDS.lastName.input); },
get emptyError () { return $(FIELDS.lastName.emptyError); },
get invalidError () { return $(FIELDS.lastName.invalidError); }
get input() { return $(FIELDS.lastName.input); },
get emptyError() { return $(FIELDS.lastName.emptyError); },
get invalidError() { return $(FIELDS.lastName.invalidError); }
},
emailAddress: {
get input () { return $(FIELDS.emailAddress.input); }
get input() { return $(FIELDS.emailAddress.input); }
},
phoneNumber: {
get input () { return $(FIELDS.phoneNumber.input); },
get emptyError () { return $(FIELDS.phoneNumber.emptyError); },
get invalidError () { return $(FIELDS.phoneNumber.invalidError); }
get input() { return $(FIELDS.phoneNumber.input); },
get emptyError() { return $(FIELDS.phoneNumber.emptyError); },
get invalidError() { return $(FIELDS.phoneNumber.invalidError); }
},
addressLine1: {
get input () { return $(FIELDS.addressLine1.input); },
get emptyError () { return $(FIELDS.addressLine1.emptyError); }
get input() { return $(FIELDS.addressLine1.input); },
get emptyError() { return $(FIELDS.addressLine1.emptyError); }
},
addressLine2: {
get input () { return $(FIELDS.addressLine2.input); }
get input() { return $(FIELDS.addressLine2.input); }
},
addressLine3: {
get input () { return $(FIELDS.addressLine3.input); }
get input() { return $(FIELDS.addressLine3.input); }
},
city: {
get input () { return $(FIELDS.city.input); },
get emptyError () { return $(FIELDS.city.emptyError); }
get input() { return $(FIELDS.city.input); },
get emptyError() { return $(FIELDS.city.emptyError); }
},
postcode: {
get input () { return $(FIELDS.postcode.input); },
get emptyError () { return $(FIELDS.postcode.emptyError); },
get invalidError () { return $(FIELDS.postcode.invalidError); }
get input() { return $(FIELDS.postcode.input); },
get emptyError() { return $(FIELDS.postcode.emptyError); },
get invalidError() { return $(FIELDS.postcode.invalidError); }
}
};

async isErrorCardComponentDisplayed () {
async isErrorCardComponentDisplayed() {
return this.errorCardComponent.isDisplayed();
}

Expand All @@ -86,60 +86,59 @@ class AccountInfo extends Page {
*
* @param {String} fieldName The name of the field to tab out of
*/
async tabOutOfField (fieldName) {
const el = await this.fields[fieldName].input;
await el.keys(['Tab']);
async tabOutOfField() {
await browser.keys(['Tab']);
}

async clickOutOfInputField () {
async clickOutOfInputField() {
await this.component.click();
}

async clickSaveButton () {
async clickSaveButton() {
await this.LinksAndButtons.saveChangesButton.cta.click();
}

async clickChangePassword () {
async clickChangePassword() {
await this.LinksAndButtons.changePasswordButton.cta.click();
}

async clickDeleteAccountLink () {
async clickDeleteAccountLink() {
await this.LinksAndButtons.deleteAccountLink.cta.click();
}

async clickChangeEmailAddressLink () {
async clickChangeEmailAddressLink() {
await this.LinksAndButtons.changeEmailAddressLink.cta.click();
}

async isEmptyErrorMessageDisplayed (fieldName) {
async isEmptyErrorMessageDisplayed(fieldName) {
return this.fields[fieldName].emptyError.isDisplayed();
}

async isInvalidErrorMessageDisplayed (fieldName) {
async isInvalidErrorMessageDisplayed(fieldName) {
return this.fields[fieldName].invalidError.isDisplayed();
}

async canBeClicked (callToActionName) {
async canBeClicked(callToActionName) {
return this.LinksAndButtons[callToActionName].cta.isClickable();
}

async isDisabled (field) {
async isDisabled(field) {
return !await this.fields[field].input.isEnabled();
}

async isErrorAlertDisplayed () {
async isErrorAlertDisplayed() {
return this.errorAlert.isDisplayed();
}

async waitForErrorAlertDisplayed () {
async waitForErrorAlertDisplayed() {
await this.errorAlert.waitForDisplayed();
}

async isSuccessAlertDisplayed () {
async isSuccessAlertDisplayed() {
return this.successAlert.isDisplayed();
}

async waitForSuccessAlertDisplayed () {
async waitForSuccessAlertDisplayed() {
await this.successAlert.waitForDisplayed();
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/pages/f-mfa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@justeat/f-card-with-content": "3.x",
"@justeat/f-form-field": "6.x",
"@justeat/f-link": "3.x",
"@justeat/f-wdio-utils": "1.x",
"@justeat/f-wdio-utils": "1.3.0",
"@vue/cli-plugin-babel": "4.5.15"
},
"volta": {
Expand Down
8 changes: 4 additions & 4 deletions packages/services/f-wdio-utils/src/page.object.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ export default class Page {
const el = this.fields[fieldName].input;
el.waitForClickable();
el.click();
el.keys([CONTROL, 'a']);
browser.keys([CONTROL, 'a']);
el.waitUntil(() => {
return this.isSelected()
});
el.keys(['Backspace']);
browser.keys(['Backspace']);
el.waitUntil(() => {
return this.getText().length === 0
});
Expand All @@ -100,11 +100,11 @@ export default class Page {
const el = this.fields[fieldName].input;
(await el).waitForClickable();
(await el).click();
(await el).keys([CONTROL, 'a']);
(await browser).keys([CONTROL, 'a']);
(await el).waitUntil(async function () {
return (await this.isSelected())
});
(await el).keys(['Backspace']);
(await browser).keys(['Backspace']);
(await el).waitUntil(async function () {
return (await this.getText()).length === 0
});
Expand Down

0 comments on commit 207a90f

Please sign in to comment.