Skip to content

Commit 5316ed9

Browse files
authored
chore(ui5-date-picker, ui5-range-slider): use i18n bundle in tests instead of hardcoded strings (#13529)
fix(ui5-date-picker, ui5-range-slider): use i18n bundle in tests instead of hardcoded strings Replace hardcoded accessible name assertions with i18nBundle.getText() calls so tests remain stable across translation updates.
1 parent cdaa85b commit 5316ed9

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

packages/main/cypress/specs/DatePicker.cy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "../../src/Assets.js";
22
import { setLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
33
import DatePicker from "../../src/DatePicker.js";
44
import Label from "../../src/Label.js";
5+
import { DATEPICKER_POPOVER_ACCESSIBLE_NAME } from "../../src/generated/i18n/i18n-defaults.js";
56

67
describe("Date Picker Tests", () => {
78
it("input renders", () => {
@@ -1993,7 +1994,7 @@ describe("Accessibility", () => {
19931994
cy.get<DatePicker>("@datePicker")
19941995
.shadow()
19951996
.find("ui5-responsive-popover")
1996-
.should("have.attr", "accessible-name", `Choose Date for ${LABEL}`);
1997+
.should("have.attr", "accessible-name", DatePicker.i18nBundle.getText(DATEPICKER_POPOVER_ACCESSIBLE_NAME, LABEL));
19971998
});
19981999

19992000
it("picker popover accessible name", () => {
@@ -2009,7 +2010,7 @@ describe("Accessibility", () => {
20092010
cy.get<DatePicker>("@datePicker")
20102011
.shadow()
20112012
.find("ui5-responsive-popover")
2012-
.should("have.attr", "accessible-name", `Choose Date for ${LABEL}`);
2013+
.should("have.attr", "accessible-name", DatePicker.i18nBundle.getText(DATEPICKER_POPOVER_ACCESSIBLE_NAME, LABEL));
20132014
});
20142015

20152016
it("accessibleDescription property", () => {

packages/main/cypress/specs/RangeSlider.cy.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import RangeSlider from "../../src/RangeSlider.js";
2+
import { RANGE_SLIDER_START_HANDLE_DESCRIPTION, RANGE_SLIDER_END_HANDLE_DESCRIPTION } from "../../src/generated/i18n/i18n-defaults.js";
23

34
describe("Testing Range Slider interactions", () => {
45
it("Changing the current startValue is reflected", () => {
@@ -874,7 +875,7 @@ describe("Testing events", () => {
874875
const startValue = rangeSlider.startValue;
875876

876877
cy.get("@startHandle")
877-
.should("have.attr", "aria-label", "Left handle");
878+
.should("have.attr", "aria-label", RangeSlider.i18nBundle.getText(RANGE_SLIDER_START_HANDLE_DESCRIPTION));
878879

879880
cy.get("@startHandle")
880881
.should("have.attr", "aria-valuemin", `${minValue}`);
@@ -903,7 +904,7 @@ describe("Testing events", () => {
903904
const endValue = rangeSlider.endValue;
904905

905906
cy.get("@endHandle")
906-
.should("have.attr", "aria-label", "Right handle");
907+
.should("have.attr", "aria-label", RangeSlider.i18nBundle.getText(RANGE_SLIDER_END_HANDLE_DESCRIPTION));
907908

908909
cy.get("@endHandle")
909910
.should("have.attr", "aria-valuemin", `${minValue}`);
@@ -929,17 +930,17 @@ describe("Testing events", () => {
929930
.find("[ui5-slider-handle][handle-type='End']")
930931
.as("endHandle");
931932

932-
cy.get("@startHandle").should("have.attr", "aria-label", "Left handle");
933-
cy.get("@endHandle").should("have.attr", "aria-label", "Right handle");
933+
cy.get("@startHandle").should("have.attr", "aria-label", RangeSlider.i18nBundle.getText(RANGE_SLIDER_START_HANDLE_DESCRIPTION));
934+
cy.get("@endHandle").should("have.attr", "aria-label", RangeSlider.i18nBundle.getText(RANGE_SLIDER_END_HANDLE_DESCRIPTION));
934935

935936
// Drag start handle past end handle to swap values using real events
936937
cy.get("@startHandle")
937938
.realMouseDown()
938939
.realMouseMove(100, 0)
939940
.realMouseUp();
940941

941-
cy.get("@startHandle").should("have.attr", "aria-label", "Left handle");
942-
cy.get("@endHandle").should("have.attr", "aria-label", "Right handle");
942+
cy.get("@startHandle").should("have.attr", "aria-label", RangeSlider.i18nBundle.getText(RANGE_SLIDER_START_HANDLE_DESCRIPTION));
943+
cy.get("@endHandle").should("have.attr", "aria-label", RangeSlider.i18nBundle.getText(RANGE_SLIDER_END_HANDLE_DESCRIPTION));
943944
});
944945

945946
it("Click anywhere in the Range Slider should focus the closest handle", () => {
@@ -1811,12 +1812,12 @@ describe("Accessibility", () => {
18111812
cy.get("[ui5-range-slider]")
18121813
.shadow()
18131814
.find("[ui5-slider-handle][handle-type='Start']")
1814-
.should("have.attr", "aria-label", `${labelText} Left handle`);
1815+
.should("have.attr", "aria-label", `${labelText} ${RangeSlider.i18nBundle.getText(RANGE_SLIDER_START_HANDLE_DESCRIPTION)}`);
18151816

18161817
cy.get("[ui5-range-slider]")
18171818
.shadow()
18181819
.find("[ui5-slider-handle][handle-type='End']")
1819-
.should("have.attr", "aria-label", `${labelText} Right handle`);
1820+
.should("have.attr", "aria-label", `${labelText} ${RangeSlider.i18nBundle.getText(RANGE_SLIDER_END_HANDLE_DESCRIPTION)}`);
18201821
});
18211822

18221823
it("Aria attributes of the progress bar are set correctly", () => {

0 commit comments

Comments
 (0)