Skip to content

Commit fcae5e3

Browse files
MarcoDotIOclaude
andcommitted
fix(mobile): Bitbucket and GitCafe approvals show as approved on the PR timeline
The mobile timeline compared review states to uppercase GitHub spellings only, so lowercase "approved" and "changes_requested" from Bitbucket and GitCafe rendered as plain comments. Reuse the overview's normalization. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a12d6ed commit fcae5e3

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

‎apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { relativeTime } from "../../lib/time";
1313
import { PullRequestAvatar } from "./PullRequestPresentation";
1414
import { PullRequestMarkdown } from "./PullRequestMarkdown";
1515
import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";
16+
import { normalizedReviewState } from "./pullRequestStatus";
1617
import type { PullRequestParams } from "./usePullRequestDiff";
1718

1819
function TimelineEvent(props: {
@@ -66,8 +67,9 @@ function TimelineComment({ comment }: { comment: PullRequestComment }) {
6667
[comment.body],
6768
);
6869
const preview = content.preview;
69-
const approved = comment.reviewState === "APPROVED";
70-
const changes = comment.reviewState === "CHANGES_REQUESTED";
70+
const state = normalizedReviewState(comment.reviewState);
71+
const approved = state === "APPROVED";
72+
const changes = state === "CHANGES_REQUESTED";
7173
return (
7274
<TimelineEvent
7375
icon={approved ? "checkmark" : changes ? "doc.text" : "text.bubble"}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { PullRequestActivity, PullRequestCheck, PullRequestComment } from "@t3tools/contracts";
22
import { describe, expect, it } from "vite-plus/test";
3-
import { pullRequestChecksSummary, pullRequestReviewSummary } from "./pullRequestStatus";
3+
import {
4+
normalizedReviewState,
5+
pullRequestChecksSummary,
6+
pullRequestReviewSummary,
7+
} from "./pullRequestStatus";
48

59
const author = { login: "julius", name: null, avatarUrl: null };
610
function review(state: string, at: string): PullRequestComment {
@@ -76,6 +80,17 @@ describe("mobile overview review status", () => {
7680
});
7781
});
7882

83+
describe("mobile review state spelling", () => {
84+
it("reads GitHub's uppercase and Bitbucket's or GitCafe's lowercase verdicts alike", () => {
85+
expect(normalizedReviewState("APPROVED")).toBe("APPROVED");
86+
expect(normalizedReviewState("approved")).toBe("APPROVED");
87+
expect(normalizedReviewState("CHANGES_REQUESTED")).toBe("CHANGES_REQUESTED");
88+
expect(normalizedReviewState("changes_requested")).toBe("CHANGES_REQUESTED");
89+
expect(normalizedReviewState("commented")).toBe("COMMENTED");
90+
expect(normalizedReviewState(null)).toBeUndefined();
91+
});
92+
});
93+
7994
describe("mobile overview check status", () => {
8095
it("prioritizes failed checks while others are running", () => {
8196
expect(

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,20 @@ export function pullRequestChecksSummary(pr: Pick<PullRequestDetail, "checks">)
135135
} as const;
136136
}
137137

138+
// GitHub and Forgejo send uppercase review states; Bitbucket and GitCafe send lowercase.
139+
export function normalizedReviewState(reviewState: string | null) {
140+
return reviewState?.toUpperCase().replaceAll("-", "_");
141+
}
142+
138143
export function pullRequestReviewSummary(
139144
pr: Pick<PullRequestDetail, "reviewers">,
140145
activity: Pick<PullRequestActivity, "comments" | "commits"> | null,
141146
) {
142147
const latest = new Map<string, PullRequestActivity["comments"][number]>();
143148
const comments = new Map<string, PullRequestActivity["comments"][number]>();
144149
for (const review of activity?.comments ?? []) {
145-
if (review.kind !== "review" || !review.reviewState) continue;
146-
const state = review.reviewState.toUpperCase().replaceAll("-", "_");
150+
const state = normalizedReviewState(review.reviewState);
151+
if (review.kind !== "review" || !state) continue;
147152
const key = review.author?.login ?? review.id;
148153
if (state === "COMMENTED") {
149154
const previous = comments.get(key);

0 commit comments

Comments
 (0)