@@ -31,8 +31,26 @@ const group2 = {
31
31
id : '456' ,
32
32
}
33
33
34
+ const instance1 : TestResults [ 'instance' ] = {
35
+ id : '123' ,
36
+ groupId : '123' ,
37
+ status : 'FAILED' ,
38
+ hasScreenshots : true ,
39
+ screenshotsUrl : 'https://cloud.cypress.io/projects/123/runs/456/overview/789/screenshots' ,
40
+ hasStdout : true ,
41
+ stdoutUrl : 'https://cloud.cypress.io/projects/123/runs/456/overview/789/stdout' ,
42
+ hasVideo : true ,
43
+ videoUrl : 'https://cloud.cypress.io/projects/123/runs/456/overview/789/video' ,
44
+ }
45
+
46
+ const instance2 : TestResults [ 'instance' ] = {
47
+ ...instance1 ,
48
+ id : '456' ,
49
+ groupId : '456' ,
50
+ }
51
+
34
52
/**
35
- * This helper testing function mimicks mappedTitleParts in DebugFailedTest.
53
+ * This helper testing function mimics mappedTitleParts in DebugFailedTest.
36
54
* It creates an ordered array of titleParts and chevron icons and then asserts
37
55
* the order in which they are rendered using the testAttr and text values.
38
56
*/
@@ -84,14 +102,7 @@ describe('<DebugFailedTest/>', () => {
84
102
const testResult : TestResults = {
85
103
id : '676df87878' ,
86
104
titleParts : [ 'Login' , 'Should redirect unauthenticated user to signin page' ] ,
87
- instance : {
88
- id : '123' ,
89
- groupId : '123' ,
90
- status : 'FAILED' ,
91
- hasScreenshots : false ,
92
- hasStdout : false ,
93
- hasVideo : false ,
94
- } ,
105
+ instance : instance1 ,
95
106
}
96
107
97
108
cy . mount ( ( ) => (
@@ -114,14 +125,7 @@ describe('<DebugFailedTest/>', () => {
114
125
const multipleTitleParts : TestResults = {
115
126
id : '676df87878' ,
116
127
titleParts : [ 'Login' , 'Describe' , 'it' , 'context' , 'Should redirect unauthenticated user to signin page' ] ,
117
- instance : {
118
- id : '456' ,
119
- groupId : '456' ,
120
- status : 'FAILED' ,
121
- hasScreenshots : false ,
122
- hasStdout : false ,
123
- hasVideo : false ,
124
- } ,
128
+ instance : instance1 ,
125
129
}
126
130
127
131
cy . mount ( ( ) => (
@@ -138,26 +142,12 @@ describe('<DebugFailedTest/>', () => {
138
142
{
139
143
id : '676df87878' ,
140
144
titleParts : [ 'Login' , 'Describe' , 'it' , 'context' , 'Should redirect unauthenticated user to signin page' ] ,
141
- instance : {
142
- id : '456' ,
143
- groupId : '456' ,
144
- status : 'FAILED' ,
145
- hasScreenshots : false ,
146
- hasStdout : false ,
147
- hasVideo : false ,
148
- } ,
145
+ instance : instance1 ,
149
146
} ,
150
147
{
151
148
id : '676df87878' ,
152
149
titleParts : [ 'Login' , 'Should redirect unauthenticated user to signin page' ] ,
153
- instance : {
154
- id : '123' ,
155
- groupId : '123' ,
156
- status : 'FAILED' ,
157
- hasScreenshots : false ,
158
- hasStdout : false ,
159
- hasVideo : false ,
160
- } ,
150
+ instance : instance2 ,
161
151
} ,
162
152
]
163
153
@@ -179,14 +169,7 @@ describe('<DebugFailedTest/>', () => {
179
169
const testResult : TestResults = {
180
170
id : '676df87874' ,
181
171
titleParts : [ 'Test content' , 'Test content 2' , 'Test content 3' , 'Test content 4' , 'onMount() should be called once' , 'hook() should be called twice and then' ] ,
182
- instance : {
183
- id : '123' ,
184
- groupId : '123' ,
185
- status : 'FAILED' ,
186
- hasScreenshots : false ,
187
- hasStdout : false ,
188
- hasVideo : false ,
189
- } ,
172
+ instance : instance1 ,
190
173
}
191
174
192
175
cy . mount ( ( ) => (
@@ -202,4 +185,39 @@ describe('<DebugFailedTest/>', () => {
202
185
203
186
cy . percySnapshot ( )
204
187
} )
188
+
189
+ it ( 'conditionally renders artifacts' , ( ) => {
190
+ const render = ( testResult : TestResults ) => cy . mount ( ( ) =>
191
+ ( < div data-cy = "test-group" >
192
+ < DebugFailedTest failedTestsResult = { [ testResult ] } groups = { [ group1 ] } expandable = { false } />
193
+ </ div > ) )
194
+
195
+ const testResult : TestResults = {
196
+ id : '676df87874' ,
197
+ titleParts : [ 'Test content' , 'Test content 2' , 'Test content 3' , 'Test content 4' , 'onMount() should be called once' , 'hook() should be called twice and then' ] ,
198
+ instance : instance1 ,
199
+ }
200
+
201
+ const artifactFreeInstance : TestResults [ 'instance' ] = {
202
+ ...instance1 ,
203
+ hasStdout : false ,
204
+ hasScreenshots : false ,
205
+ hasVideo : false ,
206
+ }
207
+
208
+ render ( { ...testResult , instance : artifactFreeInstance } )
209
+ cy . findByTestId ( 'debug-artifacts' ) . children ( ) . should ( 'have.length' , 0 )
210
+
211
+ render ( { ...testResult , instance : { ...artifactFreeInstance , hasStdout : true } } )
212
+ cy . findByTestId ( 'debug-artifacts' ) . children ( ) . should ( 'have.length' , 1 )
213
+ cy . findByTestId ( 'TERMINAL_LOG-button' ) . should ( 'exist' )
214
+
215
+ render ( { ...testResult , instance : { ...artifactFreeInstance , hasScreenshots : true } } )
216
+ cy . findByTestId ( 'debug-artifacts' ) . children ( ) . should ( 'have.length' , 1 )
217
+ cy . findByTestId ( 'IMAGE_SCREENSHOT-button' ) . should ( 'exist' )
218
+
219
+ render ( { ...testResult , instance : { ...artifactFreeInstance , hasVideo : true } } )
220
+ cy . findByTestId ( 'debug-artifacts' ) . children ( ) . should ( 'have.length' , 1 )
221
+ cy . findByTestId ( 'PLAY-button' ) . should ( 'exist' )
222
+ } )
205
223
} )
0 commit comments