Skip to content

Commit 937c6e1

Browse files
tests fix (working locally)
1 parent 5ee4bbc commit 937c6e1

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/components/ControlPlane/ManagedResources.cy.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,15 @@ describe('ManagedResources - Delete Resource', () => {
205205
});
206206

207207
describe('ManagedResources - Edit Resource', () => {
208-
const state = {
209-
patchHandlerCreated: false,
210-
patchCalled: false,
211-
patchedItem: null as any,
212-
};
208+
let patchHandlerCreated = false;
209+
let patchCalled = false;
210+
let patchedItem: any = null;
213211

214212
const fakeUseHandleResourcePatch: typeof useHandleResourcePatch = () => {
215-
state.patchHandlerCreated = true;
213+
patchHandlerCreated = true;
216214
return async (item: any) => {
217-
state.patchCalled = true;
218-
state.patchedItem = item;
215+
patchCalled = true;
216+
patchedItem = item;
219217
return true;
220218
};
221219
};
@@ -284,9 +282,9 @@ describe('ManagedResources - Edit Resource', () => {
284282
});
285283

286284
beforeEach(() => {
287-
state.patchHandlerCreated = false;
288-
state.patchCalled = false;
289-
state.patchedItem = null;
285+
patchHandlerCreated = false;
286+
patchCalled = false;
287+
patchedItem = null;
290288
});
291289

292290
it('opens edit panel and can apply changes', () => {
@@ -305,7 +303,7 @@ describe('ManagedResources - Edit Resource', () => {
305303
);
306304

307305
// Verify patch handler was initialized
308-
cy.then(() => cy.wrap(state.patchHandlerCreated).should('equal', true));
306+
cy.then(() => cy.wrap(patchHandlerCreated).should('equal', true));
309307

310308
// Expand resource group
311309
cy.get('button[aria-label*="xpand"]').first().click({ force: true });
@@ -318,9 +316,6 @@ describe('ManagedResources - Edit Resource', () => {
318316
// Verify YAML panel opened
319317
cy.contains('YAML').should('be.visible');
320318

321-
// Verify patch not called yet
322-
cy.then(() => cy.wrap(state.patchCalled).should('equal', false));
323-
324319
// Click Apply button
325320
cy.get('[data-testid="yaml-apply-button"]').should('be.visible').click();
326321

@@ -330,8 +325,8 @@ describe('ManagedResources - Edit Resource', () => {
330325
// Wait for success message
331326
cy.contains('Update submitted', { timeout: 10000 }).should('be.visible');
332327

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');
328+
// Verify patch was called
329+
cy.then(() => cy.wrap(patchCalled).should('equal', true));
330+
cy.then(() => cy.wrap(patchedItem).should('not.be.null'));
336331
});
337332
});

0 commit comments

Comments
 (0)