import * as React from 'react'; import { render, screen } from '@testing-library/react'; import { Page } from '../Page'; import { PageHeader } from '../../../deprecated/components/PageHeader'; import { PageSidebar } from '../PageSidebar'; import { PageSidebarBody } from '../PageSidebarBody'; import { PageSection } from '../PageSection'; import { Breadcrumb, BreadcrumbItem } from '../../Breadcrumb'; import { Nav, NavList, NavItem } from '../../Nav'; import { SkipToContent } from '../../SkipToContent'; import { PageBreadcrumb } from '../PageBreadcrumb'; import { PageNavigation } from '../PageNavigation'; import { PageGroup } from '../PageGroup'; const props = { 'aria-label': 'Page layout', id: 'PageId', className: 'my-page-class' }; describe('Page', () => { test('Check page vertical layout example against snapshot', () => { const Header = undefined} />; const Sidebar = ( Navigation ); const { asFragment } = render( Section with default background Section with light background Section with dark background Section with darker background ); expect(asFragment()).toMatchSnapshot(); }); test('Check dark page against snapshot', () => { const Header = undefined} />; const Sidebar = ( Navigation ); const { asFragment } = render( Section with default background Section with light background Section with dark background Section with darker background ); expect(asFragment()).toMatchSnapshot(); }); test('Check page horizontal layout example against snapshot', () => { const Header = ; const Sidebar = ; const { asFragment } = render( Section with default background Section with light background Section with dark background Section with darker background ); expect(asFragment()).toMatchSnapshot(); }); test('Check page to verify breadcrumb is created', () => { const Header = ; const Sidebar = ; const PageBreadcrumb = () => ( Section Home Section Title Section Title Section Landing ); const { asFragment } = render( }> Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Verify sticky top breadcrumb on all height breakpoints', () => { const Header = ; const Sidebar = ; const PageBreadcrumb = () => ( Section Home Section Title Section Title Section Landing ); const { asFragment } = render( } breadcrumbProps={{ stickyOnBreakpoint: { sm: 'top', md: 'top', lg: 'top', xl: 'top', '2xl': 'top' } }} > Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Verify sticky bottom breadcrumb on all height breakpoints', () => { const Header = ; const Sidebar = ; const PageBreadcrumb = () => ( Section Home Section Title Section Title Section Landing ); const { asFragment } = render( } breadcrumbProps={{ stickyOnBreakpoint: { sm: 'bottom', md: 'bottom', lg: 'bottom', xl: 'bottom', '2xl': 'bottom' } }} > Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Check page to verify breadcrumb is created - PageBreadcrumb syntax', () => { const Header = ; const Sidebar = ; const { asFragment } = render( Section Home Section Title Section Title Section Landing Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Verify sticky top breadcrumb on all height breakpoints - PageBreadcrumb syntax', () => { const Header = ; const Sidebar = ; const { asFragment } = render( Section Home Section Title Section Title Section Landing Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Sticky bottom breadcrumb on all height breakpoints - PageBreadcrumb syntax', () => { const Header = ; const Sidebar = ; const { asFragment } = render( Section Home Section Title Section Title Section Landing Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Check page to verify nav is created - PageNavigation syntax', () => { const Header = ; const Sidebar = ; const { asFragment } = render( Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Check page to verify grouped nav and breadcrumb - new components syntax', () => { const Header = ; const Sidebar = ; const { asFragment } = render( Section Home Section Title Section Title Section Landing Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(asFragment()).toMatchSnapshot(); }); test('Check page to verify grouped nav and breadcrumb - old / props syntax', () => { const Header = ; const Sidebar = ; const crumb = ( Section Home Section Title Section Title Section Landing ); const nav = ( ); const { asFragment } = render( Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).not.toHaveAttribute('id'); expect(screen.getByLabelText('test')).toHaveClass('pf-m-shadow-top'); expect(asFragment()).toMatchSnapshot(); }); test('Check page to verify skip to content points to main content region', () => { const Header = ; const Sidebar = ; const PageBreadcrumb = ( Section Home Section Title Section Title Section Landing ); const mainId = 'main-content-page-layout-test-nav'; const PageSkipToContent = Skip to Content; const { asFragment } = render( Section with default background Section with light background Section with dark background Section with darker background ); expect(screen.getByRole('main')).toHaveAttribute('id', mainId); expect(screen.getByTestId('page-test-id')).toHaveAttribute('id', props.id); expect(asFragment()).toMatchSnapshot(); }); });