diff --git a/cypress/component/Ansible.cy.tsx b/cypress/component/Ansible.cy.tsx new file mode 100644 index 00000000..997e5666 --- /dev/null +++ b/cypress/component/Ansible.cy.tsx @@ -0,0 +1,13 @@ +import React from 'react'; +import Ansible from '../../packages/module/dist/dynamic/Ansible'; + +describe('Ansible', () => { + it('renders supported Ansible', () => { + cy.mount() + cy.get('i').should('have.class', 'ansibleSupported-0-2-2'); + }); + it('renders unsupported Ansible', () => { + cy.mount() + cy.get('i').should('have.class', 'ansibleUnsupported-0-2-3'); + }); +}); \ No newline at end of file diff --git a/cypress/component/CloseButton.cy.tsx b/cypress/component/CloseButton.cy.tsx index 7b2c485c..e1523463 100644 --- a/cypress/component/CloseButton.cy.tsx +++ b/cypress/component/CloseButton.cy.tsx @@ -2,9 +2,15 @@ import React from 'react'; import CloseButton from '../../packages/module/dist/dynamic/CloseButton'; describe('CloseButton', () => { + /* eslint-disable no-console */ it('renders the Close button', () => { - /* eslint-disable no-console */ cy.mount({console.log('Close button clicked')}} style={{ float: 'none' }}/>) cy.get('[data-test-id="close-button-example"]').should('exist'); - }) + }); + it('should call callback on click', () => { + const onClickSpy = cy.spy().as('onClickSpy'); + cy.mount(); + cy.get('[data-test-id="close-button-example"]').click(); + cy.get('@onClickSpy').should('have.been.called'); + }); }) \ No newline at end of file diff --git a/cypress/component/ErrorBoundary.cy.tsx b/cypress/component/ErrorBoundary.cy.tsx new file mode 100644 index 00000000..8bf9cc44 --- /dev/null +++ b/cypress/component/ErrorBoundary.cy.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import ErrorBoundary from '../../packages/module/dist/dynamic/ErrorBoundary'; + +describe('ErrorBoundary', () => { + it('renders the ErrorBoundary ', () => { + cy.mount() + cy.get('div h1').should('have.text', 'Something wrong happened'); + }); +}) \ No newline at end of file diff --git a/cypress/component/ErrorState.cy.tsx b/cypress/component/ErrorState.cy.tsx new file mode 100644 index 00000000..2360d62b --- /dev/null +++ b/cypress/component/ErrorState.cy.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import ErrorState from '../../packages/module/dist/dynamic/ErrorState'; +import { ActionButton } from '../../packages/module/dist/dynamic/ActionButton' + +describe('ErrorState', () => { + it('renders the Close button', () => { + cy.mount(); + cy.get('h4').should('have.text', 'Sample error title'); + cy.get('div div div div div div').should('have.text', 'Sample error description'); + }); + + it('render with a custom footer', () => { + const onClickSpy = cy.spy().as('onClickSpy'); + cy.mount( + Custom action + }/>); + cy.get('button').should('exist'); + cy.get('button').click(); + cy.get('@onClickSpy').should('have.been.called'); + }) +}) \ No newline at end of file diff --git a/cypress/component/InvalidObject.cy.tsx b/cypress/component/InvalidObject.cy.tsx new file mode 100644 index 00000000..7e64dad5 --- /dev/null +++ b/cypress/component/InvalidObject.cy.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import InvalidObject from '../../packages/module/dist/dynamic/InvalidObject'; + +describe('InvalidObject', () => { + it('renders InvalidObject', () => { + cy.mount() + cy.get('[class="pf-v5-c-empty-state"]').should('exist') + cy.get('h1').should('have.text', 'We lost that page'); + }); +}) \ No newline at end of file diff --git a/cypress/component/LogSnippet.cy.tsx b/cypress/component/LogSnippet.cy.tsx new file mode 100644 index 00000000..b52ca3e5 --- /dev/null +++ b/cypress/component/LogSnippet.cy.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import LogSnippet from '../../packages/module/dist/dynamic/LogSnippet'; + +describe('LogSnippet', () => { + it('renders LogSnippet', () => { + cy.mount() + cy.get('div div p').should('have.text', 'A test message'); + cy.get('div div div div pre').should('have.text', 'test test code'); + }); +}); \ No newline at end of file diff --git a/cypress/component/MultiContentCard.cy.tsx b/cypress/component/MultiContentCard.cy.tsx new file mode 100644 index 00000000..8fda3142 --- /dev/null +++ b/cypress/component/MultiContentCard.cy.tsx @@ -0,0 +1,106 @@ +import React from 'react'; +import MultiContentCard from "@patternfly/react-component-groups/dist/dynamic/MultiContentCard"; +import { Button, Card, CardHeader, CardBody, Text, TextContent, TextVariants, Icon, TextList, TextListItem, CardFooter } from '@patternfly/react-core'; +import { ArrowRightIcon, BellIcon, CogIcon, LockIcon } from '@patternfly/react-icons'; + +const cards = [ + + + + Getting Started + + + + + + + + + Configure application + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + + + + + + + + + + + + + + + + + + + , + + + + + + + + Configure access + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + + + + + + + + + , + + + + Next Steps + + + + + + + + + Configure notifications + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + + + + + + + + + +]; + +const MultiContentCardExample: React.FunctionComponent = () => ; + +describe('MultiContentCard', () => { + it('renders MultiContentCard', () => { + cy.mount(); + cy.get('[class="pf-v5-c-card pf-m-expanded"').should('exist'); + }); +}); diff --git a/cypress/component/NotAuthorized.cy.tsx b/cypress/component/NotAuthorized.cy.tsx new file mode 100644 index 00000000..51269f3a --- /dev/null +++ b/cypress/component/NotAuthorized.cy.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { Button } from '@patternfly/react-core'; +import NotAuthorized from '../../packages/module/dist/dynamic/NotAuthorized'; + +describe('NotAuthorized', () => { + it('renders basic NotAuthorized', () => { + cy.mount(); + cy.get('div div div h5').should('have.text', 'You do not have access to Test bundle'); + cy.get('[class="pf-v5-c-empty-state__body"').should('have.text', 'Test text'); + }); + + it('renders NotAuthorized with custom action buttons', () => { + const onClickSpy = cy.spy().as('onClickSpy'); + const primaryAction = + ; + const customNotAuthorized = + cy.mount(customNotAuthorized); + const customButton = cy.get('div div div div button') + customButton.should('exist'); + customButton.should('have.text', 'Custom primary action'); + customButton.click(); + cy.get('@onClickSpy').should('have.been.called'); + }); +}); \ No newline at end of file diff --git a/cypress/component/ShortcutGrid.cy.tsx b/cypress/component/ShortcutGrid.cy.tsx new file mode 100644 index 00000000..fa242a5f --- /dev/null +++ b/cypress/component/ShortcutGrid.cy.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import ShortcutGrid from '../../packages/module/dist/dynamic/ShortcutGrid'; + +describe('ShortcutGrid', () => { + it('renders ShortcutGrid', () => { + const shortCutGridExample = + cy.mount(shortCutGridExample); + cy.get('[class="pf-v5-l-grid pf-m-all-6-col pf-m-gutter"]').should('exist'); + cy.get('div div').should('have.text', '⌘ Cmd + ⇧ Shift + TOpen new tab⌥ Opt + NOpen new page^ Ctrl + DragMove object⌘ Cmd + ⇧ Shift + T⌘ Cmd⇧ ShiftTOpen new tab⌥ Opt + N⌥ OptNOpen new page^ Ctrl + Drag^ Ctrl DragMove object'); + }); +}) \ No newline at end of file diff --git a/cypress/component/SkeletonTable.cy.tsx b/cypress/component/SkeletonTable.cy.tsx new file mode 100644 index 00000000..411ebfd8 --- /dev/null +++ b/cypress/component/SkeletonTable.cy.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import SkeletonTable from '../../packages/module/dist/dynamic/SkeletonTable'; + +describe('SkeletonTable', () => { + it('renders SkeletonTable', () => { + const SkeletonTableExample = ; + cy.mount(SkeletonTableExample); + cy.get('table').should('exist'); + cy.get('table thead tr').should('have.text', 'firstsecond'); + }); +}) \ No newline at end of file diff --git a/cypress/component/TagCount.cy.tsx b/cypress/component/TagCount.cy.tsx new file mode 100644 index 00000000..40d68032 --- /dev/null +++ b/cypress/component/TagCount.cy.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import TagCount from '../../packages/module/dist/dynamic/TagCount'; + +describe('TagCount', () => { + it('renders TagCount', () => { + cy.mount() + cy.get('button').should('exist'); + cy.get('button span').should('have.text', '50'); + }); + + it('render disabled', () => { + cy.mount() + cy.get('button').should('be.disabled'); + }); +}); \ No newline at end of file diff --git a/cypress/component/UnavailableContent.cy.tsx b/cypress/component/UnavailableContent.cy.tsx new file mode 100644 index 00000000..93fb19bf --- /dev/null +++ b/cypress/component/UnavailableContent.cy.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import UnavailableContent from '../../packages/module/dist/dynamic/UnavailableContent'; + +describe('UnavailableContent', () => { + it('renders UnavailableContent', () => { + cy.mount() + cy.get('[class="pf-v5-c-empty-state__content"').should('exist'); + cy.get('div div div h5').should('have.text', 'This page is temporarily unavailable'); + cy.get('[class="pf-v5-c-empty-state__body"').should('have.text', 'Try refreshing the page. If the problem persists, contact your organization administrator or visit our status page for known outages.'); + }); +}); \ No newline at end of file diff --git a/cypress/component/WarningModal.cy.tsx b/cypress/component/WarningModal.cy.tsx new file mode 100644 index 00000000..dcc57a09 --- /dev/null +++ b/cypress/component/WarningModal.cy.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { Button } from '@patternfly/react-core'; +import WarningModal from '../../packages/module/dist/dynamic/WarningModal'; + +const BasicModal: React.FunctionComponent = () => { + const [ isOpen, setIsOpen ] = React.useState(false); + return <> + + setIsOpen(false)} + onConfirm={() => setIsOpen(false)}> + Your page contains unsaved changes. Do you want to leave? + + +}; + +describe('WarningModal', () => { + it('renders WarningModal', () => { + cy.mount() + cy.get('button').click(); + cy.get('[class="pf-v5-c-modal-box pf-m-warning pf-m-sm"').should('exist'); + cy.get('div header h1 span').should('have.text', 'Warning alert:Unsaved changes'); + }); +}); \ No newline at end of file