Skip to content

Commit 4b1ea04

Browse files
committed
Reverts test updates
1 parent be431b8 commit 4b1ea04

2 files changed

Lines changed: 19 additions & 24 deletions

File tree

tests/site-with-errors.test.ts

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

1818
it('cache has expected results', () => {
19-
const actual = results.map(({issue: {url: issueUrl}, findings}) => {
19+
const actual = results.map(({issue: {url: issueUrl}, pullRequest: {url: pullRequestUrl}, findings}) => {
2020
const {problemUrl, solutionLong, screenshotId, ...finding} = findings[0]
2121
// Check volatile fields for existence only
2222
expect(issueUrl).toBeDefined()
23+
expect(pullRequestUrl).toBeDefined()
2324
expect(problemUrl).toBeDefined()
2425
expect(solutionLong).toBeDefined()
2526
// Check `problemUrl`, ignoring axe version
@@ -141,24 +142,22 @@ describe('site-with-errors', () => {
141142
return issue
142143
}),
143144
)
144-
// Fetch pull requests referenced in the findings file if they exist
145+
// Fetch pull requests referenced in the findings file
145146
pullRequests = await Promise.all(
146-
results
147-
.filter(({pullRequest}) => !!pullRequest?.url)
148-
.map(async ({pullRequest}) => {
149-
const pullRequestUrl = pullRequest!.url
150-
const {owner, repo, pullNumber} =
151-
/https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/pull\/(?<pullNumber>\d+)/.exec(
152-
pullRequestUrl,
153-
)!.groups!
154-
const {data: fetchedPullRequest} = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
155-
owner,
156-
repo,
157-
pull_number: parseInt(pullNumber, 10),
158-
})
159-
expect(fetchedPullRequest).toBeDefined()
160-
return fetchedPullRequest
161-
}),
147+
results.map(async ({pullRequest: {url: pullRequestUrl}}) => {
148+
expect(pullRequestUrl).toBeDefined()
149+
const {owner, repo, pullNumber} =
150+
/https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/pull\/(?<pullNumber>\d+)/.exec(
151+
pullRequestUrl!,
152+
)!.groups!
153+
const {data: pullRequest} = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
154+
owner,
155+
repo,
156+
pull_number: parseInt(pullNumber, 10),
157+
})
158+
expect(pullRequest).toBeDefined()
159+
return pullRequest
160+
}),
162161
)
163162
})
164163

@@ -181,11 +180,7 @@ describe('site-with-errors', () => {
181180
}
182181
})
183182

184-
it('pull requests exist and have expected author, state, and assignee if they are created', async () => {
185-
if (pullRequests.length === 0) {
186-
// No pull requests with URLs were fetched; skip further assertions.
187-
return
188-
}
183+
it('pull requests exist and have expected author, state, and assignee', async () => {
189184
for (const pullRequest of pullRequests) {
190185
expect(pullRequest.user.login).toBe('Copilot')
191186
expect(pullRequest.state).toBe('open')

tests/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ export type PullRequest = {
2626
export type Result = {
2727
findings: Finding[]
2828
issue: Issue
29-
pullRequest?: PullRequest
29+
pullRequest: PullRequest
3030
}

0 commit comments

Comments
 (0)