File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
apps/console/src/__tests__ Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff 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' , ( ) => {
You can’t perform that action at this time.
0 commit comments