Files
orca/mobile/src/tasks/github-check-summary.test.ts
T
NeilandOrca fdb58695e9 [P1] fix(checks): stop skipped and manual checks reporting as failures (#11700)
* fix(checks): stop skipped and manual checks reporting as failures

Route every check-classification surface through one shared helper so
desktop renderer, desktop main and mobile agree on the same verdict.

- GitLab `manual` jobs and pipelines are neutral again, not action_required/failure
- `skipped` counts as passed everywhere, including mobile
- a neutral check no longer demotes a summary that has passing checks

* fix(checks): move the check-classification parity test into the renderer project

The parity table lived in src/shared but imported a renderer module, and both
config/tsconfig.node.json and config/tsconfig.cli.json are composite projects
that include src/shared without that renderer path, so `pnpm typecheck` failed
with TS6307 on two of its three projects. Only the web project spans both trees.

Co-authored-by: Orca <help@stably.ai>

* fix(checks): stop the Tasks-grid pill contradicting its own verdict

The checks pill's label, tone and icon all read one ProviderCheckSummary, but
getChecksLabel short-circuited on the raw `neutral` counter while the tone and
icon key off `state`. After the classification fix a PR with 19 success + 1
neutral renders an emerald CheckCircle2 pill that reads "1 unresolved", and
mobile's own label (which keys off `state`) reads "19/20 passed" for the same
summary.

Move the label into src/shared/provider-check-summary.ts so desktop and mobile
cannot fork it again, and key it off `state`.

Also covers deriveWorkItemCheckSummary, the desktop-main producer of the summary
that reaches the Tasks grid and the relay-paired mobile client. It was rewritten
here with no test at all; the parity table stands in derivePRCheckStatusFromRollup,
which is a different normalizer. The new main-process test drives getWorkItem with
a real statusCheckRollup fixture, pinning the StatusContext `state` fallback that
would otherwise be deletable with the whole suite still green.

Co-authored-by: Orca <help@stably.ai>

* fix(gitlab): route the pipeline job-array rollup through the shared check classifier

The array path in derivePipelineStatus kept its own copy of the rollup rules, so
manual-only read green and one unrecognized job status demoted a passing pipeline
to neutral — both disagreeing with every other check surface.

Also retry the packaged-CLI smoke temp cleanup on Windows: the copied Orca.exe can
still be locked by AV/indexers after every assertion passed, failing the package job.

Co-authored-by: Orca <help@stably.ai>

* fix(gitlab): stop the skipped pipeline string diverging from the Checks tab

- classifyPipelineString now counts a skipped pipeline as passing, matching
  the per-check classifier; canceled stays neutral and is pinned as an
  explicit, sign-off-pending divergence.
- Pin the production string path (head_pipeline.status) in the parity table
  and note that the job-array branch has no production caller yet.
- Count skipped checks in the Checks panel's passing header so it agrees
  with the checks pill.
- Correct the packaged-CLI smoke retry comment: the EBUSY is the smoke's own
  just-exited Electron process, not AV/indexers.

Co-authored-by: Orca <help@stably.ai>

* fix(checks): finish cross-surface check parity and back out the skipped MR-card flip

Review follow-ups on the check-classification PR.

- PullRequestPage and GitHubItemDialog kept private copies of getCheckCounts /
  getChecksSummaryLabel that still counted only `success` as passing, so a
  2-success/3-skipped PR read "2 passing · 3 skipped" there and "5 passing" in
  the sidebar. Both copies move to pr-check-counts.ts, which routes the passing
  bucket through classifyCheckOutcome; action_required keeps its own amber
  bucket. The summary icon now keys off passing count, so an all-neutral PR
  stops painting a green tick above "0 of N checks passing".
- The sidebar checks header and triage strip still called
  `{status: completed, conclusion: null}` pending, contradicting the grey
  "Unresolved checks" pill. Both now read summarizeProviderChecks and render an
  unresolved chip/strip instead of an amber spinner that can never resolve.
- classifyPipelineString('skipped') is reverted to neutral. That flip painted
  MR cards green for pipelines that never ran, on the only GitLab path with
  production callers, and contradicted the same function's deferral of
  `canceled`. Both tone changes stay deferred, pinned by one test.
- classifyPipelineString('manual') resolves to pending rather than neutral: a
  blocked pipeline is outstanding, and neutral let the worktree card fall
  through to its emerald `open` default while GitLab still refuses the merge.
- TaskPage's checks pill helpers move to task-page-checks-pill.ts so the
  "1 unresolved on a green pill" fix is actually pinned by a test.
- smoke-packaged-cli no longer lets an EBUSY cleanup replace the real failure.

* fix(checks): stop completed unknown checks from spinning

---------

Co-authored-by: Orca <help@stably.ai>
2026-07-31 04:58:15 -07:00

144 lines
4.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { buildGitHubCheckSummary, type GitHubCheckLike } from './github-check-summary'
import { buildGitLabCheckSummary } from './gitlab-check-summary'
import { summarizeProviderChecks } from '../../../src/shared/provider-check-summary'
import type { ProviderCheckSummary } from '../../../src/shared/types'
describe('buildGitHubCheckSummary', () => {
it('returns none for empty check lists', () => {
expect(buildGitHubCheckSummary([])).toEqual({
state: 'none',
total: 0,
passed: 0,
failed: 0,
pending: 0,
neutral: 0
})
})
it('prioritizes failed checks over pending checks', () => {
expect(
buildGitHubCheckSummary([
{ status: 'completed', conclusion: 'success' },
{ status: 'queued', conclusion: null },
{ status: 'completed', conclusion: 'timed_out' }
])
).toEqual({
state: 'failure',
total: 3,
passed: 1,
failed: 1,
pending: 1,
neutral: 0
})
})
it('keeps neutral and unknown terminal conclusions out of passed without demoting the PR', () => {
expect(
buildGitHubCheckSummary([
{ status: 'completed', conclusion: 'success' },
{ status: 'completed', conclusion: 'neutral' }
])
).toEqual({
state: 'success',
total: 2,
passed: 1,
failed: 0,
pending: 0,
neutral: 1
})
})
it('rolls up GitLab jobs with unknown terminal statuses as neutral', () => {
expect(buildGitLabCheckSummary([{ status: 'success' }, { status: 'future_status' }])).toEqual({
state: 'success',
total: 2,
passed: 1,
failed: 0,
pending: 0,
neutral: 1
})
})
})
type ParityCase = {
name: string
checks: GitHubCheckLike[]
expected: Omit<ProviderCheckSummary, 'total'>
}
const completed = (conclusion: string): GitHubCheckLike => ({ status: 'completed', conclusion })
const PARITY_CASES: ParityCase[] = [
{
name: 'all success',
checks: [completed('success'), completed('success')],
expected: { state: 'success', passed: 2, failed: 0, pending: 0, neutral: 0 }
},
{
name: 'success plus skipped',
checks: [completed('success'), completed('skipped')],
expected: { state: 'success', passed: 2, failed: 0, pending: 0, neutral: 0 }
},
{
name: 'all skipped',
checks: [completed('skipped'), completed('skipped')],
expected: { state: 'success', passed: 2, failed: 0, pending: 0, neutral: 0 }
},
{
name: 'success plus neutral',
checks: [completed('success'), completed('neutral')],
expected: { state: 'success', passed: 1, failed: 0, pending: 0, neutral: 1 }
},
{
name: 'all neutral',
checks: [completed('neutral')],
expected: { state: 'neutral', passed: 0, failed: 0, pending: 0, neutral: 1 }
},
{
name: 'success plus failure',
checks: [completed('success'), completed('failure')],
expected: { state: 'failure', passed: 1, failed: 1, pending: 0, neutral: 0 }
},
{
name: 'success plus running',
checks: [completed('success'), { status: 'in_progress', conclusion: null }],
expected: { state: 'pending', passed: 1, failed: 0, pending: 1, neutral: 0 }
},
{
name: 'genuine action_required',
checks: [completed('success'), completed('action_required')],
expected: { state: 'failure', passed: 1, failed: 1, pending: 0, neutral: 0 }
}
]
describe('mobile / desktop check classification parity', () => {
it.each(PARITY_CASES)('$name matches the shared desktop classifier', ({ checks, expected }) => {
const summary = { ...expected, total: checks.length }
expect(buildGitHubCheckSummary(checks)).toEqual(summary)
expect(summarizeProviderChecks(checks)).toEqual(summary)
})
it.each([
{
name: 'GitLab manual gate only',
statuses: ['manual'],
expected: { state: 'neutral', passed: 0, failed: 0, pending: 0, neutral: 1 }
},
{
name: 'GitLab manual gate alongside a green pipeline',
statuses: ['manual', 'success'],
expected: { state: 'success', passed: 1, failed: 0, pending: 0, neutral: 1 }
}
] satisfies {
name: string
statuses: string[]
expected: Omit<ProviderCheckSummary, 'total'>
}[])('$name never reads as failing', ({ statuses, expected }) => {
expect(buildGitLabCheckSummary(statuses.map((status) => ({ status })))).toEqual({
...expected,
total: statuses.length
})
})
})