File tree Expand file tree Collapse file tree 3 files changed +30
-13
lines changed
extensions/ql-vscode/src/view/variant-analysis Expand file tree Collapse file tree 3 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -59,16 +59,6 @@ export const VariantAnalysisHeader = ({
5959 return getSkippedRepoCount ( variantAnalysis . skippedRepos ) > 0 ;
6060 } , [ variantAnalysis . skippedRepos ] ) ;
6161
62- const duration = useMemo ( ( ) => {
63- if ( ! variantAnalysis ?. completedAt ) {
64- return undefined ;
65- }
66-
67- const createdAt = parseDate ( variantAnalysis . createdAt ) ;
68- const completedAt = parseDate ( variantAnalysis . completedAt ) ;
69- return completedAt . getTime ( ) - createdAt . getTime ( ) ;
70- } , [ variantAnalysis ?. completedAt , variantAnalysis ?. createdAt ] ) ;
71-
7262 return (
7363 < Container >
7464 < Row >
@@ -91,7 +81,7 @@ export const VariantAnalysisHeader = ({
9181 completedRepositoryCount = { completedRepositoryCount }
9282 resultCount = { resultCount }
9383 hasWarnings = { hasSkippedRepos }
94- duration = { duration }
84+ createdAt = { parseDate ( variantAnalysis . createdAt ) }
9585 completedAt = { parseDate ( variantAnalysis . completedAt ) }
9686 onViewLogsClick = { onViewLogsClick }
9787 />
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export type VariantAnalysisStatsProps = {
1717 hasWarnings ?: boolean ;
1818
1919 resultCount ?: number | undefined ;
20- duration ?: number | undefined ;
20+ createdAt : Date ;
2121 completedAt ?: Date | undefined ;
2222
2323 onViewLogsClick : ( ) => void ;
@@ -35,7 +35,7 @@ export const VariantAnalysisStats = ({
3535 completedRepositoryCount = 0 ,
3636 hasWarnings,
3737 resultCount,
38- duration ,
38+ createdAt ,
3939 completedAt,
4040 onViewLogsClick,
4141} : VariantAnalysisStatsProps ) => {
@@ -59,6 +59,14 @@ export const VariantAnalysisStats = ({
5959 return 'Succeeded' ;
6060 } , [ variantAnalysisStatus , hasWarnings ] ) ;
6161
62+ const duration = useMemo ( ( ) => {
63+ if ( ! completedAt ) {
64+ return undefined ;
65+ }
66+
67+ return completedAt . getTime ( ) - createdAt . getTime ( ) ;
68+ } , [ completedAt , createdAt ] ) ;
69+
6270 return (
6371 < Row >
6472 < StatItem title = "Results" >
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ describe(VariantAnalysisStats.name, () => {
1717 variantAnalysisStatus = { VariantAnalysisStatus . InProgress }
1818 totalRepositoryCount = { 10 }
1919 onViewLogsClick = { onViewLogsClick }
20+ createdAt = { new Date ( ) }
2021 { ...props }
2122 />
2223 ) ;
@@ -100,4 +101,22 @@ describe(VariantAnalysisStats.name, () => {
100101 expect ( screen . getByText ( 'Succeeded' ) ) . toBeInTheDocument ( ) ;
101102 expect ( screen . queryByText ( 'Succeeded warnings' ) ) . not . toBeInTheDocument ( ) ;
102103 } ) ;
104+
105+ it ( 'renders the duration when it is less than a second' , ( ) => {
106+ render ( { createdAt : new Date ( '2021-05-01T00:00:00Z' ) , completedAt : new Date ( '2021-05-01T00:00:00Z' ) } ) ;
107+
108+ expect ( screen . getByText ( 'Less than a second' ) ) . toBeInTheDocument ( ) ;
109+ } ) ;
110+
111+ it ( 'renders the duration when it is less than a minute' , ( ) => {
112+ render ( { createdAt : new Date ( '2021-05-01T00:00:00Z' ) , completedAt : new Date ( '2021-05-01T00:00:34Z' ) } ) ;
113+
114+ expect ( screen . getByText ( '34 seconds' ) ) . toBeInTheDocument ( ) ;
115+ } ) ;
116+
117+ it ( 'renders the duration when it is more than a minute' , ( ) => {
118+ render ( { createdAt : new Date ( '2021-05-01T00:00:00Z' ) , completedAt : new Date ( '2021-05-01T00:10:22Z' ) } ) ;
119+
120+ expect ( screen . getByText ( '10 minutes' ) ) . toBeInTheDocument ( ) ;
121+ } ) ;
103122} ) ;
You can’t perform that action at this time.
0 commit comments