Skip to content

Commit 3cb60da

Browse files
Chat: fix unstable tests with day headers (#28289)
1 parent 07e9ed7 commit 3cb60da

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

e2e/testcafe-devextreme/tests/chat/errorList.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ test.clientScripts([
8888
height: 600,
8989
errors: [{ id: 1, message: 'Error Message 1. Error Description...' }],
9090
});
91-
// eslint-disable-next-line @typescript-eslint/require-await
9291
}).after(async () => {
9392
await ClientFunction(() => {
9493
(window as any).MockDate.reset();
Binary file not shown.

e2e/testcafe-devextreme/tests/chat/messageList.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ test('Messagelist should scrolled to the latest messages after being rendered in
152152
});
153153
});
154154

155-
test('Messagelist with date headers', async (t) => {
155+
test.clientScripts([
156+
{ module: 'mockdate' },
157+
{ content: 'window.MockDate = MockDate;' },
158+
])('Messagelist with date headers', async (t) => {
156159
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
157160

158161
await testScreenshot(t, takeScreenshot, 'Messagelist with date headers.png', { element: '#container' });
@@ -161,10 +164,14 @@ test('Messagelist with date headers', async (t) => {
161164
.expect(compareResults.isValid())
162165
.ok(compareResults.errorMessages());
163166
}).before(async () => {
167+
await ClientFunction(() => {
168+
(window as any).MockDate.set('2024/10/27');
169+
})();
170+
164171
const userFirst = createUser(1, 'First');
165172
const userSecond = createUser(2, 'Second');
166173
const msInDay = 86400000;
167-
const today = new Date().setHours(7, 22, 0, 0);
174+
const today = new Date('2024/10/27').setHours(7, 22, 0, 0);
168175
const yesterday = today - msInDay;
169176

170177
const items = [{
@@ -195,6 +202,10 @@ test('Messagelist with date headers', async (t) => {
195202
width: 400,
196203
height: 600,
197204
});
205+
}).after(async () => {
206+
await ClientFunction(() => {
207+
(window as any).MockDate.reset();
208+
})();
198209
});
199210

200211
test('Messagelist with messageTemplate', async (t) => {

0 commit comments

Comments
 (0)