@@ -66,119 +66,5 @@ describe('InstanceDetails', () => {
6666 ) . not . toBeInTheDocument ( ) ;
6767 } ) ;
6868 } ) ;
69-
70- it ( 'should refetch metric index when instance version changes (SSE update)' , async ( ) => {
71- const application = new Application ( applications [ 0 ] ) ;
72- const instance1 = application . instances [ 0 ] ;
73-
74- const fetchMetricsSpy = vi
75- . fn ( )
76- . mockResolvedValue ( { data : { names : [ 'jvm.memory.max' ] } } ) ;
77- instance1 . fetchMetrics = fetchMetricsSpy ;
78- instance1 . hasEndpoint = vi . fn ( ) . mockImplementation ( ( ) => true ) ;
79-
80- const { rerender } = render ( DetailsView , {
81- props : {
82- instance : instance1 ,
83- application,
84- } ,
85- } ) ;
86-
87- await waitFor ( ( ) => {
88- expect ( fetchMetricsSpy ) . toHaveBeenCalledTimes ( 1 ) ;
89- } ) ;
90-
91- const instance2 = new Application ( {
92- ...application ,
93- instances : [
94- {
95- ...instance1 ,
96- id : instance1 . id ,
97- version : ( instance1 . version ?? 0 ) + 1 ,
98- } ,
99- ] ,
100- } ) . instances [ 0 ] ;
101-
102- instance2 . fetchMetrics = fetchMetricsSpy ;
103- instance2 . hasEndpoint = instance1 . hasEndpoint ;
104-
105- await rerender ( { instance : instance2 , application } ) ;
106-
107- await waitFor ( ( ) => {
108- expect ( fetchMetricsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
109- } ) ;
110- } ) ;
111-
112- it ( 'should ignore stale metric index response when instance updates quickly' , async ( ) => {
113- const application = new Application ( applications [ 0 ] ) ;
114- const instance1 = application . instances [ 0 ] ;
115-
116- const p1 = deferred < { data : { names : string [ ] } } > ( ) ;
117- const p2 = deferred < { data : { names : string [ ] } } > ( ) ;
118- const fetchMetricsSpy = vi
119- . fn ( )
120- . mockReturnValueOnce ( p1 . promise )
121- . mockReturnValueOnce ( p2 . promise ) ;
122- instance1 . fetchMetrics = fetchMetricsSpy ;
123- instance1 . hasEndpoint = vi . fn ( ) . mockImplementation ( ( ) => true ) ;
124-
125- const { rerender } = render ( DetailsView , {
126- global : {
127- stubs : {
128- 'details-memory' : {
129- props : [ 'instance' , 'type' ] ,
130- template : '<div data-testid="details-memory" />' ,
131- } ,
132- } ,
133- } ,
134- props : {
135- instance : instance1 ,
136- application,
137- } ,
138- } ) ;
139-
140- await waitFor ( ( ) => {
141- expect ( fetchMetricsSpy ) . toHaveBeenCalledTimes ( 1 ) ;
142- } ) ;
143-
144- const instance2 = new Application ( {
145- ...application ,
146- instances : [
147- {
148- ...instance1 ,
149- id : instance1 . id ,
150- version : ( instance1 . version ?? 0 ) + 1 ,
151- } ,
152- ] ,
153- } ) . instances [ 0 ] ;
154-
155- instance2 . fetchMetrics = fetchMetricsSpy ;
156- instance2 . hasEndpoint = instance1 . hasEndpoint ;
157-
158- await rerender ( { instance : instance2 , application } ) ;
159-
160- await waitFor ( ( ) => {
161- expect ( fetchMetricsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
162- } ) ;
163-
164- // Resolve second (newer) response first.
165- p2 . resolve ( { data : { names : [ 'jvm.memory.max' ] } } ) ;
166- await waitFor ( ( ) => {
167- expect (
168- screen . queryByTestId ( 'instance-section-loading-spinner' ) ,
169- ) . not . toBeInTheDocument ( ) ;
170- } ) ;
171-
172- // Memory sections should be present for the newer response.
173- await waitFor ( ( ) => {
174- expect ( screen . getAllByTestId ( 'details-memory' ) ) . toHaveLength ( 2 ) ;
175- } ) ;
176-
177- // Resolve first (older) response afterwards; UI must not regress.
178- p1 . resolve ( { data : { names : [ ] } } ) ;
179- await waitFor ( ( ) => {
180- expect ( screen . getAllByTestId ( 'details-memory' ) ) . toHaveLength ( 2 ) ;
181- } ) ;
182- } ) ;
18369 } ) ;
18470} ) ;
0 commit comments