@@ -7,7 +7,20 @@ import ConfigurationCard, { ConfigurationCardProps } from './ConfigurationCard'
77
88const mockedProps = mock < ConfigurationCardProps > ( )
99
10+ const mockUseSelector = jest . fn ( )
11+ jest . mock ( 'react-redux' , ( ) => ( {
12+ ...jest . requireActual ( 'react-redux' ) ,
13+ useSelector : ( ) => mockUseSelector ( ) ,
14+ } ) )
15+
1016describe ( 'ConfigurationCard' , ( ) => {
17+ beforeEach ( ( ) => {
18+ mockUseSelector . mockReturnValue ( {
19+ changes : { } ,
20+ configValidationErrors : [ ] ,
21+ } )
22+ } )
23+
1124 it ( 'should render with correct title' , ( ) => {
1225 render ( < ConfigurationCard { ...instance ( mockedProps ) } /> )
1326
@@ -49,4 +62,92 @@ describe('ConfigurationCard', () => {
4962 expect ( card ) . toHaveAttribute ( 'tabIndex' , '0' )
5063 expect ( card ) . toHaveAttribute ( 'role' , 'button' )
5164 } )
65+
66+ describe ( 'Changes indicator' , ( ) => {
67+ it ( 'should not show changes indicator when no changes' , ( ) => {
68+ mockUseSelector . mockReturnValue ( {
69+ changes : { } ,
70+ configValidationErrors : [ ] ,
71+ } )
72+
73+ render ( < ConfigurationCard { ...instance ( mockedProps ) } /> )
74+
75+ expect (
76+ screen . queryByTestId ( 'updated-configuration-highlight' ) ,
77+ ) . not . toBeInTheDocument ( )
78+ } )
79+
80+ it ( 'should show changes indicator when config has changes' , ( ) => {
81+ mockUseSelector . mockReturnValue ( {
82+ changes : { config : 'modified' } ,
83+ configValidationErrors : [ ] ,
84+ } )
85+
86+ render ( < ConfigurationCard { ...instance ( mockedProps ) } /> )
87+
88+ expect (
89+ screen . getByTestId ( 'updated-configuration-highlight' ) ,
90+ ) . toBeInTheDocument ( )
91+ } )
92+ } )
93+
94+ describe ( 'Validation errors' , ( ) => {
95+ it ( 'should not show error icon when config is valid' , ( ) => {
96+ mockUseSelector . mockReturnValue ( {
97+ changes : { } ,
98+ configValidationErrors : [ ] ,
99+ } )
100+
101+ render ( < ConfigurationCard { ...instance ( mockedProps ) } /> )
102+
103+ expect (
104+ screen . queryByTestId ( 'rdi-pipeline-nav__error-configuration' ) ,
105+ ) . not . toBeInTheDocument ( )
106+ } )
107+
108+ it ( 'should show error icon when config has validation errors' , ( ) => {
109+ mockUseSelector . mockReturnValue ( {
110+ changes : { } ,
111+ configValidationErrors : [
112+ 'Invalid configuration' ,
113+ 'Missing required field' ,
114+ ] ,
115+ } )
116+
117+ render ( < ConfigurationCard { ...instance ( mockedProps ) } /> )
118+
119+ expect (
120+ screen . getByTestId ( 'rdi-pipeline-nav__error-configuration' ) ,
121+ ) . toBeInTheDocument ( )
122+ } )
123+
124+ it ( 'should handle single validation error' , ( ) => {
125+ mockUseSelector . mockReturnValue ( {
126+ changes : { } ,
127+ configValidationErrors : [ 'Single error' ] ,
128+ } )
129+
130+ render ( < ConfigurationCard { ...instance ( mockedProps ) } /> )
131+
132+ expect (
133+ screen . getByTestId ( 'rdi-pipeline-nav__error-configuration' ) ,
134+ ) . toBeInTheDocument ( )
135+ } )
136+ } )
137+
138+ it ( 'should show both changes indicator and error icon when config has changes and errors' , ( ) => {
139+ mockUseSelector . mockReturnValue ( {
140+ changes : { config : 'modified' } ,
141+ configValidationErrors : [ 'Invalid configuration' ] ,
142+ } )
143+
144+ render ( < ConfigurationCard { ...instance ( mockedProps ) } /> )
145+
146+ expect (
147+ screen . getByTestId ( 'updated-configuration-highlight' ) ,
148+ ) . toBeInTheDocument ( )
149+ expect (
150+ screen . getByTestId ( 'rdi-pipeline-nav__error-configuration' ) ,
151+ ) . toBeInTheDocument ( )
152+ } )
52153} )
0 commit comments