@@ -32,34 +32,34 @@ describe('ExecutionNode', () => {
3232 expect ( screen . getByText ( 'train-step' ) ) . toBeInTheDocument ( ) ;
3333 } ) ;
3434
35- it ( 'renders with COMPLETE state and green background ' , ( ) => {
36- const { container } = renderWithProvider (
35+ it ( 'renders with COMPLETE state and correct icon ' , ( ) => {
36+ renderWithProvider (
3737 < ExecutionNode
3838 id = 'exec-1'
3939 data = { { label : 'completed-step' , state : Execution . State . COMPLETE } }
4040 /> ,
4141 ) ;
4242 expect ( screen . getByText ( 'completed-step' ) ) . toBeInTheDocument ( ) ;
43- expect ( container . querySelector ( '.bg-mui-green-50 ') ) . toBeInTheDocument ( ) ;
43+ expect ( screen . getByTestId ( 'CheckCircleIcon ') ) . toBeInTheDocument ( ) ;
4444 } ) ;
4545
46- it ( 'renders with RUNNING state and green background ' , ( ) => {
47- const { container } = renderWithProvider (
46+ it ( 'renders with RUNNING state and correct icon ' , ( ) => {
47+ renderWithProvider (
4848 < ExecutionNode
4949 id = 'exec-1'
5050 data = { { label : 'running-step' , state : Execution . State . RUNNING } }
5151 /> ,
5252 ) ;
5353 expect ( screen . getByText ( 'running-step' ) ) . toBeInTheDocument ( ) ;
54- expect ( container . querySelector ( '.bg-mui-green-50 ') ) . toBeInTheDocument ( ) ;
54+ expect ( screen . getByTestId ( 'RefreshIcon ') ) . toBeInTheDocument ( ) ;
5555 } ) ;
5656
57- it ( 'renders with FAILED state and red background ' , ( ) => {
58- const { container } = renderWithProvider (
57+ it ( 'renders with FAILED state and correct icon ' , ( ) => {
58+ renderWithProvider (
5959 < ExecutionNode id = 'exec-1' data = { { label : 'failed-step' , state : Execution . State . FAILED } } /> ,
6060 ) ;
6161 expect ( screen . getByText ( 'failed-step' ) ) . toBeInTheDocument ( ) ;
62- expect ( container . querySelector ( '.bg-mui-red-50 ') ) . toBeInTheDocument ( ) ;
62+ expect ( screen . getByTestId ( 'ErrorIcon ') ) . toBeInTheDocument ( ) ;
6363 } ) ;
6464
6565 it ( 'sets the title attribute' , ( ) => {
@@ -76,32 +76,32 @@ describe('getIcon', () => {
7676 } ) ;
7777
7878 it . each ( [
79- [ 'COMPLETE' , Execution . State . COMPLETE , '.bg-mui-green-50' , 'CheckCircleIcon' ] ,
80- [ 'RUNNING' , Execution . State . RUNNING , '.bg-mui-green-50' , 'RefreshIcon' ] ,
81- [ 'FAILED' , Execution . State . FAILED , '.bg-mui-red-50' , 'ErrorIcon' ] ,
82- [ 'NEW' , Execution . State . NEW , '.bg-mui-blue-50' , 'PowerSettingsNewIcon' ] ,
83- [ 'CANCELED' , Execution . State . CANCELED , '.bg-mui-grey-200' , undefined ] ,
84- [ 'CACHED' , Execution . State . CACHED , '.bg-mui-green-50' , 'CloudDownloadIcon' ] ,
85- [ 'UNKNOWN' , Execution . State . UNKNOWN , '.bg-mui-grey-200' , 'MoreHorizIcon' ] ,
86- ] as const ) ( 'returns the correct icon for %s state' , ( _label , state , bgClass , iconTestId ) => {
87- const { container } = render ( getIcon ( state ) ! ) ;
88- expect ( container . querySelector ( bgClass ) ) . toBeInTheDocument ( ) ;
89- if ( iconTestId ) {
90- expect ( container . querySelector ( `[data-testid="${ iconTestId } "]` ) ) . toBeInTheDocument ( ) ;
91- }
92- } ) ;
79+ [ 'COMPLETE' , Execution . State . COMPLETE , 'CheckCircleIcon' , 'bg-mui-green-50' ] ,
80+ [ 'RUNNING' , Execution . State . RUNNING , 'RefreshIcon' , 'bg-mui-green-50' ] ,
81+ [ 'FAILED' , Execution . State . FAILED , 'ErrorIcon' , 'bg-mui-red-50' ] ,
82+ [ 'NEW' , Execution . State . NEW , 'PowerSettingsNewIcon' , 'bg-mui-blue-50' ] ,
83+ [ 'CANCELED' , Execution . State . CANCELED , 'StopCircleIcon' , 'bg-mui-grey-200' ] ,
84+ [ 'CACHED' , Execution . State . CACHED , 'CloudDownloadIcon' , 'bg-mui-green-50' ] ,
85+ [ 'UNKNOWN' , Execution . State . UNKNOWN , 'MoreHorizIcon' , 'bg-mui-grey-200' ] ,
86+ ] as const ) (
87+ 'returns the correct icon for %s state' ,
88+ ( _label , state , iconTestId , backgroundClass ) => {
89+ render ( getIcon ( state ) ! ) ;
90+ const stateIcon = screen . getByTestId ( iconTestId ) ;
91+ expect ( stateIcon ) . toBeInTheDocument ( ) ;
92+ expect ( stateIcon . parentElement ) . toHaveClass ( backgroundClass ) ;
93+ } ,
94+ ) ;
9395} ) ;
9496
9597describe ( 'getExecutionIcon' , ( ) => {
96- it ( 'returns a grey ListAlt icon for undefined state' , ( ) => {
97- const { container } = render ( getExecutionIcon ( undefined ) ) ;
98- expect ( container . querySelector ( '.text-mui-grey-500' ) ) . toBeInTheDocument ( ) ;
99- expect ( container . querySelector ( '[data-testid="ListAltIcon"]' ) ) . toBeInTheDocument ( ) ;
98+ it ( 'returns a default ListAlt icon for undefined state' , ( ) => {
99+ render ( getExecutionIcon ( undefined ) ) ;
100+ expect ( screen . getByTestId ( 'execution-icon-default' ) ) . toBeInTheDocument ( ) ;
100101 } ) ;
101102
102- it ( 'returns a blue ListAlt icon for defined state' , ( ) => {
103- const { container } = render ( getExecutionIcon ( Execution . State . RUNNING ) ) ;
104- expect ( container . querySelector ( '.text-mui-blue-600' ) ) . toBeInTheDocument ( ) ;
105- expect ( container . querySelector ( '[data-testid="ListAltIcon"]' ) ) . toBeInTheDocument ( ) ;
103+ it ( 'returns an active ListAlt icon for defined state' , ( ) => {
104+ render ( getExecutionIcon ( Execution . State . RUNNING ) ) ;
105+ expect ( screen . getByTestId ( 'execution-icon-active' ) ) . toBeInTheDocument ( ) ;
106106 } ) ;
107107} ) ;
0 commit comments