1
- import { Text , IconContainer , IconButton , LinkButton , FlexRow } from '@epam/loveship' ;
1
+ import { Text , IconContainer , IconButton , LinkButton , FlexRow } from '@epam/loveship' ;
2
2
import { ErrorModal } from './ErrorModal' ;
3
+ import { AttachmentModal } from './AttachmentModal' ;
4
+ import { ResponseModal } from './ResponseModal' ;
5
+ import { LogsModal } from './LogsModal' ;
6
+ import { TimeLabel } from './TimeLabel' ;
7
+ import { FlexSpacer } from '@epam/uui' ;
8
+
3
9
import { ReactComponent as PassedIcon } from '@epam/assets/icons/common/notification-done-24.svg' ;
4
10
import { ReactComponent as FailedIcon } from '@epam/assets/icons/common/navigation-close-24.svg' ;
5
11
import { ReactComponent as SkippedIcon } from '@epam/assets/icons/common/navigation-chevron-right_right-24.svg' ;
@@ -9,15 +15,15 @@ import { ReactComponent as PendingIcon } from '@epam/assets/icons/common/navigat
9
15
import { ReactComponent as ErrorIcon } from '@epam/assets/icons/common/notification-info-fill-24.svg' ;
10
16
import { ReactComponent as AttachmentIcon } from '@epam/assets/icons/common/file-attachment-24.svg' ;
11
17
import { ReactComponent as LogsIcon } from '@epam/assets/icons/common/content-code-24.svg' ;
18
+ import { ReactComponent as ResponseIcon } from '@epam/assets/icons/common/content-code_braces-24.svg' ;
12
19
13
20
import css from '../App.module.scss' ;
14
21
import { useUuiContext } from '@epam/uui-core' ;
15
- import { AttachmentModal } from './AttachmentModal' ;
16
22
import { supportedMimeTypes } from '../utils/supportedMimeTypes' ;
17
23
import { openInNewTab } from '../utils/openInNewTab' ;
18
- import { LogsModal } from './LogsModal' ;
19
- import { TimeLabel } from './TimeLabel ';
20
- import { FlexSpacer } from '@epam/uui ';
24
+
25
+ const logPlainMimeType = 'text/x.cucumber.log+plain ';
26
+ const responseMimeType = 'text/x.response.json ';
21
27
22
28
const icon = ( status : string ) => {
23
29
switch ( status ) {
@@ -69,11 +75,15 @@ const handleLogsClick = (logs: any[], svc: any) => {
69
75
return ( ) => svc . uuiModals . show ( ( props : any ) => < LogsModal { ...props } logs = { logs } /> )
70
76
}
71
77
78
+ const handleResponseClick = ( response : any , svc : any ) => {
79
+ return ( ) => svc . uuiModals . show ( ( props : any ) => < ResponseModal { ...props } response = { response } /> )
80
+ }
81
+
72
82
export const Step = ( { step} : { step : any } ) => {
73
83
const svc = useUuiContext ( ) ;
74
- const logs = step . embeddings
75
- ? step . embeddings . filter ( ( embedding : any ) => embedding . mime_type === 'text/x.cucumber.log+plain' )
76
- : [ ] ;
84
+ const logs = step . embeddings ?. filter ( ( embedding : any ) => embedding . mime_type === logPlainMimeType ) ?? [ ] ;
85
+ const responses = step . embeddings ? .filter ( ( embedding : any ) => embedding . mime_type === responseMimeType ) ?? [ ] ;
86
+ const attachments = step . embeddings ?. filter ( ( embedding : any ) => ! [ logPlainMimeType , responseMimeType ] . includes ( embedding . mime_type ) ) ?? [ ] ;
77
87
return < div >
78
88
< FlexRow >
79
89
{ icon ( step . result . status ) }
@@ -88,10 +98,17 @@ export const Step = ({step}: {step: any}) => {
88
98
caption = 'Logs'
89
99
onClick = { handleLogsClick ( logs , svc ) }
90
100
/> }
91
- { step . embeddings && step . embeddings
92
- . filter ( ( embedding : any ) => embedding . mime_type !== 'text/x.cucumber.log+plain' )
101
+ { responses
102
+ . map ( ( embedding : any , index : any ) => < LinkButton
103
+ key = { `response-${ index } ` }
104
+ icon = { ResponseIcon }
105
+ caption = 'Response'
106
+ onClick = { handleResponseClick ( embedding , svc ) }
107
+ /> )
108
+ }
109
+ { attachments
93
110
. map ( ( embedding : any , index : any ) => < LinkButton
94
- key = { index }
111
+ key = { `attachment- ${ index } ` }
95
112
icon = { AttachmentIcon }
96
113
caption = { embedding . fileName ?? embedding . mime_type }
97
114
onClick = { handleAttachmentClick ( embedding , svc ) }
0 commit comments