Add PR checks workflow and Vitest coverage (#97)

This commit is contained in:
Jinjing
2026-03-24 20:53:38 -07:00
committed by GitHub
parent 431c14d0a4
commit 9c5a1f48bb
11 changed files with 435 additions and 6 deletions
+31
View File
@@ -0,0 +1,31 @@
import { describe, expect, it } from 'vitest'
import { deriveCheckStatus } from './client'
describe('deriveCheckStatus', () => {
it('returns neutral when no checks are present', () => {
expect(deriveCheckStatus(null)).toBe('neutral')
expect(deriveCheckStatus([])).toBe('neutral')
})
it('returns failure when a failed check is present', () => {
expect(
deriveCheckStatus([
{ status: 'QUEUED' },
{ conclusion: 'FAILURE' }
])
).toBe('failure')
})
it('returns pending when checks are still running', () => {
expect(deriveCheckStatus([{ status: 'IN_PROGRESS' }])).toBe('pending')
})
it('returns success when all checks complete without failures', () => {
expect(
deriveCheckStatus([
{ conclusion: 'SUCCESS' },
{ conclusion: 'SKIPPED' }
])
).toBe('success')
})
})
+2 -2
View File
@@ -127,7 +127,7 @@ export async function listIssues(repoPath: string, limit = 20): Promise<IssueInf
}
}
function mapPRState(state: string): PRInfo['state'] {
export function mapPRState(state: string): PRInfo['state'] {
const s = state?.toUpperCase()
if (s === 'MERGED') {
return 'merged'
@@ -139,7 +139,7 @@ function mapPRState(state: string): PRInfo['state'] {
return 'open'
}
function deriveCheckStatus(rollup: unknown[] | null | undefined): CheckStatus {
export function deriveCheckStatus(rollup: unknown[] | null | undefined): CheckStatus {
if (!rollup || !Array.isArray(rollup) || rollup.length === 0) {
return 'neutral'
}