Skip to content

Commit 1145581

Browse files
authored
Use mocked date for locale tests (#17)
1 parent 433d2e6 commit 1145581

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

e2e/test/compatibility.cy.spec.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,30 @@ const TIMEOUT_MS = 40000;
9494
});
9595

9696
it("should load a moment locale", () => {
97+
const time = new Date('2025-01-01')
98+
cy.clock(time, ['Date'])
99+
97100
cy.visit({
98101
url: "/interactive-question?locale=es",
99102
});
100103

101104
cy.findByText('Filtro', {timeout: TIMEOUT_MS}).click();
102105
cy.get('[data-element-id="mantine-popover"]').within(() => {
103106
cy.findByText('Created At').click();
104-
cy.findByText(/(Fechas específicas|Rango de fechas fijo)/).click();
107+
// Different texts for 54 and 55
108+
cy.findByText(/(Fechas relativas|Rango de fechas relativo)/).click();
105109
})
106110

107111
cy.findByTestId('date-filter-picker').within(() => {
108-
const monthName = new Intl.DateTimeFormat('es-ES', { month: 'short' }).format(new Date());
109112

110-
cy.findByText(new RegExp(monthName, 'i')).should('exist');
113+
cy.findByText('dic. 2–31, 2024').should('exist');
111114
})
112115
});
113116

114117
it("should load a dayjs locale", () => {
118+
const time = new Date('2025-01-01')
119+
cy.clock(time, ['Date'])
120+
115121
cy.visit({
116122
url: "/interactive-question?locale=es",
117123
});
@@ -124,9 +130,7 @@ const TIMEOUT_MS = 40000;
124130
})
125131

126132
cy.findByTestId('date-filter-picker').within(() => {
127-
const monthName = new Intl.DateTimeFormat('es-ES', { month: 'long' }).format(new Date());
128-
129-
cy.findByText(new RegExp(monthName, 'i')).should('exist');
133+
cy.findByText('enero 2025').should('exist');
130134
})
131135
});
132136
});

0 commit comments

Comments
 (0)