Skip to content

Commit

Permalink
Merge pull request #274 from shopware/next-29235/registration-forms
Browse files Browse the repository at this point in the history
fix: Change locators for accessibility changes in forms
  • Loading branch information
Phil23 authored Jan 20, 2025
2 parents 7abe2a2 + fe1942c commit f0745e9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/page-objects/StorefrontPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ export const test = base.extend<FixtureTypes>({
await use(new AccountRecover(StorefrontPage));
},

StorefrontAccountProfile: async ({ StorefrontPage }, use) => {
await use(new AccountProfile(StorefrontPage));
StorefrontAccountProfile: async ({ StorefrontPage, InstanceMeta }, use) => {
await use(new AccountProfile(StorefrontPage, InstanceMeta));
},

StorefrontAccountOrder: async ({ StorefrontPage }, use) => {
Expand Down
32 changes: 27 additions & 5 deletions src/page-objects/storefront/AccountProfile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Page, Locator } from '@playwright/test';
import type { PageObject } from '../../types/PageObject';
import { HelperFixtureTypes } from '../../fixtures/HelperFixtures';

export class AccountProfile implements PageObject {
public readonly salutationSelect: Locator;
Expand All @@ -26,7 +27,10 @@ export class AccountProfile implements PageObject {
public readonly emailUpdateFailureAlert: Locator;
public readonly passwordUpdateFailureAlert: Locator;

constructor(public readonly page: Page) {
constructor(
public readonly page: Page,
public readonly instanceMeta: HelperFixtureTypes['InstanceMeta']
) {
this.salutationSelect = page.getByLabel('Salutation');
this.firstNameInput = page.getByLabel('First name');
this.lastNameInput = page.getByLabel('Last name');
Expand All @@ -40,16 +44,34 @@ export class AccountProfile implements PageObject {

this.changePasswordButton = page.getByRole('button', { name: 'Change password' });
this.newPasswordInput = page.locator('input[id="newPassword"]');
this.newPasswordConfirmInput = page.locator('input[id="passwordConfirmation"]');
this.currentPasswordInput = page.locator('input[id="password"]');

if (instanceMeta.features['ACCESSIBILITY_TWEAKS']) {
this.newPasswordConfirmInput = page.locator('input[name="password[newPasswordConfirm]"]');
this.currentPasswordInput = page.locator('input[name="password[password]"]');
} else {
this.newPasswordConfirmInput = page.locator('input[id="passwordConfirmation"]');
this.currentPasswordInput = page.locator('input[id="password"]');
}

this.saveNewPasswordButton = page.locator('#profilePasswordForm').getByRole('button', { name: 'Save changes' });
this.loginDataEmailAddress = page.locator('.account-profile-mail');

this.emailUpdateMessage = page.getByText('Your email address has been updated.');
this.passwordUpdateMessage = page.getByText('Your password has been updated.');
this.emailValidationAlert = page.locator('.was-validated');

if (instanceMeta.features['ACCESSIBILITY_TWEAKS']) {
this.emailValidationAlert = page.getByText('Invalid email address.');
} else {
this.emailValidationAlert = page.locator('.was-validated');
}

this.emailUpdateFailureAlert = page.getByText('Email address could not be changed.');
this.passwordUpdateFailureAlert = page.getByText('Password could not be changed.');

if (instanceMeta.features['ACCESSIBILITY_TWEAKS']) {
this.passwordUpdateFailureAlert = page.getByText('Input is too short.');
} else {
this.passwordUpdateFailureAlert = page.getByText('Password could not be changed.');
}
}

url() {
Expand Down

0 comments on commit f0745e9

Please sign in to comment.