Skip to content

Commit cdebce0

Browse files
committed
Include EuiCollapsibleNavBeta in flyout shards spec
1 parent 192efcc commit cdebce0

1 file changed

Lines changed: 46 additions & 8 deletions

File tree

packages/eui/src/components/flyout/flyout.spec.tsx

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import React, { useState } from 'react';
1414

1515
import { EuiGlobalToastList } from '../toast';
16-
import { EuiHeader } from '../header';
16+
import { EuiHeader, EuiHeaderSection } from '../header';
17+
import { EuiCollapsibleNavBeta } from '../collapsible_nav_beta';
1718
import { EuiFlyout } from './flyout';
1819

1920
const childrenDefault = (
@@ -171,18 +172,41 @@ describe('EuiFlyout', () => {
171172
});
172173

173174
describe('EuiHeader shards', () => {
174-
const FlyoutWithHeader = ({ children = childrenDefault, ...rest }) => {
175+
const FlyoutWithHeader = ({
176+
children = childrenDefault,
177+
showCollapsibleNav = false,
178+
...rest
179+
}) => {
175180
const [isOpen, setIsOpen] = useState(false);
176181

177182
return (
178183
<>
179184
<EuiHeader position="fixed">
180-
<button
181-
data-test-subj="toggleFlyoutFromHeader"
182-
onClick={() => setIsOpen(!isOpen)}
183-
>
184-
Toggle flyout
185-
</button>
185+
{showCollapsibleNav && (
186+
<EuiHeaderSection>
187+
<EuiCollapsibleNavBeta>
188+
<EuiCollapsibleNavBeta.Body>
189+
<EuiCollapsibleNavBeta.Item
190+
title="Items"
191+
isCollapsible={false}
192+
items={[
193+
{ title: 'Item A', href: '#' },
194+
{ title: 'Item B', href: '#' },
195+
{ title: 'Item C', href: '#' },
196+
]}
197+
/>
198+
</EuiCollapsibleNavBeta.Body>
199+
</EuiCollapsibleNavBeta>
200+
</EuiHeaderSection>
201+
)}
202+
<EuiHeaderSection>
203+
<button
204+
data-test-subj="toggleFlyoutFromHeader"
205+
onClick={() => setIsOpen(!isOpen)}
206+
>
207+
Toggle flyout
208+
</button>
209+
</EuiHeaderSection>
186210
</EuiHeader>
187211
{isOpen ? (
188212
<EuiFlyout
@@ -214,6 +238,20 @@ describe('EuiFlyout', () => {
214238
);
215239
});
216240

241+
it('includes collapsible nav items inside EuiHeaders shards', () => {
242+
cy.viewport(800, 600);
243+
cy.mount(<FlyoutWithHeader showCollapsibleNav> </FlyoutWithHeader>);
244+
cy.get('[data-test-subj="toggleFlyoutFromHeader"]').click();
245+
cy.repeatRealPress('Tab', 4);
246+
cy.focused().should('have.text', 'Item B');
247+
cy.repeatRealPress('Tab', 2);
248+
cy.focused().should(
249+
'have.attr',
250+
'data-test-subj',
251+
'toggleFlyoutFromHeader'
252+
);
253+
});
254+
217255
it('does not shard fixed headers if `includeFixedHeadersInFocusTrap` is set to false', () => {
218256
cy.mount(<FlyoutWithHeader includeFixedHeadersInFocusTrap={false} />);
219257
cy.get('[data-test-subj="toggleFlyoutFromHeader"]').click();

0 commit comments

Comments
 (0)