@@ -30,6 +30,17 @@ module.exports = (function () {
30
30
} ) ;
31
31
}
32
32
33
+ /**
34
+ * Checks if the step is an After step containing a screenshot
35
+ * @param step - object which contains step data
36
+ * @returns boolean
37
+ */
38
+ function isAfterStepWithScreenshot ( step ) {
39
+ return step . keyword . trim ( ) === 'After'
40
+ && step . embeddings
41
+ && step . embeddings [ 0 ]
42
+ && step . embeddings [ 0 ] . mime_type === 'image/png' ;
43
+ }
33
44
34
45
/**
35
46
* Return html code of step element based on step template
@@ -43,10 +54,26 @@ module.exports = (function () {
43
54
return compiled ( {
44
55
status : step . result ? step . result . status : '' ,
45
56
errorDetails : step . result ? toHtmlEntities ( step . result . error_message ) : '' ,
57
+ screenshot : step . embeddings && step . embeddings [ 0 ] ? step . embeddings [ 0 ] . data : '' ,
46
58
name : step . keyword + step . name
47
59
} ) ;
48
60
}
49
61
62
+
63
+ /**
64
+ * Return html code of step element based on step template
65
+ * @param step - object which contains step data
66
+ * @returns string
67
+ */
68
+ function getAfterScreenshotStep ( step ) {
69
+ var template = fs . readFileSync ( templates . screenshotTemplate ) ,
70
+ compiled = lodashTemplate ( template . toString ( ) ) ;
71
+
72
+ return compiled ( {
73
+ screenshot : step . embeddings && step . embeddings [ 0 ] ? step . embeddings [ 0 ] . data : ''
74
+ } ) ;
75
+ }
76
+
50
77
/**
51
78
* Return html code of scenario element based on scenario template
52
79
* @param scenario - object which contains step data
@@ -148,14 +175,19 @@ module.exports = (function () {
148
175
isPassed = true ;
149
176
for ( var k = 0 ; k < testResults [ i ] . elements [ j ] . steps . length ; k ++ ) {
150
177
step = testResults [ i ] . elements [ j ] . steps [ k ] ;
151
- stepsHtml += getStep ( step ) ;
152
- stepsNumber ++ ;
153
- stepsNumberInFeature ++ ;
154
- if ( step . result . status !== statuses . PASSED ) {
155
- isPassed = false ;
156
- } else if ( step . result . status === statuses . PASSED ) {
157
- passedSteps ++ ;
158
- passedStepsInFeature ++ ;
178
+
179
+ if ( isAfterStepWithScreenshot ( step ) ) {
180
+ stepsHtml += getAfterScreenshotStep ( step ) ;
181
+ } else {
182
+ stepsHtml += getStep ( step ) ;
183
+ stepsNumber ++ ;
184
+ stepsNumberInFeature ++ ;
185
+ if ( step . result . status !== statuses . PASSED ) {
186
+ isPassed = false ;
187
+ } else if ( step . result . status === statuses . PASSED ) {
188
+ passedSteps ++ ;
189
+ passedStepsInFeature ++ ;
190
+ }
159
191
}
160
192
}
161
193
0 commit comments