Skip to content

Commit 5fb62d0

Browse files
authored
fix: Test results not rendering on first pull branches with test data (#3710)
1 parent ba78b25 commit 5fb62d0

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

src/pages/RepoPage/FailedTestsTab/FailedTestsPage/FailedTestsTable/FailedTestsTable.test.tsx

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ describe('FailedTestsTable', () => {
177177
hasNextPage: false,
178178
endCursor: null,
179179
},
180-
totalCount: 1234,
180+
totalCount: 0,
181181
},
182182
},
183183
},
@@ -361,19 +361,51 @@ describe('FailedTestsTable', () => {
361361
})
362362

363363
describe('when first pull request', () => {
364-
it('renders no data message', async () => {
365-
const { queryClient } = setup({ isFirstPullRequest: true })
366-
render(<FailedTestsTable />, {
367-
wrapper: wrapper(queryClient),
364+
describe('when there are no test results', () => {
365+
it('renders no data message', async () => {
366+
const { queryClient } = setup({
367+
isFirstPullRequest: true,
368+
noEntries: true,
369+
})
370+
render(<FailedTestsTable />, {
371+
wrapper: wrapper(queryClient),
372+
})
373+
374+
const noDataMessage = await screen.findByText('No data yet')
375+
expect(noDataMessage).toBeInTheDocument()
376+
377+
const mergeIntoMainMessage = await screen.findByText(
378+
'To see data for the main branch, merge your PR into the main branch.'
379+
)
380+
expect(mergeIntoMainMessage).toBeInTheDocument()
368381
})
382+
})
369383

370-
const noDataMessage = await screen.findByText('No data yet')
371-
expect(noDataMessage).toBeInTheDocument()
384+
describe('there are test results', () => {
385+
it('renders data in the table', async () => {
386+
const { queryClient } = setup({ isFirstPullRequest: true })
387+
render(<FailedTestsTable />, {
388+
wrapper: wrapper(queryClient),
389+
})
390+
391+
const nameColumn = await screen.findByText('test-1')
392+
expect(nameColumn).toBeInTheDocument()
393+
394+
const durationColumn = await screen.findByText('10.000s')
395+
expect(durationColumn).toBeInTheDocument()
396+
397+
const failureRateColumn = await screen.findByText('10.00%')
398+
expect(failureRateColumn).toBeInTheDocument()
372399

373-
const mergeIntoMainMessage = await screen.findByText(
374-
'To see data for the main branch, merge your PR into the main branch.'
375-
)
376-
expect(mergeIntoMainMessage).toBeInTheDocument()
400+
const flakeRateColumn = await screen.findByText('0%')
401+
expect(flakeRateColumn).toBeInTheDocument()
402+
403+
const commitFailedColumn = await screen.findByText('1')
404+
expect(commitFailedColumn).toBeInTheDocument()
405+
406+
const lastRunColumn = await screen.findAllByText('over 1 year ago')
407+
expect(lastRunColumn.length).toBeGreaterThan(0)
408+
})
377409
})
378410
})
379411

src/pages/RepoPage/FailedTestsTab/FailedTestsPage/FailedTestsTable/FailedTestsTable.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
useReactTable,
99
} from '@tanstack/react-table'
1010
import cs from 'classnames'
11-
import isEmpty from 'lodash/isEmpty'
1211
import qs from 'qs'
1312
import { useEffect, useMemo, useState } from 'react'
1413
import { useInView } from 'react-intersection-observer'
@@ -298,7 +297,7 @@ const FailedTestsTable = () => {
298297
}
299298
}, [fetchNextPage, inView, hasNextPage])
300299

301-
if (testData?.isFirstPullRequest) {
300+
if (testData?.isFirstPullRequest && testData.totalCount === 0) {
302301
return (
303302
<div className="flex flex-col gap-2">
304303
<TableHeader
@@ -316,7 +315,7 @@ const FailedTestsTable = () => {
316315
)
317316
}
318317

319-
if (isEmpty(testData?.testResults) && !isLoading && !!branch) {
318+
if (testData.totalCount === 0 && !isLoading && !!branch) {
320319
return (
321320
<div className="flex flex-col gap-2">
322321
<TableHeader

0 commit comments

Comments
 (0)