Skip to content

Commit c13c556

Browse files
committed
test: fix failing e2e tests after HDS 5 upgrade
1 parent 1aa68fc commit c13c556

12 files changed

Lines changed: 39 additions & 46 deletions

File tree

src/common/components/form/fields/MultiDropdownField.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ const MultiDropdownField: React.FC<Props> = ({
3434
className,
3535
field: { name, onBlur, onChange, value, ...field },
3636
form: { errors, touched },
37+
clearButtonAriaLabel,
3738
helper,
3839
label,
3940
options,
4041
placeholder,
42+
selectedItemRemoveButtonAriaLabel,
4143
setFieldValue,
4244
texts,
4345
...rest
@@ -77,6 +79,9 @@ const MultiDropdownField: React.FC<Props> = ({
7779
{...field}
7880
texts={{
7981
assistive: helper,
82+
clearButtonAriaLabel_multiple: clearButtonAriaLabel,
83+
clearButtonAriaLabel_one: clearButtonAriaLabel,
84+
tagRemoveSelectionAriaLabel: selectedItemRemoveButtonAriaLabel,
8085
error: errorText,
8186
label,
8287
language: locale,

src/domain/app/i18n/en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,19 +488,19 @@
488488
"accessibility": {
489489
"audienceDropdown": {
490490
"clearButtonAriaLabel": "Delete all audience selections",
491-
"selectedItemRemoveButtonAriaLabel": "Delete audience selection"
491+
"selectedItemRemoveButtonAriaLabel": "Delete audience selection \"{{label}}\""
492492
},
493493
"categoryDropdown": {
494494
"clearButtonAriaLabel": "Delete all categories",
495-
"selectedItemRemoveButtonAriaLabel": "Delete category selection"
495+
"selectedItemRemoveButtonAriaLabel": "Delete category selection \"{{label}}\""
496496
},
497497
"activityDropdown": {
498498
"clearButtonAriaLabel": "Delete all activity selections",
499-
"selectedItemRemoveButtonAriaLabel": "Delete activity selection"
499+
"selectedItemRemoveButtonAriaLabel": "Delete activity selection \"{{label}}\""
500500
},
501501
"inLanguageDropdown": {
502502
"clearButtonAriaLabel": "Delete all language selections",
503-
"selectedItemRemoveButtonAriaLabel": "Delete language selection"
503+
"selectedItemRemoveButtonAriaLabel": "Delete language selection \"{{label}}\""
504504
}
505505
},
506506
"occurrences": {

src/domain/app/i18n/fi.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,19 +494,19 @@
494494
"accessibility": {
495495
"audienceDropdown": {
496496
"clearButtonAriaLabel": "Poista kaikki kohderyhmävalinnat",
497-
"selectedItemRemoveButtonAriaLabel": "Poista kohderyhmä"
497+
"selectedItemRemoveButtonAriaLabel": "Poista kohderyhmä \"{{label}}\""
498498
},
499499
"categoryDropdown": {
500500
"clearButtonAriaLabel": "Poista kaikki kategoriavalinnat",
501-
"selectedItemRemoveButtonAriaLabel": "Poista kategoriavalinta"
501+
"selectedItemRemoveButtonAriaLabel": "Poista kategoriavalinta \"{{label}}\""
502502
},
503503
"activityDropdown": {
504504
"clearButtonAriaLabel": "Poista kaikki aktiviteettivalinnat",
505-
"selectedItemRemoveButtonAriaLabel": "Poista aktiviteettivalinta"
505+
"selectedItemRemoveButtonAriaLabel": "Poista aktiviteettivalinta \"{{label}}\""
506506
},
507507
"inLanguageDropdown": {
508508
"clearButtonAriaLabel": "Poista kaikki kielivalinnat",
509-
"selectedItemRemoveButtonAriaLabel": "Poista kielivalinta"
509+
"selectedItemRemoveButtonAriaLabel": "Poista kielivalinta \"{{label}}\""
510510
}
511511
},
512512
"occurrences": {

src/domain/app/i18n/sv.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,19 +495,19 @@
495495
"accessibility": {
496496
"audienceDropdown": {
497497
"clearButtonAriaLabel": "Ta bort alla publikval",
498-
"selectedItemRemoveButtonAriaLabel": "Ta bort publikval"
498+
"selectedItemRemoveButtonAriaLabel": "Ta bort publikval \"{{label}}\""
499499
},
500500
"categoryDropdown": {
501501
"clearButtonAriaLabel": "Ta bort alla kategorier",
502-
"selectedItemRemoveButtonAriaLabel": "Ta bort kategorival"
502+
"selectedItemRemoveButtonAriaLabel": "Ta bort kategorival \"{{label}}\""
503503
},
504504
"activityDropdown": {
505505
"clearButtonAriaLabel": "Ta bort alla aktiviteter",
506-
"selectedItemRemoveButtonAriaLabel": "Ta bort aktivitet"
506+
"selectedItemRemoveButtonAriaLabel": "Ta bort aktivitet \"{{label}}\""
507507
},
508508
"inLanguageDropdown": {
509509
"clearButtonAriaLabel": "Ta bort alla språkval",
510-
"selectedItemRemoveButtonAriaLabel": "Ta bort språkval"
510+
"selectedItemRemoveButtonAriaLabel": "Ta bort språkval \"{{label}}\""
511511
}
512512
},
513513
"occurrences": {

src/domain/app/layout/__tests__/PageLayout.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ async function fillAndSubmitProfileForm() {
127127

128128
expect(
129129
screen.getByRole('button', {
130-
name: 'Poista valinta "Organisaatio 1".',
130+
name: 'Organisaatio 1',
131131
})
132132
).toBeInTheDocument();
133133
expect(
134134
screen.getByRole('button', {
135-
name: 'Poista valinta "Organisaatio 2".',
135+
name: 'Organisaatio 2',
136136
})
137137
).toBeInTheDocument();
138138

src/domain/event/__tests__/CreateEventPage.test.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,12 @@ const mocks = [
352352
];
353353

354354
const testMultiDropdownValues = async ({
355+
deleteButtonName,
355356
dropdownTestId,
356357
dropdownLabel,
357358
values,
358359
}: {
360+
deleteButtonName: (value: string) => string;
359361
dropdownTestId: string;
360362
dropdownLabel: RegExp | string;
361363
values: string[];
@@ -374,7 +376,9 @@ const testMultiDropdownValues = async ({
374376
const dropdown = within(await screen.findByTestId(dropdownTestId));
375377

376378
for (const value of values) {
377-
await dropdown.findByRole('button', { name: `Poista valinta "${value}".` });
379+
await dropdown.getByRole('button', {
380+
name: deleteButtonName(value),
381+
});
378382
}
379383
};
380384

@@ -480,18 +484,22 @@ const fillForm = async (eventFormData: typeof partialDefaultFormData) => {
480484
dropdownLabel: /kategoriat/i,
481485
dropdownTestId: 'categories-dropdown',
482486
values: categoryKeywords.map((k) => k.name),
487+
deleteButtonName: (value: string) => `Poista kategoriavalinta "${value}"`,
483488
});
484489

485490
await testMultiDropdownValues({
486491
dropdownLabel: /aktiviteetit/i,
487492
dropdownTestId: 'additional-criteria-dropdown',
488493
values: criteriaKeywords.map((k) => k.name),
494+
deleteButtonName: (value: string) =>
495+
`Poista aktiviteettivalinta "${value}"`,
489496
});
490497

491498
await testMultiDropdownValues({
492499
dropdownLabel: /kohderyhmät/i,
493500
dropdownTestId: 'audience-dropdown',
494501
values: audienceKeywords.map((k) => k.name),
502+
deleteButtonName: (value: string) => `Poista kohderyhmä "${value}"`,
495503
});
496504

497505
vi.spyOn(ApolloClient.prototype, 'readQuery').mockReturnValueOnce(

src/playwright/pages/authenticated.page.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ export class AuthenticatedPage extends BasePage {
4848
await this.userMenuButton(lang).click();
4949
}
5050

51-
async hasVisibleHeadingInUserMenuDropdown(name: string | RegExp) {
52-
await expect(
53-
this.userMenuDropdown.getByRole('heading', { name })
54-
).toBeVisible();
55-
}
56-
5751
async hasVisibleButtonInUserMenuDropdown(name: string | RegExp) {
5852
await expect(this.userMenuDropdownButton(name)).toBeVisible();
5953
}
@@ -160,7 +154,6 @@ export class AuthenticatedPage extends BasePage {
160154
await option.hover(); // Hover so that the option and the listbox change state
161155
const optionId = await option.getAttribute('id');
162156
expect(optionId).not.toBeNull();
163-
await expect(listBox).toHaveAttribute('aria-activedescendant', optionId!);
164157
await option.click();
165158
}
166159

src/playwright/pages/createEventBasicInfo.page.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,44 +270,38 @@ export class CreateEventBasicInfoPage extends AuthenticatedPage {
270270

271271
get targetGroupsDropdownButton() {
272272
return this.eventClassificationsSection
273-
.getByRole('button', {
273+
.getByRole('combobox', {
274274
name: this.t('targetGroups'),
275275
})
276276
.and(this.hasListBoxPopUp); // To distinguish from the selected tags
277277
}
278278

279279
get targetGroupsListBox() {
280-
return this.eventClassificationsSection.getByRole('listbox', {
281-
name: this.t('targetGroups'),
282-
});
280+
return this.eventClassificationsSection.getByRole('listbox');
283281
}
284282

285283
get categoriesDropdownButton() {
286284
return this.eventClassificationsSection
287-
.getByRole('button', {
285+
.getByRole('combobox', {
288286
name: this.t('categories'),
289287
})
290288
.and(this.hasListBoxPopUp); // To distinguish from the selected tags
291289
}
292290

293291
get categoriesListBox() {
294-
return this.eventClassificationsSection.getByRole('listbox', {
295-
name: this.t('categories'),
296-
});
292+
return this.eventClassificationsSection.getByRole('listbox');
297293
}
298294

299295
get activitiesDropdownButton() {
300296
return this.eventClassificationsSection
301-
.getByRole('button', {
297+
.getByRole('combobox', {
302298
name: this.t('activities'),
303299
})
304300
.and(this.hasListBoxPopUp); // To distinguish from the selected tags
305301
}
306302

307303
get activitiesListBox() {
308-
return this.eventClassificationsSection.getByRole('listbox', {
309-
name: this.t('activities'),
310-
});
304+
return this.eventClassificationsSection.getByRole('listbox');
311305
}
312306

313307
get eventKeywordsTextBox() {
@@ -351,15 +345,13 @@ export class CreateEventBasicInfoPage extends AuthenticatedPage {
351345
}
352346

353347
get contactPersonNameDropdownButton() {
354-
return this.contactPersonSection.getByRole('button', {
348+
return this.contactPersonSection.getByRole('combobox', {
355349
name: this.t('contactPersonName'),
356350
});
357351
}
358352

359353
get contactPersonNameListBox() {
360-
return this.contactPersonSection.getByRole('listbox', {
361-
name: this.t('contactPersonName'),
362-
});
354+
return this.contactPersonSection.getByRole('listbox');
363355
}
364356

365357
get emailTextBox() {

src/playwright/pages/createEventOccurrences.page.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,14 @@ export class CreateEventOccurrencesPage extends AuthenticatedPage {
509509

510510
get occurrenceLanguageDropdownButton() {
511511
return this.occurrencesForm
512-
.getByRole('button', {
512+
.getByRole('combobox', {
513513
name: this.t('occurrenceLanguage'),
514514
})
515515
.and(this.hasListBoxPopUp); // To distinguish from the selected tags
516516
}
517517

518518
get occurrenceLanguageListBox() {
519-
return this.occurrencesForm.getByRole('listbox', {
520-
name: this.t('occurrenceLanguage'),
521-
});
519+
return this.occurrencesForm.getByRole('listbox');
522520
}
523521

524522
get totalSeatsSpinButton() {

src/playwright/pages/myProfile.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class MyProfilePage extends AuthenticatedPage {
105105
}
106106

107107
get languageDropdownButton() {
108-
return this.mainContent.getByRole('button', {
108+
return this.mainContent.getByRole('combobox', {
109109
name: this.t('language'),
110110
});
111111
}

0 commit comments

Comments
 (0)