Skip to content

Commit d50bbe6

Browse files
committed
fix(pull-requests): exclude skipped checks from progress totals
1 parent 81aca0a commit d50bbe6

7 files changed

Lines changed: 63 additions & 18 deletions

File tree

‎apps/mobile/src/features/pull-requests/pullRequestStatus.test.ts‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,28 @@ describe("mobile overview check status", () => {
9797
count: "1 pending",
9898
});
9999
});
100-
it("only says all passed when every check succeeded", () => {
100+
it("excludes skipped checks from passing totals", () => {
101101
expect(pullRequestChecksSummary({ checks: [check("success"), check("success")] }).title).toBe(
102102
"All checks passed",
103103
);
104-
expect(pullRequestChecksSummary({ checks: [check("success"), check("skipped")] }).title).toBe(
105-
"Checks completed",
106-
);
104+
expect(
105+
pullRequestChecksSummary({ checks: [check("success"), check("skipped")] }),
106+
).toMatchObject({
107+
label: "1 of 1 passed",
108+
title: "All checks passed",
109+
count: "1 of 1",
110+
});
111+
expect(
112+
pullRequestChecksSummary({ checks: [check("failure"), check("skipped")] }),
113+
).toMatchObject({
114+
title: "1 check failing",
115+
count: "0 of 1",
116+
});
117+
expect(pullRequestChecksSummary({ checks: [check("skipped")] })).toMatchObject({
118+
label: "All checks skipped",
119+
title: "All checks skipped",
120+
count: undefined,
121+
});
107122
expect(pullRequestChecksSummary({ checks: [] }).title).toBe("No checks reported");
108123
});
109124

‎apps/mobile/src/features/pull-requests/pullRequestStatus.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ export function checkStatus(check: PullRequestCheck) {
7676
}
7777

7878
export function pullRequestChecksSummary(pr: Pick<PullRequestDetail, "checks">) {
79+
const total = pr.checks.filter((check) => check.status !== "skipped").length;
7980
const failed = pr.checks.filter((check) => check.status === "failure").length;
8081
const required = pr.checks.filter((check) => check.status === "action-required").length;
8182
const pending = pr.checks.filter((check) => check.status === "pending").length;
8283
const passed = pr.checks.filter((check) => check.status === "success").length;
83-
const count = pr.checks.length ? `${passed} of ${pr.checks.length}` : undefined;
84+
const count = total ? `${passed} of ${total}` : undefined;
8485
if (failed)
8586
return {
8687
label: `${failed} ${failed === 1 ? "check" : "checks"} failing`,
@@ -107,15 +108,20 @@ export function pullRequestChecksSummary(pr: Pick<PullRequestDetail, "checks">)
107108
} as const;
108109
if (passed)
109110
return {
110-
label: `${passed} of ${pr.checks.length} passed`,
111-
title: passed === pr.checks.length ? "All checks passed" : "Checks completed",
111+
label: `${passed} of ${total} passed`,
112+
title: passed === total ? "All checks passed" : "Checks completed",
112113
count,
113114
icon: "checkmark.circle",
114115
tint: "accent-adaptive-emerald-600-400",
115116
} as const;
117+
const title = !pr.checks.length
118+
? "No checks reported"
119+
: total === 0
120+
? "All checks skipped"
121+
: "Checks completed";
116122
return {
117-
label: pr.checks.length ? `${pr.checks.length} completed` : "No checks reported",
118-
title: pr.checks.length ? "Checks completed" : "No checks reported",
123+
label: total ? `${pr.checks.length} completed` : title,
124+
title,
119125
count,
120126
icon: "minus",
121127
tint: "accent-icon-muted",

‎apps/web/src/components/pullRequest/PullRequestChecksPopover.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export function PullRequestChecksPopover({
127127
render?: React.ReactElement;
128128
}) {
129129
const presentation = pullRequestChecksStatePresentation(checksState);
130+
const checkCount = checks?.filter((check) => check.status !== "skipped").length ?? 0;
130131
const runningCount = checks?.filter((check) => check.status === "pending").length ?? 0;
131132
const failedCount =
132133
checks?.filter((check) => check.status === "failure" || check.status === "cancelled").length ??
@@ -162,7 +163,7 @@ export function PullRequestChecksPopover({
162163
<>
163164
{checks !== undefined && runningCount > 0 ? (
164165
<span className="tabular-nums">
165-
{runningCount}/{checks.length}
166+
{runningCount}/{checkCount}
166167
</span>
167168
) : failedCount > 0 ? (
168169
<span className="tabular-nums">{failedCount} failed</span>

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,13 @@ describe("the compact row's single action slot", () => {
18271827
expect(describePullRequestChecks([check("success"), check("success")])).toBe(
18281828
"All checks passed",
18291829
);
1830-
expect(describePullRequestChecks([check("success"), check("skipped")])).toBe("1 of 2 passing");
1830+
expect(describePullRequestChecks([check("success"), check("skipped")])).toBe("1 of 1 passing");
1831+
expect(describePullRequestChecks([check("pending"), check("skipped")])).toBe("1 of 1 pending");
1832+
expect(describePullRequestChecks([check("failure"), check("skipped")])).toBe("1 of 1 failing");
1833+
expect(describePullRequestChecks([check("action-required"), check("skipped")])).toBe(
1834+
"1 of 1 awaiting action",
1835+
);
1836+
expect(describePullRequestChecks([check("skipped")])).toBe("All checks skipped");
18311837
expect(
18321838
describePullRequestChecks([
18331839
...Array.from({ length: 7 }, () => check("pending")),

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,20 +332,22 @@ export function classifyPullRequestChecks(
332332

333333
export function describePullRequestChecks(checks: ReadonlyArray<PullRequestCheck>): string {
334334
if (checks.length === 0) return "No checks reported";
335+
const total = checks.filter((check) => check.status !== "skipped").length;
336+
if (total === 0) return "All checks skipped";
335337
const failed = checks.filter(
336338
(check) => check.status === "failure" || check.status === "cancelled",
337339
).length;
338340
const pending = checks.filter((check) => check.status === "pending").length;
339341
const actionRequired = checks.filter((check) => check.status === "action-required").length;
340342
const passed = checks.filter((check) => check.status === "success").length;
341343
const parts: string[] = [];
342-
if (pending > 0) parts.push(`${pending} of ${checks.length} pending`);
343-
if (actionRequired > 0) parts.push(`${actionRequired} of ${checks.length} awaiting action`);
344+
if (pending > 0) parts.push(`${pending} of ${total} pending`);
345+
if (actionRequired > 0) parts.push(`${actionRequired} of ${total} awaiting action`);
344346
if (failed > 0) {
345-
parts.push(parts.length > 0 ? `${failed} failed` : `${failed} of ${checks.length} failing`);
347+
parts.push(parts.length > 0 ? `${failed} failed` : `${failed} of ${total} failing`);
346348
}
347349
if (parts.length === 0) {
348-
return passed === checks.length ? "All checks passed" : `${passed} of ${checks.length} passing`;
350+
return passed === checks.length ? "All checks passed" : `${passed} of ${total} passing`;
349351
}
350352
return parts.join(" · ");
351353
}

‎apps/web/src/components/pullRequest/pullRequestPresentation.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ it("does not call a pending check running when it may still be queued", () => {
1919
expect(summarizePullRequestChecks([check])).toBe("1 of 1 pending");
2020
});
2121

22+
it.each([
23+
[["success", "skipped"], "1 of 1 passing"],
24+
[["pending", "skipped"], "1 of 1 pending"],
25+
[["failure", "skipped"], "1 of 1 failing"],
26+
[["skipped", "skipped"], "All checks skipped"],
27+
] as const)("excludes skipped checks from the summary for %j", (statuses, expected) => {
28+
expect(
29+
summarizePullRequestChecks(
30+
statuses.map((status) => ({ name: status, status, description: null, url: null })),
31+
),
32+
).toBe(expected);
33+
});
34+
2235
describe("resolvePullRequestState", () => {
2336
it.each([
2437
[

‎apps/web/src/components/pullRequest/pullRequestPresentation.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ export function PullRequestMetaLine({
511511

512512
export function summarizePullRequestChecks(checks: ReadonlyArray<PullRequestCheck>): string {
513513
if (checks.length === 0) return "No checks reported";
514+
const total = checks.filter((check) => check.status !== "skipped").length;
515+
if (total === 0) return "All checks skipped";
514516
const actionRequired = checks.filter((check) => check.status === "action-required");
515517
const workflowApprovalRequired = actionRequired.filter(isWorkflowApprovalCheck).length;
516518
const otherActionRequired = actionRequired.length - workflowApprovalRequired;
@@ -519,7 +521,7 @@ export function summarizePullRequestChecks(checks: ReadonlyArray<PullRequestChec
519521
).length;
520522
const pending = checks.filter((check) => check.status === "pending").length;
521523
const passed = checks.filter((check) => check.status === "success").length;
522-
if (failed > 0) return `${failed} of ${checks.length} failing`;
524+
if (failed > 0) return `${failed} of ${total} failing`;
523525
if (workflowApprovalRequired > 0 && otherActionRequired > 0) {
524526
return `${workflowApprovalRequired} ${workflowApprovalRequired === 1 ? "workflow" : "workflows"} and ${otherActionRequired} ${otherActionRequired === 1 ? "check" : "checks"} awaiting action`;
525527
}
@@ -529,6 +531,6 @@ export function summarizePullRequestChecks(checks: ReadonlyArray<PullRequestChec
529531
if (otherActionRequired > 0) {
530532
return `${otherActionRequired} ${otherActionRequired === 1 ? "check" : "checks"} awaiting action`;
531533
}
532-
if (pending > 0) return `${pending} of ${checks.length} pending`;
533-
return passed === checks.length ? "All checks passed" : `${passed} of ${checks.length} passing`;
534+
if (pending > 0) return `${pending} of ${total} pending`;
535+
return passed === checks.length ? "All checks passed" : `${passed} of ${total} passing`;
534536
}

0 commit comments

Comments
 (0)