From 207a90f2b71e78d07f07708d50eb00cf6e3b60d9 Mon Sep 17 00:00:00 2001 From: Ben Siggery Date: Wed, 15 Nov 2023 15:12:56 +0000 Subject: [PATCH] Attempt to fix f-account-info tests --- .../f-account-info.component.js | 87 +++++++++---------- packages/components/pages/f-mfa/package.json | 2 +- .../services/f-wdio-utils/src/page.object.js | 8 +- 3 files changed, 48 insertions(+), 49 deletions(-) diff --git a/packages/components/pages/f-account-info/test-utils/component-objects/f-account-info.component.js b/packages/components/pages/f-account-info/test-utils/component-objects/f-account-info.component.js index 2b9c9582bc..fe7f0e7150 100644 --- a/packages/components/pages/f-account-info/test-utils/component-objects/f-account-info.component.js +++ b/packages/components/pages/f-account-info/test-utils/component-objects/f-account-info.component.js @@ -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(); } @@ -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(); } } diff --git a/packages/components/pages/f-mfa/package.json b/packages/components/pages/f-mfa/package.json index 5060b4b4f2..32eb02342c 100644 --- a/packages/components/pages/f-mfa/package.json +++ b/packages/components/pages/f-mfa/package.json @@ -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": { diff --git a/packages/services/f-wdio-utils/src/page.object.js b/packages/services/f-wdio-utils/src/page.object.js index 796d68c430..15a21ec29a 100644 --- a/packages/services/f-wdio-utils/src/page.object.js +++ b/packages/services/f-wdio-utils/src/page.object.js @@ -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 }); @@ -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 });