1
- import { Typography } from 'antd' ;
2
-
3
- import { TRACE_DOCUMENTATION_URL } from 'constants/Common.constants' ;
4
1
import { TestState } from 'constants/TestRun.constants' ;
5
2
import { TraceEventType } from 'constants/TestRunEvents.constants' ;
6
- import { isRunStateFailed } from 'models/TestRun.model' ;
7
3
import TestRunService from 'services/TestRun.service' ;
8
4
import RunEvent , { IPropsEvent } from './RunEvent' ;
9
5
import RunEventDataStore from './RunEventDataStore' ;
10
6
import RunEventPolling from './RunEventPolling' ;
11
7
import { IPropsComponent } from './RunEvents' ;
12
8
import * as S from './RunEvents.styled' ;
9
+ import FailedTraceHeader from './TraceHeader/FailedTraceHeader' ;
10
+ import FailedTriggerHeader from './TraceHeader/FailedTriggerHeader' ;
11
+ import LoadingHeader from './TraceHeader/LoadingHeader' ;
12
+ import StoppedHeader from './TraceHeader/StoppedHeader' ;
13
+
14
+ type TestStateType = TestState . TRIGGER_FAILED | TestState . TRACE_FAILED | TestState . STOPPED ;
15
+
16
+ const HeaderComponentMap : Record < TestStateType , ( ) => React . ReactElement > = {
17
+ [ TestState . TRIGGER_FAILED ] : FailedTriggerHeader ,
18
+ [ TestState . TRACE_FAILED ] : FailedTraceHeader ,
19
+ [ TestState . STOPPED ] : StoppedHeader ,
20
+ } ;
13
21
14
22
type TraceEventTypeWithoutFetching = Exclude <
15
23
TraceEventType ,
@@ -23,51 +31,11 @@ const ComponentMap: Record<TraceEventTypeWithoutFetching, (props: IPropsEvent) =
23
31
24
32
const RunEventsTrace = ( { events, state} : IPropsComponent ) => {
25
33
const filteredEvents = TestRunService . getTestRunTraceEvents ( events ) ;
26
-
27
- const loadingHeader = (
28
- < >
29
- < S . LoadingIcon />
30
- < Typography . Title level = { 3 } type = "secondary" >
31
- We are working to gather the trace associated with this test run
32
- </ Typography . Title >
33
- < S . Paragraph type = "secondary" >
34
- Want to know more about traces? Head to the official{ ' ' }
35
- < S . Link href = { TRACE_DOCUMENTATION_URL } target = "_blank" >
36
- Open Telemetry Documentation
37
- </ S . Link >
38
- </ S . Paragraph >
39
- </ >
40
- ) ;
41
-
42
- const failedTriggerHeader = (
43
- < >
44
- < S . ErrorIcon />
45
- < Typography . Title level = { 2 } type = "secondary" >
46
- Test Trigger Failed
47
- </ Typography . Title >
48
- < S . Paragraph type = "secondary" >
49
- The test failed in the Trigger stage, review the Trigger tab to see the breakdown of diagnostic steps.
50
- </ S . Paragraph >
51
- </ >
52
- ) ;
53
-
54
- const failedTraceHeader = (
55
- < >
56
- < S . ErrorIcon />
57
- < Typography . Title level = { 2 } type = "secondary" >
58
- Trace Fetch Failed
59
- </ Typography . Title >
60
- < S . Paragraph type = "secondary" >
61
- We prepared the breakdown of diagnostic steps and tips to help identify the source of the issue:
62
- </ S . Paragraph >
63
- </ >
64
- ) ;
34
+ const HeaderComponent = HeaderComponentMap [ state as TestStateType ] ?? LoadingHeader ;
65
35
66
36
return (
67
37
< S . Container $hasScroll >
68
- { state === TestState . TRIGGER_FAILED && failedTriggerHeader }
69
- { state === TestState . TRACE_FAILED && failedTraceHeader }
70
- { ! isRunStateFailed ( state ) && loadingHeader }
38
+ < HeaderComponent />
71
39
72
40
< S . ListContainer >
73
41
{ filteredEvents . map ( event => {
0 commit comments