Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -166,7 +166,9 @@ describe('UserDropdown', () => {

const link = screen.getByText('Settings')
expect(link).toBeVisible()
expect(link).toHaveAttribute('href', '/account/gh/janedoe')
await waitFor(() =>
expect(link).toHaveAttribute('href', '/account/gh/janedoe')
)
})

it('shows sign out button', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function MemberActivation() {
const planAutoActivateIsDefined = !isUndefined(
accountDetails?.planAutoActivate
)
const planDataIsDefined = !isUndefined(planData)
const isNotTrialing =
!planData?.plan?.isTrialPlan &&
planData?.plan?.trialStatus !== TrialStatuses.ONGOING
Expand All @@ -30,7 +31,10 @@ function MemberActivation() {
) // only show for admins on enterprise cloud plans

const showAutoActivate =
planAutoActivateIsDefined && isNotTrialing && isNotAnEnterpriseDeveloper
planAutoActivateIsDefined &&
planDataIsDefined &&
isNotTrialing &&
isNotAnEnterpriseDeveloper

return (
<div className="border-2 border-ds-gray-primary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,12 @@ describe('FlagMultiSelect', () => {

render(<FlagMultiSelect />, { wrapper })

const select = await screen.findByText('All flags')
const select = await screen.findByRole('button', {
name: 'Select flags to show',
})
expect(select).toBeInTheDocument()

await waitFor(() => expect(select).not.toHaveAttribute('disabled'))
await user.click(select)

const flag1 = await screen.findByText('flag-1')
Expand Down
184 changes: 175 additions & 9 deletions src/services/commit/useCommit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,94 @@ const compareDoneData = {
},
}

const dataReturnedProcessed = {
owner: {
repository: {
__typename: 'Repository',
commit: {
branchName: null,
coverageAnalytics: {
totals: {
coverage: 38.30846,
diff: {
coverage: null,
},
},
},
commitid: 'f00162848a3cebc0728d915763c2fd9e92132408',
pullId: 10,
createdAt: '2020-08-25T16:35:32',
author: {
username: 'febg',
},
state: 'complete',
uploads: {
edges: [
{
node: {
id: 0,
state: 'PROCESSED',
provider: 'travis',
createdAt: '2020-08-25T16:36:19.55947400:00',
updatedAt: '2020-08-25T16:36:19.67986800:00',
flags: [],
downloadUrl:
'/api/gh/febg/repo-test/download/build?path=v4/raw/2020-08-25/F84D6D9A7F883055E40E3B380280BC44/f00162848a3cebc0728d915763c2fd9e92132408/30582d33-de37-4272-ad50-c4dc805802fb.txt',
ciUrl: 'https://travis-ci.com/febg/repo-test/jobs/721065746',
uploadType: 'UPLOADED',
errors: null,
name: 'upload name',
jobCode: null,
buildCode: null,
},
},
{
node: {
id: 1,
state: 'PROCESSED',
provider: 'travis',
createdAt: '2020-08-25T16:36:25.82034000:00',
updatedAt: '2020-08-25T16:36:25.85988900:00',
flags: [],
downloadUrl:
'/api/gh/febg/repo-test/download/build?path=v4/raw/2020-08-25/F84D6D9A7F883055E40E3B380280BC44/f00162848a3cebc0728d915763c2fd9e92132408/18b19f8d-5df6-48bd-90eb-50578ed8812f.txt',
ciUrl: 'https://travis-ci.com/febg/repo-test/jobs/721065763',
uploadType: 'UPLOADED',
errors: null,
name: 'upload name',
jobCode: null,
buildCode: null,
},
},
null,
],
},
message: 'paths test',
ciPassed: true,
compareWithParent: {
__typename: 'Comparison',
state: 'PROCESSED',
indirectChangedFilesCount: 1,
directChangedFilesCount: 1,
patchTotals: null,
impactedFiles: {
__typename: 'ImpactedFiles',
results: [],
},
},
parent: {
commitid: 'd773f5bc170caec7f6e64420b0967e7bac978a8f',
coverageAnalytics: {
totals: {
coverage: 38.30846,
},
},
},
},
},
},
}

const dataReturned = {
owner: {
repository: {
Expand Down Expand Up @@ -214,6 +302,75 @@ const dataReturnedTeam = {
},
}

const dataReturnedTeamProcessed = {
owner: {
repository: {
__typename: 'Repository',
commit: {
branchName: null,
coverageAnalytics: {
totals: {
coverage: 38.30846,
diff: {
coverage: null,
},
},
},
commitid: 'f00162848a3cebc0728d915763c2fd9e92132408',
pullId: 10,
createdAt: '2020-08-25T16:35:32',
author: {
username: 'febg',
},
state: 'complete',
uploads: {
edges: [
{
node: {
id: 0,
state: 'PROCESSED',
provider: 'travis',
createdAt: '2020-08-25T16:36:19.55947400:00',
updatedAt: '2020-08-25T16:36:19.67986800:00',
downloadUrl:
'/api/gh/febg/repo-test/download/build?path=v4/raw/2020-08-25/F84D6D9A7F883055E40E3B380280BC44/f00162848a3cebc0728d915763c2fd9e92132408/30582d33-de37-4272-ad50-c4dc805802fb.txt',
ciUrl: 'https://travis-ci.com/febg/repo-test/jobs/721065746',
uploadType: 'UPLOADED',
errors: null,
name: 'upload name',
jobCode: null,
buildCode: null,
flags: null,
},
},
],
},
message: 'paths test',
ciPassed: true,
compareWithParent: {
__typename: 'Comparison',
state: 'PROCESSED',
indirectChangedFilesCount: 1,
directChangedFilesCount: 1,
patchTotals: null,
impactedFiles: {
__typename: 'ImpactedFiles',
results: [],
},
},
parent: {
commitid: 'd773f5bc170caec7f6e64420b0967e7bac978a8f',
coverageAnalytics: {
totals: {
coverage: 38.30846,
},
},
},
},
},
},
}

const mockNotFoundError = {
owner: {
isCurrentUserPartOfOrg: true,
Expand Down Expand Up @@ -297,6 +454,11 @@ describe('useCommit', () => {
return HttpResponse.json({ data: mockUnsuccessfulParseError })
} else if (isNullOwner) {
return HttpResponse.json({ data: mockNullOwner })
} else if (skipPolling) {
const dataToReturn = info.variables.isTeamPlan
? dataReturnedTeamProcessed
: dataReturnedProcessed
return HttpResponse.json({ data: dataToReturn })
} else {
const dataToReturn = info.variables.isTeamPlan
? dataReturnedTeam
Expand All @@ -306,7 +468,11 @@ describe('useCommit', () => {
}),
graphql.query(`CompareTotals`, () => {
if (skipPolling) {
return HttpResponse.json({ data: { owner: null } })
return HttpResponse.json({
data: {
owner: { repository: { commit: { compareWithParent: null } } },
},
})
}
return HttpResponse.json({ data: compareDoneData })
})
Expand Down Expand Up @@ -346,14 +512,14 @@ describe('useCommit', () => {
commitid: 'f00162848a3cebc0728d915763c2fd9e92132408',
compareWithParent: {
__typename: 'Comparison',
state: 'PROCESSED',
indirectChangedFilesCount: 1,
directChangedFilesCount: 1,
patchTotals: null,
impactedFiles: {
__typename: 'ImpactedFiles',
results: [],
},
patchTotals: null,
state: 'pending',
indirectChangedFilesCount: 1,
directChangedFilesCount: 1,
},
createdAt: '2020-08-25T16:35:32',
message: 'paths test',
Expand Down Expand Up @@ -443,14 +609,14 @@ describe('useCommit', () => {
commitid: 'f00162848a3cebc0728d915763c2fd9e92132408',
compareWithParent: {
__typename: 'Comparison',
state: 'PROCESSED',
indirectChangedFilesCount: 1,
directChangedFilesCount: 1,
patchTotals: null,
impactedFiles: {
__typename: 'ImpactedFiles',
results: [],
},
patchTotals: null,
state: 'pending',
indirectChangedFilesCount: 1,
directChangedFilesCount: 1,
},
createdAt: '2020-08-25T16:35:32',
message: 'paths test',
Expand Down
6 changes: 5 additions & 1 deletion src/ui/FileViewer/ToggleHeader/Title/Title.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ describe('TitleFlags', () => {

render(<TitleFlags />, { wrapper })

const select = await screen.findByText('All flags')
const select = await screen.findByRole('button', {
name: 'Filter by flags',
})
expect(select).toBeInTheDocument()

await waitFor(() => expect(select).not.toHaveAttribute('disabled'))
await user.click(select)

const flag1 = await screen.findByText('flag-1')
Expand Down
Loading