Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ const mockAggResponse = (
testResultsAggregates: {
totalDuration: 1490,
totalDurationPercentChange: 25.0,
slowestTestsDuration: 111.11,
slowestTestsDurationPercentChange: 0.0,
totalSlowTests: 12,
totalSlowTestsPercentChange: 15.1,
totalFails: 1,
totalFailsPercentChange: 100.0,
totalSkips: 20,
Expand Down Expand Up @@ -178,63 +174,6 @@ describe('MetricsSection', () => {
expect(description).toBeInTheDocument()
})

describe('slowest tests card', () => {
it('renders slowest tests card', async () => {
setup()
render(<MetricsSection />, {
wrapper: wrapper('/gh/owner/repo/tests/main'),
})

const title = await screen.findByText('Slowest tests')
const context = await screen.findByText(12)
const description = await screen.findByText(
'The slowest 12 tests take 1m 51s to run.'
)

expect(title).toBeInTheDocument()
expect(context).toBeInTheDocument()
expect(description).toBeInTheDocument()
})

it('can update the location params on button click', async () => {
const { user } = setup()
render(<MetricsSection />, {
wrapper: wrapper('/gh/owner/repo/tests/main'),
})
const select = await screen.findByText('12')
expect(select).toBeInTheDocument()
await user.click(select)

expect(testLocation?.state).toStrictEqual({
parameter: TestResultsFilterParameter.SLOWEST_TESTS,
flags: [],
historicalTrend: '',
term: '',
testSuites: [],
})
})

it('removes the location param on second button click', async () => {
const { user } = setup()
render(<MetricsSection />, {
wrapper: wrapper('/gh/owner/repo/tests/main'),
})
const select = await screen.findByText('12')
expect(select).toBeInTheDocument()

await user.click(select)
await user.click(select)

expect(testLocation?.state).toStrictEqual({
parameter: '',
flags: [],
historicalTrend: '',
term: '',
testSuites: [],
})
})
})

describe('flaky tests card', () => {
it('renders total flaky tests card', async () => {
setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,60 +95,6 @@ const TotalTestsRunTimeCard = ({
)
}

const SlowestTestsCard = ({
slowestTests,
slowestTestsPercentChange,
slowestTestsDuration,
isSelected,
updateParams,
}: {
slowestTests?: number
slowestTestsPercentChange?: number | null
slowestTestsDuration?: number | null
isSelected: boolean
updateParams: (newParams: {
parameter: TestResultsFilterParameterType | ''
}) => void
}) => {
return (
<MetricCard>
<MetricCard.Header>
<MetricCard.Title className="flex items-center gap-2">
Slowest tests
<TooltipWithIcon>
Lists the tests that take more than the 95th percentile run time to
complete. Showing a max of 100 tests.
</TooltipWithIcon>
</MetricCard.Title>
</MetricCard.Header>

<MetricCard.Content>
<button
className={cn('text-ds-blue-default hover:underline', {
'font-semibold': isSelected,
})}
onClick={() => {
updateParams({
parameter: isSelected
? ''
: TestResultsFilterParameter.SLOWEST_TESTS,
})
}}
>
{slowestTests}
</button>
{slowestTestsPercentChange ? (
<PercentBadge value={slowestTestsPercentChange} />
) : null}
</MetricCard.Content>
<MetricCard.Description>
The slowest {slowestTests} tests take{' '}
{formatTimeFromSeconds(slowestTestsDuration)} to run.
</MetricCard.Description>
</MetricCard>
)
}

const TotalFlakyTestsCard = ({
flakeCount,
flakeCountPercentChange,
Expand Down Expand Up @@ -393,29 +339,13 @@ function MetricsSection() {
<p className="pl-4 text-xs font-semibold text-ds-gray-quaternary">
Improve CI Run Efficiency
</p>
<div className="grid grid-cols-2">
<TotalTestsRunTimeCard
totalDuration={aggregates?.totalDuration}
totalDurationPercentChange={
aggregates?.totalDurationPercentChange
}
intervalCopy={historicalTrendToCopy(
queryParams?.historicalTrend as MeasurementInterval
)}
/>
<SlowestTestsCard
slowestTests={aggregates?.totalSlowTests}
slowestTestsPercentChange={
aggregates?.totalSlowTestsPercentChange
}
slowestTestsDuration={aggregates?.slowestTestsDuration}
updateParams={updateParams}
isSelected={
queryParams?.parameter ===
TestResultsFilterParameter.SLOWEST_TESTS
}
/>
</div>
<TotalTestsRunTimeCard
totalDuration={aggregates?.totalDuration}
totalDurationPercentChange={aggregates?.totalDurationPercentChange}
intervalCopy={historicalTrendToCopy(
queryParams?.historicalTrend as MeasurementInterval
)}
/>
</div>
<div className="flex flex-col gap-3">
<p className="pl-4 text-xs font-semibold text-ds-gray-quaternary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,5 @@ describe('TableHeader', () => {
const headerTitle = screen.getByText('Skipped tests (50.0K)')
expect(headerTitle).toBeInTheDocument()
})

it('renders the slowest tests header title', () => {
render(<TableHeader totalCount={50000} isDefaultBranch />, {
wrapper: wrapper('/gh/codecov/cool-repo/tests?parameter=SLOWEST_TESTS'),
})
const headerTitle = screen.getByText('Slowest tests (50.0K)')
expect(headerTitle).toBeInTheDocument()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const OrderingParameter = {
export const TestResultsFilterParameter = {
FLAKY_TESTS: 'FLAKY_TESTS',
FAILED_TESTS: 'FAILED_TESTS',
SLOWEST_TESTS: 'SLOWEST_TESTS',
SKIPPED_TESTS: 'SKIPPED_TESTS',
} as const

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ const TestResultsAggregatesSchema = z.object({
.object({
totalDuration: z.number(),
totalDurationPercentChange: z.number().nullable(),
slowestTestsDuration: z.number(),
slowestTestsDurationPercentChange: z.number().nullable(),
totalSlowTests: z.number(),
totalSlowTestsPercentChange: z.number().nullable(),
totalFails: z.number(),
totalFailsPercentChange: z.number().nullable(),
totalSkips: z.number(),
Expand Down Expand Up @@ -69,10 +65,6 @@ const query = `
testResultsAggregates(interval: $interval) {
totalDuration
totalDurationPercentChange
slowestTestsDuration
slowestTestsDurationPercentChange
totalSlowTests
totalSlowTestsPercentChange
totalFails
totalFailsPercentChange
totalSkips
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ const mockResponse = {
testResultsAggregates: {
totalDuration: 1.0,
totalDurationPercentChange: 25.0,
slowestTestsDuration: 111.11,
slowestTestsDurationPercentChange: 0.0,
totalSlowTests: 2,
totalSlowTestsPercentChange: 15.1,
totalFails: 1,
totalFailsPercentChange: 100.0,
totalSkips: 20,
Expand Down Expand Up @@ -123,12 +119,8 @@ describe('useTestResultsAggregates', () => {
testResultsAggregates: {
totalDuration: 1,
totalDurationPercentChange: 25,
slowestTestsDuration: 111.11,
slowestTestsDurationPercentChange: 0,
totalFails: 1,
totalFailsPercentChange: 100,
totalSlowTests: 2,
totalSlowTestsPercentChange: 15.1,
totalSkips: 20,
totalSkipsPercentChange: 0,
},
Expand Down