Skip to content

Commit 73209c8

Browse files
committed
test: add stability check for ObjectCalendar schema re-renders
1 parent 2eaaf23 commit 73209c8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

apps/console/src/__tests__/PluginsIntegration.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,43 @@ describe('Plugins Integration Test', () => {
107107
});
108108
expect(screen.getByText('Task 2')).toBeInTheDocument();
109109
});
110+
111+
it('does not re-fetch data on stable schema re-renders', async () => {
112+
const schema = {
113+
type: 'calendar',
114+
objectName: 'todo_task',
115+
dateField: 'due_date',
116+
titleField: 'name'
117+
};
118+
119+
const { rerender } = render(
120+
<ObjectCalendar
121+
schema={schema as any}
122+
dataSource={mockDataSource as any}
123+
/>
124+
);
125+
126+
// Wait for initial fetch
127+
await waitFor(() => {
128+
expect(mockDataSource.find).toHaveBeenCalledTimes(1);
129+
});
130+
131+
// Re-render with a NEW schema object but IDENTICAL content
132+
// This tests if useMemo/useEffect are correctly handling deep equality or specific property dependencies
133+
// instead of just object reference equality.
134+
rerender(
135+
<ObjectCalendar
136+
schema={{ ...schema } as any}
137+
dataSource={mockDataSource as any}
138+
/>
139+
);
140+
141+
// Wait a bit to ensure no extra calls happen immediately
142+
await new Promise(resolve => setTimeout(resolve, 100));
143+
144+
// Should still only have called find once
145+
expect(mockDataSource.find).toHaveBeenCalledTimes(1);
146+
});
110147
});
111148

112149
describe('ObjectKanban', () => {

0 commit comments

Comments
 (0)