1
+ import {
2
+ VALUE_STATE_ERROR ,
3
+ VALUE_STATE_INFORMATION ,
4
+ VALUE_STATE_SUCCESS ,
5
+ VALUE_STATE_WARNING
6
+ } from '@ui5/webcomponents/dist/generated/i18n/i18n-defaults.js' ;
1
7
import { ThemingParameters } from '@ui5/webcomponents-react-base' ;
2
- import type { ValueState , IndicationColor } from '../../enums/index.js' ;
8
+ import type { IndicationColor } from '../../enums/index.js' ;
9
+ import { ValueState } from '../../enums/index.js' ;
10
+ import { INDICATION_COLOR } from '../../i18n/i18n-defaults.js' ;
3
11
import { Icon } from '../../webComponents/index.js' ;
4
12
import { ObjectStatus } from './index.js' ;
5
13
import { cssVarToRgb , cypressPassThroughTestsFactory } from '@/cypress/support/utils' ;
@@ -10,6 +18,7 @@ const statesWithCSSVars: {
10
18
iconColor : string ;
11
19
hasDefaultIcon ?: true ;
12
20
inverted : { color : string ; iconColor : string ; backgroundColor : string } ;
21
+ hiddenText : undefined | string ;
13
22
} [ ] = [
14
23
{
15
24
state : 'Error' ,
@@ -20,7 +29,8 @@ const statesWithCSSVars: {
20
29
color : ThemingParameters . sapButton_Negative_TextColor ,
21
30
backgroundColor : ThemingParameters . sapButton_Negative_Background ,
22
31
iconColor : ThemingParameters . sapButton_Negative_TextColor
23
- }
32
+ } ,
33
+ hiddenText : VALUE_STATE_ERROR . defaultText
24
34
} ,
25
35
{
26
36
state : 'None' ,
@@ -30,7 +40,8 @@ const statesWithCSSVars: {
30
40
color : ThemingParameters . sapButton_Neutral_TextColor ,
31
41
backgroundColor : ThemingParameters . sapButton_Neutral_Background ,
32
42
iconColor : ThemingParameters . sapButton_Neutral_TextColor
33
- }
43
+ } ,
44
+ hiddenText : undefined
34
45
} ,
35
46
{
36
47
state : 'Success' ,
@@ -41,7 +52,8 @@ const statesWithCSSVars: {
41
52
color : ThemingParameters . sapButton_Success_TextColor ,
42
53
backgroundColor : ThemingParameters . sapButton_Success_Background ,
43
54
iconColor : ThemingParameters . sapButton_Success_TextColor
44
- }
55
+ } ,
56
+ hiddenText : VALUE_STATE_SUCCESS . defaultText
45
57
} ,
46
58
{
47
59
state : 'Warning' ,
@@ -52,7 +64,8 @@ const statesWithCSSVars: {
52
64
color : ThemingParameters . sapButton_Critical_TextColor ,
53
65
backgroundColor : ThemingParameters . sapButton_Critical_Background ,
54
66
iconColor : ThemingParameters . sapButton_Critical_TextColor
55
- }
67
+ } ,
68
+ hiddenText : VALUE_STATE_WARNING . defaultText
56
69
} ,
57
70
{
58
71
state : 'Information' ,
@@ -63,7 +76,8 @@ const statesWithCSSVars: {
63
76
color : ThemingParameters . sapButton_Information_TextColor ,
64
77
backgroundColor : ThemingParameters . sapButton_Information_Background ,
65
78
iconColor : ThemingParameters . sapButton_Information_TextColor
66
- }
79
+ } ,
80
+ hiddenText : VALUE_STATE_INFORMATION . defaultText
67
81
} ,
68
82
{
69
83
state : 'Indication01' ,
@@ -73,7 +87,8 @@ const statesWithCSSVars: {
73
87
color : ThemingParameters . sapIndicationColor_1_TextColor ,
74
88
backgroundColor : ThemingParameters . sapIndicationColor_1 ,
75
89
iconColor : ThemingParameters . sapIndicationColor_1_TextColor
76
- }
90
+ } ,
91
+ hiddenText : `${ INDICATION_COLOR . defaultText } 1`
77
92
} ,
78
93
{
79
94
state : 'Indication02' ,
@@ -83,7 +98,8 @@ const statesWithCSSVars: {
83
98
color : ThemingParameters . sapIndicationColor_2_TextColor ,
84
99
backgroundColor : ThemingParameters . sapIndicationColor_2 ,
85
100
iconColor : ThemingParameters . sapIndicationColor_2_TextColor
86
- }
101
+ } ,
102
+ hiddenText : `${ INDICATION_COLOR . defaultText } 2`
87
103
} ,
88
104
{
89
105
state : 'Indication03' ,
@@ -93,7 +109,8 @@ const statesWithCSSVars: {
93
109
color : ThemingParameters . sapIndicationColor_3_TextColor ,
94
110
backgroundColor : ThemingParameters . sapIndicationColor_3 ,
95
111
iconColor : ThemingParameters . sapIndicationColor_3_TextColor
96
- }
112
+ } ,
113
+ hiddenText : `${ INDICATION_COLOR . defaultText } 3`
97
114
} ,
98
115
{
99
116
state : 'Indication04' ,
@@ -103,7 +120,8 @@ const statesWithCSSVars: {
103
120
color : ThemingParameters . sapIndicationColor_4_TextColor ,
104
121
backgroundColor : ThemingParameters . sapIndicationColor_4 ,
105
122
iconColor : ThemingParameters . sapIndicationColor_4_TextColor
106
- }
123
+ } ,
124
+ hiddenText : `${ INDICATION_COLOR . defaultText } 4`
107
125
} ,
108
126
{
109
127
state : 'Indication05' ,
@@ -113,7 +131,8 @@ const statesWithCSSVars: {
113
131
color : ThemingParameters . sapIndicationColor_5_TextColor ,
114
132
backgroundColor : ThemingParameters . sapIndicationColor_5 ,
115
133
iconColor : ThemingParameters . sapIndicationColor_5_TextColor
116
- }
134
+ } ,
135
+ hiddenText : `${ INDICATION_COLOR . defaultText } 5`
117
136
} ,
118
137
{
119
138
state : 'Indication06' ,
@@ -123,7 +142,8 @@ const statesWithCSSVars: {
123
142
color : ThemingParameters . sapIndicationColor_6_TextColor ,
124
143
backgroundColor : ThemingParameters . sapIndicationColor_6 ,
125
144
iconColor : ThemingParameters . sapIndicationColor_6_TextColor
126
- }
145
+ } ,
146
+ hiddenText : `${ INDICATION_COLOR . defaultText } 6`
127
147
} ,
128
148
{
129
149
state : 'Indication07' ,
@@ -133,7 +153,8 @@ const statesWithCSSVars: {
133
153
color : ThemingParameters . sapIndicationColor_7_TextColor ,
134
154
backgroundColor : ThemingParameters . sapIndicationColor_7 ,
135
155
iconColor : ThemingParameters . sapIndicationColor_7_TextColor
136
- }
156
+ } ,
157
+ hiddenText : `${ INDICATION_COLOR . defaultText } 7`
137
158
} ,
138
159
{
139
160
state : 'Indication08' ,
@@ -143,7 +164,8 @@ const statesWithCSSVars: {
143
164
color : ThemingParameters . sapIndicationColor_8_TextColor ,
144
165
backgroundColor : ThemingParameters . sapIndicationColor_8 ,
145
166
iconColor : ThemingParameters . sapIndicationColor_8_TextColor
146
- }
167
+ } ,
168
+ hiddenText : `${ INDICATION_COLOR . defaultText } 8`
147
169
}
148
170
] ;
149
171
@@ -187,6 +209,9 @@ describe('ObjectStatus', () => {
187
209
Content
188
210
</ ObjectStatus >
189
211
) ;
212
+ if ( stateObj . hiddenText ) {
213
+ cy . findByText ( stateObj . hiddenText ) . should ( 'exist' ) . and ( 'not.be.visible' ) ;
214
+ }
190
215
if ( ! item . inverted ) {
191
216
cy . findByText ( 'Content' ) . should ( 'have.css' , 'color' , rgbValColorString ) ;
192
217
cy . findByTestId ( 'icon' ) . should ( 'have.css' , 'color' , rgbValColorIconString ) ;
@@ -201,9 +226,15 @@ describe('ObjectStatus', () => {
201
226
202
227
it ( 'active' , ( ) => {
203
228
const click = cy . spy ( ) . as ( 'clickSpy' ) ;
204
- cy . mount ( < ObjectStatus onClick = { click } > Content</ ObjectStatus > ) ;
229
+ cy . mount (
230
+ < ObjectStatus onClick = { click } data-testid = "os" >
231
+ Content
232
+ </ ObjectStatus >
233
+ ) ;
205
234
cy . findByText ( 'Content' ) . click ( ) ;
206
235
cy . get ( '@clickSpy' ) . should ( 'not.be.called' ) ;
236
+ cy . findByRole ( 'button' ) . should ( 'not.exist' ) ;
237
+ cy . findByTestId ( 'os' ) . should ( 'not.have.attr' , 'aria-roledescription' ) ;
207
238
208
239
cy . mount (
209
240
< ObjectStatus onClick = { click } active >
@@ -212,6 +243,25 @@ describe('ObjectStatus', () => {
212
243
) ;
213
244
cy . findByText ( 'Content' ) . click ( ) ;
214
245
cy . get ( '@clickSpy' ) . should ( 'have.been.calledOnce' ) ;
246
+ cy . findByRole ( 'button' ) . should ( 'have.attr' , 'aria-roledescription' , 'Object Status Button' ) ;
247
+ } ) ;
248
+
249
+ it ( 'emptyIndicator' , ( ) => {
250
+ cy . mount ( < ObjectStatus data-testid = "os" /> ) ;
251
+ cy . findByTestId ( 'os' ) . children ( ) . should ( 'have.length' , 0 ) ;
252
+ cy . mount ( < ObjectStatus data-testid = "os" emptyIndicator /> ) ;
253
+ cy . findByTestId ( 'os' ) . children ( ) . should ( 'have.length' , 1 ) ;
254
+ cy . findByText ( '–' ) . should ( 'be.visible' ) ;
255
+ } ) ;
256
+
257
+ it ( 'stateAnnouncementText' , ( ) => {
258
+ cy . mount (
259
+ < ObjectStatus data-testid = "os" state = { ValueState . Error } stateAnnouncementText = "Custom Text" >
260
+ Content
261
+ </ ObjectStatus >
262
+ ) ;
263
+ cy . findByText ( VALUE_STATE_ERROR . defaultText ) . should ( 'not.exist' ) ;
264
+ cy . findByText ( 'Custom Text' ) . should ( 'exist' ) . and ( 'not.be.visible' ) ;
215
265
} ) ;
216
266
217
267
cypressPassThroughTestsFactory ( ObjectStatus ) ;
0 commit comments