Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit 2c40bfe

Browse files
test(mobile): cover repository selection policies
Generated-By: PostHog Code Task-Id: c1bbe3cf-742b-4b24-bf96-d11a18b4cf22
1 parent a53c8f4 commit 2c40bfe

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

‎apps/mobile/src/features/tasks/utils/repositorySelection.test.ts‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { describe, expect, it } from "vitest";
22
import {
33
buildRepositoryOptions,
4+
buildUserRepositoryOptions,
45
findRepositoryOption,
56
isRepositorySelectionComplete,
7+
repositoryLoadWarning,
8+
repositoryOptionsEqual,
69
toRepositorySelection,
710
} from "./repositorySelection";
811

@@ -59,6 +62,52 @@ describe("repositorySelection", () => {
5962
});
6063
});
6164

65+
it.each([
66+
[{ installation_id: "42", account: { name: "PostHog" } }, "PostHog"],
67+
[{ installation_id: "43" }, "GitHub 43"],
68+
])(
69+
"builds user integration options with the expected label",
70+
(integration, integrationLabel) => {
71+
expect(
72+
buildUserRepositoryOptions([integration], {
73+
[integration.installation_id]: ["posthog/code"],
74+
}),
75+
).toEqual([
76+
{
77+
integrationId: Number(integration.installation_id),
78+
integrationLabel,
79+
repository: "posthog/code",
80+
},
81+
]);
82+
},
83+
);
84+
85+
it("treats a changed label as a different repository option", () => {
86+
const option = {
87+
integrationId: 11,
88+
integrationLabel: "posthog",
89+
repository: "posthog/code",
90+
};
91+
92+
expect(
93+
repositoryOptionsEqual(
94+
[option],
95+
[{ ...option, integrationLabel: "PostHog GitHub" }],
96+
),
97+
).toBe(false);
98+
});
99+
100+
it.each([
101+
[0, 2, null],
102+
[1, 2, "Some GitHub repositories could not be loaded. Pull to retry."],
103+
[2, 2, "Could not load GitHub repositories. Pull to retry."],
104+
])(
105+
"maps repository failures to the expected warning",
106+
(failedCount, totalCount, expected) => {
107+
expect(repositoryLoadWarning(failedCount, totalCount)).toBe(expected);
108+
},
109+
);
110+
62111
it("converts an option into a repository selection", () => {
63112
const selection = toRepositorySelection({
64113
integrationId: 11,

0 commit comments

Comments
 (0)