Skip to content

Commit ba9918d

Browse files
Copilotlindseywild
andcommitted
Fix TypeError in site-with-errors test when pullRequest is undefined
Co-authored-by: lindseywild <35239154+lindseywild@users.noreply.github.com>
1 parent bb095a9 commit ba9918d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/site-with-errors.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ describe('site-with-errors', () => {
1616
})
1717

1818
it('cache has expected results', () => {
19-
const actual = results.map(({issue: {url: issueUrl}, pullRequest: {url: pullRequestUrl}, findings}) => {
19+
const actual = results.map(({issue: {url: issueUrl}, pullRequest, findings}) => {
20+
const pullRequestUrl = pullRequest?.url
2021
const {problemUrl, solutionLong, screenshotId, ...finding} = findings[0]
2122
// Check volatile fields for existence only
2223
expect(issueUrl).toBeDefined()
@@ -144,19 +145,20 @@ describe('site-with-errors', () => {
144145
)
145146
// Fetch pull requests referenced in the findings file
146147
pullRequests = await Promise.all(
147-
results.map(async ({pullRequest: {url: pullRequestUrl}}) => {
148+
results.map(async ({pullRequest}) => {
149+
const pullRequestUrl = pullRequest?.url
148150
expect(pullRequestUrl).toBeDefined()
149151
const {owner, repo, pullNumber} =
150152
/https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/pull\/(?<pullNumber>\d+)/.exec(
151153
pullRequestUrl!,
152154
)!.groups!
153-
const {data: pullRequest} = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
155+
const {data: fetchedPullRequest} = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
154156
owner,
155157
repo,
156158
pull_number: parseInt(pullNumber, 10),
157159
})
158-
expect(pullRequest).toBeDefined()
159-
return pullRequest
160+
expect(fetchedPullRequest).toBeDefined()
161+
return fetchedPullRequest
160162
}),
161163
)
162164
})

0 commit comments

Comments
 (0)