@@ -205,15 +205,17 @@ describe('ManagedResources - Delete Resource', () => {
205205} ) ;
206206
207207describe ( 'ManagedResources - Edit Resource' , ( ) => {
208- let patchHandlerCreated = false ;
209- let patchCalled = false ;
210- let patchedItem : any = null ;
208+ const state = {
209+ patchHandlerCreated : false ,
210+ patchCalled : false ,
211+ patchedItem : null as any ,
212+ } ;
211213
212214 const fakeUseHandleResourcePatch : typeof useHandleResourcePatch = ( ) => {
213- patchHandlerCreated = true ;
215+ state . patchHandlerCreated = true ;
214216 return async ( item : any ) => {
215- patchCalled = true ;
216- patchedItem = item ;
217+ state . patchCalled = true ;
218+ state . patchedItem = item ;
217219 return true ;
218220 } ;
219221 } ;
@@ -271,11 +273,9 @@ describe('ManagedResources - Edit Resource', () => {
271273
272274 before ( ( ) => {
273275 cy . on ( 'uncaught:exception' , ( err ) => {
274- // Ignore Monaco Editor errors
275276 if ( err . message . includes ( 'TextModel got disposed' ) ) {
276277 return false ;
277278 }
278- // Ignore DiffEditorWidget errors
279279 if ( err . message . includes ( 'DiffEditorWidget' ) ) {
280280 return false ;
281281 }
@@ -284,9 +284,9 @@ describe('ManagedResources - Edit Resource', () => {
284284 } ) ;
285285
286286 beforeEach ( ( ) => {
287- patchHandlerCreated = false ;
288- patchCalled = false ;
289- patchedItem = null ;
287+ state . patchHandlerCreated = false ;
288+ state . patchCalled = false ;
289+ state . patchedItem = null ;
290290 } ) ;
291291
292292 it ( 'opens edit panel and can apply changes' , ( ) => {
@@ -305,7 +305,7 @@ describe('ManagedResources - Edit Resource', () => {
305305 ) ;
306306
307307 // Verify patch handler was initialized
308- cy . then ( ( ) => cy . wrap ( patchHandlerCreated ) . should ( 'equal' , true ) ) ;
308+ cy . then ( ( ) => cy . wrap ( state . patchHandlerCreated ) . should ( 'equal' , true ) ) ;
309309
310310 // Expand resource group
311311 cy . get ( 'button[aria-label*="xpand"]' ) . first ( ) . click ( { force : true } ) ;
@@ -319,7 +319,7 @@ describe('ManagedResources - Edit Resource', () => {
319319 cy . contains ( 'YAML' ) . should ( 'be.visible' ) ;
320320
321321 // Verify patch not called yet
322- cy . then ( ( ) => cy . wrap ( patchCalled ) . should ( 'equal' , false ) ) ;
322+ cy . then ( ( ) => cy . wrap ( state . patchCalled ) . should ( 'equal' , false ) ) ;
323323
324324 // Click Apply button
325325 cy . get ( '[data-testid="yaml-apply-button"]' ) . should ( 'be.visible' ) . click ( ) ;
@@ -330,10 +330,8 @@ describe('ManagedResources - Edit Resource', () => {
330330 // Wait for success message
331331 cy . contains ( 'Update submitted' , { timeout : 10000 } ) . should ( 'be.visible' ) ;
332332
333- // Verify patch was called
334- cy . then ( ( ) => {
335- cy . wrap ( patchCalled ) . should ( 'equal' , true ) ;
336- cy . wrap ( patchedItem ) . should ( 'not.be.null' ) ;
337- } ) ;
333+ // Verify patch was called - use should callback to access current value
334+ cy . wrap ( state ) . its ( 'patchCalled' ) . should ( 'equal' , true ) ;
335+ cy . wrap ( state ) . its ( 'patchedItem' ) . should ( 'not.be.null' ) ;
338336 } ) ;
339- } ) ;
337+ } ) ;
0 commit comments