feat(mobile): show PR badge on task list rows (port #2422)#2496
feat(mobile): show PR badge on task list rows (port #2422)#2496Gilbert09 wants to merge 2 commits into
Conversation
Adds a compact pull-request badge to each task row in the mobile task list, mirroring the desktop sidebar behavior (#2422). When a task has a PR url (`latest_run.output.pr_url`), the badge shows the PR number and opens the PR on tap, taking the timestamp's slot. Reuses the existing `parseGithubIssueUrl` helper to extract the PR number. Generated-By: PostHog Code Task-Id: eb5935b3-fcab-4471-b623-693834c6017e
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/mobile/src/features/tasks/components/TaskItem.test.tsx:64-90
**Prefer parameterised tests for the "no badge" cases**
The team rule is to prefer parameterised tests. The single "does not show the PR badge when there is no PR url" case only exercises `latest_run: undefined`. Other no-badge paths — `output: null`, a GitHub *issue* URL (`/issues/42`), or a non-GitHub URL — are untested and aren't obviously covered by the parser's own suite. A `it.each` table would cover all of these without duplicating the assertion logic.
Reviews (1): Last reviewed commit: "feat(mobile): show PR badge on task list..." | Re-trigger Greptile |
| }); | ||
| return renderer; | ||
| } | ||
|
|
||
| describe("TaskItem", () => { | ||
| function prIcons(renderer: ReturnType<typeof create>) { | ||
| return renderer.root.findAll( | ||
| (node) => String(node.type) === "GitPullRequest", | ||
| ); | ||
| } | ||
|
|
||
| it("shows the PR badge with the parsed number when a PR url is present", () => { | ||
| const renderer = render( | ||
| makeTask("https://github.com/PostHog/code/pull/2422"), | ||
| ); | ||
|
|
||
| expect(prIcons(renderer)).toHaveLength(1); | ||
| const number = renderer.root.findAll( | ||
| (node) => String(node.type) === "Text" && node.props.children === "#2422", | ||
| ); | ||
| expect(number).toHaveLength(1); | ||
| }); | ||
|
|
||
| it("does not show the PR badge when there is no PR url", () => { | ||
| expect(prIcons(render(makeTask()))).toHaveLength(0); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Prefer parameterised tests for the "no badge" cases
The team rule is to prefer parameterised tests. The single "does not show the PR badge when there is no PR url" case only exercises latest_run: undefined. Other no-badge paths — output: null, a GitHub issue URL (/issues/42), or a non-GitHub URL — are untested and aren't obviously covered by the parser's own suite. A it.each table would cover all of these without duplicating the assertion logic.
Context Used: Do not attempt to comment on incorrect alphabetica... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/mobile/src/features/tasks/components/TaskItem.test.tsx
Line: 64-90
Comment:
**Prefer parameterised tests for the "no badge" cases**
The team rule is to prefer parameterised tests. The single "does not show the PR badge when there is no PR url" case only exercises `latest_run: undefined`. Other no-badge paths — `output: null`, a GitHub *issue* URL (`/issues/42`), or a non-GitHub URL — are untested and aren't obviously covered by the parser's own suite. A `it.each` table would cover all of these without duplicating the assertion logic.
**Context Used:** Do not attempt to comment on incorrect alphabetica... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Covers the additional no-badge paths via it.each: null output, a GitHub issue url (kind !== "pr"), and a non-GitHub url — alongside the no-run case. Generated-By: PostHog Code Task-Id: eb5935b3-fcab-4471-b623-693834c6017e
Summary
Ports desktop PR #2422 (PR badge in the sidebar task list) to the mobile app.
Mobile already showed a PR status badge on the task detail screen, but not on the task list rows. This adds a compact, tappable PR badge to each task row: when a task has a PR url (
latest_run.output.pr_url), the row shows aGitPullRequesticon +#<number>in place of the timestamp, and tapping it opens the PR viaLinking.openURL.Details
TaskItem.tsx: new inlinePrBadge(small pill consistent with mobile styling). The PR number is parsed with the existingparseGithubIssueUrlhelper (@/lib/githubIssueUrl) — no new parser added, and the desktop@posthog/gitparser isn't bundle-compatible (depends on the Node-onlygit-url-parse).Tests
TaskItem.test.tsx: badge shown whenpr_urlpresent (with correct parsed number), hidden when absent.pnpm --filter @posthog/mobile testandbiome checkboth green;tscclean on the changed files.