@@ -30,49 +30,44 @@ import { CopyToClipboardContainer } from './copyToClipboard';
30
30
31
31
export const TestCaseView : React . FC < {
32
32
projectNames : string [ ] ,
33
- test : TestCase | undefined ,
33
+ test : TestCase ,
34
34
next : TestCaseSummary | undefined ,
35
35
prev : TestCaseSummary | undefined ,
36
36
run : number ,
37
37
} > = ( { projectNames, test, run, next, prev } ) => {
38
38
const [ selectedResultIndex , setSelectedResultIndex ] = React . useState ( run ) ;
39
39
const searchParams = React . useContext ( SearchParamsContext ) ;
40
- const filterParam = searchParams . has ( 'q' ) ? '&q=' + searchParams . get ( 'q' ) : '' ;
41
-
42
- const labels = React . useMemo ( ( ) => {
43
- if ( ! test )
44
- return undefined ;
45
- return test . tags ;
46
- } , [ test ] ) ;
47
40
48
- const visibleTestAnnotations = test ?. annotations . filter ( a => ! a . type . startsWith ( '_' ) ) ?? [ ] ;
41
+ const filterParam = searchParams . has ( 'q' ) ? '&q=' + searchParams . get ( 'q' ) : '' ;
42
+ const labels = React . useMemo ( ( ) => test . tags , [ test ] ) ;
43
+ const visibleTestAnnotations = test . annotations . filter ( a => ! a . type . startsWith ( '_' ) ) ?? [ ] ;
49
44
50
45
return < div className = 'test-case-column vbox' >
51
- { test && < div className = 'hbox' >
46
+ < div className = 'hbox' >
52
47
< div className = 'test-case-path' > { test . path . join ( ' › ' ) } </ div >
53
48
< div style = { { flex : 'auto' } } > </ div >
54
49
< div className = { clsx ( ! prev && 'hidden' ) } > < Link href = { testResultHref ( { test : prev } ) + filterParam } > « previous</ Link > </ div >
55
50
< div style = { { width : 10 } } > </ div >
56
51
< div className = { clsx ( ! next && 'hidden' ) } > < Link href = { testResultHref ( { test : next } ) + filterParam } > next »</ Link > </ div >
57
- </ div > }
58
- { test && < div className = 'test-case-title' > { test ? .title } </ div > }
59
- { test && < div className = 'hbox' >
52
+ </ div >
53
+ < div className = 'test-case-title' > { test . title } </ div >
54
+ < div className = 'hbox' >
60
55
< div className = 'test-case-location' >
61
- < CopyToClipboardContainer value = { `${ test ? .location . file } :${ test ? .location . line } ` } >
56
+ < CopyToClipboardContainer value = { `${ test . location . file } :${ test . location . line } ` } >
62
57
{ test . location . file } :{ test . location . line }
63
58
</ CopyToClipboardContainer >
64
59
</ div >
65
60
< div style = { { flex : 'auto' } } > </ div >
66
61
< div className = 'test-case-duration' > { msToString ( test . duration ) } </ div >
67
- </ div > }
68
- { test && ( ! ! test . projectName || labels ) && < div className = 'test-case-project-labels-row' >
69
- { test && ! ! test . projectName && < ProjectLink projectNames = { projectNames } projectName = { test . projectName } > </ ProjectLink > }
62
+ </ div >
63
+ { ( ! ! test . projectName || labels ) && < div className = 'test-case-project-labels-row' >
64
+ { ! ! test . projectName && < ProjectLink projectNames = { projectNames } projectName = { test . projectName } > </ ProjectLink > }
70
65
{ labels && < LabelsLinkView labels = { labels } /> }
71
66
</ div > }
72
- { test ? .results . length === 0 && visibleTestAnnotations . length !== 0 && < AutoChip header = 'Annotations' dataTestId = 'test-case-annotations' >
67
+ { test . results . length === 0 && visibleTestAnnotations . length !== 0 && < AutoChip header = 'Annotations' dataTestId = 'test-case-annotations' >
73
68
{ visibleTestAnnotations . map ( ( annotation , index ) => < TestCaseAnnotationView key = { index } annotation = { annotation } /> ) }
74
69
</ AutoChip > }
75
- { test && < TabbedPane tabs = {
70
+ < TabbedPane tabs = {
76
71
test . results . map ( ( result , index ) => ( {
77
72
id : String ( index ) ,
78
73
title : < div style = { { display : 'flex' , alignItems : 'center' } } >
@@ -88,7 +83,7 @@ export const TestCaseView: React.FC<{
88
83
< TestResultView test = { test ! } result = { result } />
89
84
</ > ;
90
85
} ,
91
- } ) ) || [ ] } selectedTab = { String ( selectedResultIndex ) } setSelectedTab = { id => setSelectedResultIndex ( + id ) } /> }
86
+ } ) ) || [ ] } selectedTab = { String ( selectedResultIndex ) } setSelectedTab = { id => setSelectedResultIndex ( + id ) } />
92
87
</ div > ;
93
88
} ;
94
89
0 commit comments