@@ -4,6 +4,8 @@ import { screen } from "@testing-library/react";
44import { Schema_Event } from "@core/types/event.types" ;
55import { createStoreWithEvents } from "@web/__tests__/utils/state/store.test.util" ;
66import { compareEventsByStartDate } from "@web/common/utils/event/event.util" ;
7+ import { selectIsDayEventsProcessing } from "@web/ducks/events/selectors/event.selectors" ;
8+ import { eventsEntitiesSlice } from "@web/ducks/events/slices/event.slice" ;
79import { Agenda } from "@web/views/Day/components/Agenda/Agenda" ;
810import { renderWithDayProviders } from "@web/views/Day/util/day.test-util" ;
911import { useOpenEventForm } from "@web/views/Forms/hooks/useOpenEventForm" ;
@@ -14,10 +16,23 @@ jest.mock("@web/auth/auth.util", () => ({
1416
1517jest . mock ( "@web/views/Forms/hooks/useOpenEventForm" ) ;
1618
19+ jest . mock ( "@web/ducks/events/selectors/event.selectors" , ( ) => {
20+ const actual = jest . requireActual (
21+ "@web/ducks/events/selectors/event.selectors" ,
22+ ) ;
23+ return {
24+ ...actual ,
25+ selectIsDayEventsProcessing : jest . fn ( ) ,
26+ } ;
27+ } ) ;
28+
1729const renderAgenda = (
1830 events : Schema_Event [ ] = [ ] ,
1931 options ?: { isProcessing ?: boolean } ,
2032) => {
33+ ( selectIsDayEventsProcessing as jest . Mock ) . mockReturnValue (
34+ options ?. isProcessing ?? false ,
35+ ) ;
2136 const store = createStoreWithEvents ( events , options ) ;
2237 const utils = renderWithDayProviders ( < Agenda /> , { store } ) ;
2338 return { ...utils , store } ;
@@ -84,6 +99,54 @@ describe("CalendarAgenda", () => {
8499 expect ( skeleton ) . toBeInTheDocument ( ) ;
85100 } ) ;
86101
102+ it ( "should show progress line on subsequent loads after first load" , async ( ) => {
103+ const mockEvents : Schema_Event [ ] = [
104+ {
105+ _id : "event-1" ,
106+ title : "Test Event" ,
107+ startDate : "2024-01-15T10:00:00Z" ,
108+ endDate : "2024-01-15T11:00:00Z" ,
109+ isAllDay : false ,
110+ } ,
111+ ] ;
112+
113+ // First render with events loaded (not processing)
114+ const { store } = renderAgenda ( mockEvents , { isProcessing : false } ) ;
115+
116+ // Verify initial load shows events, not skeleton or progress line
117+ expect ( await screen . findByText ( "Test Event" ) ) . toBeInTheDocument ( ) ;
118+ expect ( screen . queryByTestId ( "agenda-skeleton" ) ) . not . toBeInTheDocument ( ) ;
119+ expect (
120+ screen . queryByTestId ( "loading-progress-line" ) ,
121+ ) . not . toBeInTheDocument ( ) ;
122+
123+ // Dispatch request action to simulate reload
124+ act ( ( ) => {
125+ ( selectIsDayEventsProcessing as jest . Mock ) . mockReturnValue ( true ) ;
126+ store . dispatch (
127+ eventsEntitiesSlice . actions . edit ( {
128+ _id : "event-1" ,
129+ event : {
130+ ...mockEvents [ 0 ] ,
131+ title : "Updated Title" ,
132+ startDate : mockEvents [ 0 ] . startDate ! ,
133+ endDate : mockEvents [ 0 ] . endDate ! ,
134+ user : "user-123" ,
135+ priority : "high" ,
136+ origin : "google" ,
137+ } as any ,
138+ } ) ,
139+ ) ;
140+ } ) ;
141+
142+ // On subsequent load after component has loaded once,
143+ // should show progress line not skeleton
144+ expect (
145+ await screen . findByTestId ( "loading-progress-line" ) ,
146+ ) . toBeInTheDocument ( ) ;
147+ expect ( screen . queryByTestId ( "agenda-skeleton" ) ) . not . toBeInTheDocument ( ) ;
148+ } ) ;
149+
87150 it ( "should not show skeleton or error when events are loaded" , async ( ) => {
88151 const mockEvents : Schema_Event [ ] = [
89152 {
0 commit comments