Skip to content

Commit 68c6bca

Browse files
authored
feat(Status): Add Status component (#137)
1 parent e877107 commit 68c6bca

15 files changed

Lines changed: 1125 additions & 1083 deletions

File tree

cypress/component/Status.cy.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import * as React from 'react';
2+
import { ExclamationTriangleIcon, CheckCircleIcon, BanIcon } from '@patternfly/react-icons';
3+
import { Button, ButtonVariant, ButtonSize } from '@patternfly/react-core';
4+
import { IconStatus, Status, StatusVariant } from '../../packages/module/dist/dynamic/Status';
5+
6+
describe('Status', () => {
7+
8+
it('should render with label and icon', () => {
9+
cy.mount(<Status status={IconStatus.warning} label='Warning' icon={<ExclamationTriangleIcon/>} />);
10+
cy.get(`[data-ouia-component-id="Status-label"]`).should('be.visible');
11+
cy.get(`[data-ouia-component-id="Status-icon"]`).should('be.visible');
12+
});
13+
14+
it('should render with iconOnly', () => {
15+
cy.mount(<Status iconOnly status={IconStatus.warning} label='Warning' iconTitle='1 security issue found' icon={<ExclamationTriangleIcon/>} />);
16+
cy.get(`[data-ouia-component-id="Status-label"]`).should('not.exist');
17+
cy.get(`[data-ouia-component-id="Status-icon"]`).should('be.visible');
18+
});
19+
20+
it('should render link variant and handle click', () => {
21+
const handleClick = cy.stub().as('handleClick');
22+
cy.mount(<Status status={IconStatus.success} variant={StatusVariant.link} label='Ready' onClick={handleClick} icon={<CheckCircleIcon/>} />);
23+
cy.get(`[data-ouia-component-id="Status-label"]`).should('be.visible');
24+
cy.get(`[data-ouia-component-id="Status-icon"]`).should('be.visible');
25+
cy.get(`[data-ouia-component-id="Status-link-icon"]`).click();
26+
cy.get('@handleClick').should('have.been.calledOnce');
27+
28+
});
29+
30+
it('should render popover variant and handle open/close', () => {
31+
cy.mount(
32+
<Status
33+
status={IconStatus.danger}
34+
variant={StatusVariant.popover}
35+
label='Not Ready'
36+
icon={<BanIcon/>}
37+
popoverProps={{
38+
bodyContent: 'Example state description',
39+
footerContent: <Button size={ButtonSize.sm} variant={ButtonVariant.link} isInline>Action</Button>
40+
}}
41+
/>
42+
);
43+
cy.get(`[data-ouia-component-id="Status-label"]`).should('be.visible');
44+
cy.get(`[data-ouia-component-id="Status-icon"]`).should('be.visible');
45+
46+
cy.get(`[data-ouia-component-id="Status-popover-icon"]`).click();
47+
cy.get('[role="dialog"]').should('be.visible');
48+
cy.get('body').click(0, 0);
49+
cy.get('[role="dialog"]').should('not.exist');
50+
51+
});
52+
53+
it('should render with description', () => {
54+
cy.mount(<Status status={IconStatus.warning} label='Warning' description='1 issue found' icon={<ExclamationTriangleIcon/>} />);
55+
cy.get(`[data-ouia-component-id="Status-label"]`).should('be.visible');
56+
cy.get(`[data-ouia-component-id="Status-icon"]`).should('be.visible');
57+
cy.get(`[data-ouia-component-id="Status-description"]`).should('be.visible');
58+
});
59+
60+
});

cypress/e2e/CloseButton.spec.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ describe('Test the close button', () => {
22
it('passes', () => {
33
cy.visit('http://localhost:8006/extensions/component-groups/about-component-groups', { onBeforeLoad: (win) => {cy.stub(win.console, 'log').as('consoleLog');}, });
44
cy.wait(1000);
5-
cy.get('a[href="/extensions/component-groups/closebutton"]').click();
5+
cy.get('a[href="/extensions/component-groups/close-button"]').click();
66
cy.wait(1000);
77

88
cy.get('[data-test-id="close-button-example"]').click();

0 commit comments

Comments
 (0)