Skip to content

Commit aaad0fe

Browse files
authored
Scheduler: T1311967 — Error occurs when dateCellRender is specified and switching between pages (#31721)
1 parent 52c69c9 commit aaad0fe

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import * as testingLib from '@testing-library/react';
2+
import userEvent from '@testing-library/user-event';
3+
import * as React from 'react';
4+
import { Scheduler } from '../../../scheduler';
5+
6+
describe('Scheduler component', () => {
7+
beforeEach(() => {
8+
jest.useRealTimers();
9+
});
10+
11+
afterEach(() => {
12+
testingLib.cleanup();
13+
jest.useFakeTimers();
14+
});
15+
16+
it('T1311967: re-renders dateCellRender content after navigation', async () => {
17+
const currentDate = new Date(2025, 2, 28);
18+
const data = [
19+
{
20+
text: 'Test Appointment',
21+
startDate: new Date('2025-03-29T10:00:00'),
22+
endDate: new Date('2025-03-29T11:00:00'),
23+
},
24+
];
25+
26+
const user = userEvent.setup({ delay: null });
27+
28+
const dateCellRender = (cellData: any) => {
29+
const date = new Date(cellData.date);
30+
return <div className='custom-cell-marker'>Day {date.getDate()}</div>;
31+
};
32+
33+
testingLib.render(
34+
<Scheduler
35+
timeZone="America/Los_Angeles"
36+
dataSource={data}
37+
defaultCurrentView="week"
38+
defaultCurrentDate={currentDate}
39+
dateCellRender={dateCellRender}
40+
startDayHour={9}
41+
/>,
42+
);
43+
44+
await testingLib.waitFor(() => {
45+
const cells = document.querySelectorAll('.custom-cell-marker');
46+
const hasMarchDates = Array.from(cells).some((cell) => cell.textContent?.includes('Day 28') ?? cell.textContent?.includes('Day 29'));
47+
expect(hasMarchDates).toBe(true);
48+
});
49+
50+
const nextButton = await testingLib.waitFor(() => {
51+
const btn = document.querySelector('[aria-label="Next page"]') as HTMLElement;
52+
expect(btn).toBeDefined();
53+
return btn;
54+
});
55+
await user.click(nextButton);
56+
57+
await testingLib.waitFor(() => {
58+
const cells = document.querySelectorAll('.custom-cell-marker');
59+
const hasAprilDates = Array.from(cells).some((cell) => cell.textContent?.includes('Day 4') ?? cell.textContent?.includes('Day 5'));
60+
expect(hasAprilDates).toBe(true);
61+
});
62+
});
63+
});

0 commit comments

Comments
 (0)