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+ } ) ;
0 commit comments