Skip to content

Commit 4cdf745

Browse files
committed
chore: fix flaky cypress tests
1 parent 93a9847 commit 4cdf745

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

cypress/component/Menu.cy.tsx

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,56 @@ describe('<Menu/>', () => {
280280
</Menu>
281281
</Menu>
282282
)
283+
cy.log(
284+
'[TEST] Starting: should show and focus flyout menu on space keyDown'
285+
)
283286

284-
cy.contains('Flyout').should('be.visible').focus().should('have.focus')
285-
286-
cy.focused().realPress('Space')
287+
cy.contains('Flyout')
288+
.focus()
289+
.then(($el) => {
290+
cy.log('[TEST] Flyout focused, element:', $el[0].outerHTML)
291+
cy.log(
292+
'[TEST] Active element before Space:',
293+
document.activeElement?.outerHTML || 'none'
294+
)
295+
})
296+
297+
cy.focused()
298+
.realPress('Space')
299+
.then(() => {
300+
cy.log('[TEST] Space key pressed')
301+
})
302+
303+
cy.wait(100).then(() => {
304+
cy.log('[TEST] After 100ms wait')
305+
cy.log(
306+
'[TEST] Active element after Space:',
307+
document.activeElement?.outerHTML || 'none'
308+
)
309+
const flyoutMenuItem = document.querySelector('[role="menuitem"]')
310+
cy.log(
311+
'[TEST] First menuitem found:',
312+
flyoutMenuItem?.outerHTML || 'none'
313+
)
314+
cy.log(
315+
'[TEST] Flyout Menu Item exists:',
316+
!!document.body.textContent?.includes('Flyout Menu Item')
317+
)
318+
})
287319

288-
cy.contains('Flyout Menu Item').should('exist').and('be.visible')
320+
cy.contains('Flyout Menu Item')
321+
.should('exist')
322+
.then(($el) => {
323+
cy.log('[TEST] Flyout Menu Item element found:', $el[0].outerHTML)
324+
})
289325

290326
cy.contains('Flyout Menu Item')
291327
.closest('[role="menuitem"]')
292-
.should('have.focus')
328+
.should('be.focused')
329+
.then(($el) => {
330+
cy.log('[TEST] Final focused element:', $el[0].outerHTML)
331+
cy.log('[TEST] Test completed successfully')
332+
})
293333
})
294334

295335
it(`should show and focus flyout menu on enter keyDown`, () => {

0 commit comments

Comments
 (0)