All files / modules/70-pipeline/pages/execution/ExecutionTestView TestsSelectionBreakdown.tsx

100% Statements 11/11
100% Branches 0/0
100% Functions 1/1
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94              1x 1x 1x 1x 1x 1x 1x               1x         4x   4x   4x                                                                                                                              
/*
 * Copyright 2021 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import React from 'react'
import cx from 'classnames'
import { Text, Container, Heading, HarnessDocTooltip } from '@wings-software/uicore'
import { ProgressBar } from '@blueprintjs/core'
import { Color } from '@harness/design-system'
import { useStrings } from 'framework/strings'
import css from './BuildTests.module.scss'
 
export interface TestsSelectionBreakdownProps {
  sourceCodeChanges: number
  newTests: number
  updatedTests: number
}
 
export function TestsSelectionBreakdown({
  sourceCodeChanges,
  newTests,
  updatedTests
}: TestsSelectionBreakdownProps): React.ReactElement {
  const { getString } = useStrings()
 
  const selectedTests = sourceCodeChanges + newTests + updatedTests
 
  return (
    <div className={cx(css.widgetWrapper, css.selectionBreakdown)}>
      <Container flex={{ justifyContent: 'flex-start' }} margin={{ bottom: 'xsmall' }}>
        <Heading
          data-name="test-execution-selection-breakdown"
          level={6}
          style={{ fontWeight: 600, marginBottom: 'var(--spacing-3)' }}
          color={Color.GREY_600}
        >
          {getString('pipeline.testsReports.selectionBreakdown')}
          <HarnessDocTooltip tooltipId="testSelectionBreakdown" useStandAlone={true} />
        </Heading>
      </Container>
 
      <Container className={css.widget} height="100%">
        <Container className={css.section} flex>
          <Text className={css.type} color={Color.GREY_800}>
            <Text color={Color.GREY_800}>{getString('pipeline.testsReports.correlatedWithCodeChanges')}</Text>
            <ProgressBar
              className={css.testsSelectionBreakdown}
              animate={false}
              stripes={false}
              value={sourceCodeChanges / selectedTests}
            />
          </Text>
          <Text className={css.number} font={{ weight: 'bold' }} color={Color.GREY_800}>
            {sourceCodeChanges}
          </Text>
        </Container>
 
        <Container className={css.section} flex>
          <Text className={css.type} color={Color.GREY_800}>
            <Text color={Color.GREY_800}>{getString('pipeline.testsReports.newTests')}</Text>
            <ProgressBar
              className={css.testsSelectionBreakdown}
              animate={false}
              stripes={false}
              value={newTests / selectedTests}
            />
          </Text>
          <Text className={css.number} font={{ weight: 'bold' }} color={Color.GREY_800}>
            {newTests}
          </Text>
        </Container>
 
        <Container className={css.section} flex>
          <Text className={css.type} color={Color.GREY_800}>
            <Text color={Color.GREY_800}>{getString('pipeline.testsReports.updatedTests')}</Text>
            <ProgressBar
              className={css.testsSelectionBreakdown}
              animate={false}
              stripes={false}
              value={updatedTests / selectedTests}
            />
          </Text>
          <Text className={css.number} font={{ weight: 'bold' }} color={Color.GREY_800}>
            {updatedTests}
          </Text>
        </Container>
      </Container>
    </div>
  )
}