Skip to content

Commit

Permalink
chore(flyout): test escape key down behavior with tooltip as content
Browse files Browse the repository at this point in the history
  • Loading branch information
weronikaolejniczak committed Nov 18, 2024
1 parent f74e9d4 commit 78816ee
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/eui/src/components/flyout/flyout.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import React, { useState } from 'react';
import { EuiGlobalToastList } from '../toast';
import { EuiHeader } from '../header';
import { EuiFlyout } from './flyout';
import { EuiToolTip } from '../tool_tip';
import { EuiText } from '../text';

const childrenDefault = (
<>
Expand Down Expand Up @@ -92,6 +94,33 @@ describe('EuiFlyout', () => {
});
});

describe('Close behavior: overlay elements as children', () => {
it('closes the flyout when the EuiToolTip is not focused', () => {
cy.mount(
<Flyout>
<EuiToolTip data-test-subj="tool_tip">
<EuiText>Hello World</EuiText>
</EuiToolTip>
</Flyout>
);
cy.realPress('Escape'); // Press Escape key to trigger close
cy.get('[data-test-subj="flyoutSpec"]').should('not.exist');
});

it('does not close the flyout when the EuiToolTip is focused', () => {
cy.mount(
<Flyout>
<EuiToolTip data-test-subj="tool_tip">
<EuiText>Hello World</EuiText>
</EuiToolTip>
</Flyout>
);
cy.get('[data-test-subj="tool_tip"]').focus(); // Focus the EuiToolTip
cy.realPress('Escape'); // Press Escape key to trigger close
cy.get('[data-test-subj="flyoutSpec"]').should('exist');
});
});

describe('Close behavior: outside clicks', () => {
// We're using toasts here to trigger outside clicks, as a UX case where
// we would generally expect toasts overlaid on top of a flyout *not* to close the flyout
Expand Down

0 comments on commit 78816ee

Please sign in to comment.