diff --git a/hivemq-edge/src/frontend/src/components/PageContainer.spec.cy.tsx b/hivemq-edge/src/frontend/src/components/PageContainer.spec.cy.tsx index 6ff73d570..29056b530 100644 --- a/hivemq-edge/src/frontend/src/components/PageContainer.spec.cy.tsx +++ b/hivemq-edge/src/frontend/src/components/PageContainer.spec.cy.tsx @@ -1,23 +1,37 @@ /// import PageContainer from './PageContainer.tsx' +import { Button } from '@chakra-ui/react' -const MOCK_STATUS_TEXT = 'This is a test' +const MOCK_HEADER = 'This is a test' +const MOCK_SUBHEADER = 'This is below the test' const MOCK_CONTENT =
This is a dummy component
+const MOCK_CTA = describe('PageContainer', () => { beforeEach(() => { - // run these tests as if in a desktop - // browser with a 720p monitor cy.viewport(800, 250) }) - it('should renders', () => { - cy.mountWithProviders({MOCK_CONTENT}) - // cy.get('.chakra-alert__title').should('contain.text', 'This is a test') - // cy.get('.chakra-alert__desc').should('contain.text', 'This is a title') - // cy.get("[role='alert']").should('have.attr', 'data-status', 'error') + + it('should render properly', () => { + cy.mountWithProviders( + + {MOCK_CONTENT} + + ) + cy.get('header h1').should('have.text', 'This is a test') + cy.get('header h1 + p').should('have.text', 'This is below the test') + cy.getByTestId('page-container-cta').find('button').should('have.text', 'Button') + cy.getByTestId('the-test-id').should('have.text', 'This is a dummy component') }) - it('should also render', () => { - cy.mountWithProviders({MOCK_CONTENT}) + it('should be accessible', () => { + cy.injectAxe() + cy.mountWithProviders( + Button}> + {MOCK_CONTENT} + + ) + + cy.checkAccessibility() }) }) diff --git a/hivemq-edge/src/frontend/src/components/PageContainer.tsx b/hivemq-edge/src/frontend/src/components/PageContainer.tsx index a166a182c..e793d4f0d 100644 --- a/hivemq-edge/src/frontend/src/components/PageContainer.tsx +++ b/hivemq-edge/src/frontend/src/components/PageContainer.tsx @@ -1,33 +1,22 @@ import { FC, ReactNode } from 'react' -import { useTranslation } from 'react-i18next' -import { Box, Text, Flex, Heading, VisuallyHidden, chakra as Chakra } from '@chakra-ui/react' +import { Box, Text, Flex, Heading, chakra as Chakra } from '@chakra-ui/react' interface PageContainerProps { - title?: string + title: string subtitle?: string children?: ReactNode cta?: ReactNode } const PageContainer: FC = ({ title, subtitle, children, cta }) => { - const { t } = useTranslation() - return ( - - - {title ? ( - title - ) : ( - -

{t('translation:navigation.mainPage')}

-
- )} -
+ + {title} {subtitle && {subtitle}} - + {cta}