Skip to content

Commit 51df7ba

Browse files
PR Batch Testerclaude
andcommitted
test: trim ghq clone layout tests to the behavior they guard
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6f6bf47 commit 51df7ba

3 files changed

Lines changed: 15 additions & 155 deletions

File tree

‎apps/mobile/src/features/projects/AddProjectScreen.logic.test.ts‎

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -30,62 +30,28 @@ describe("resolveAddProjectEnvironment", () => {
3030
});
3131

3232
describe("isMissingCloneParentBrowseFailure", () => {
33-
const missing = new FilesystemBrowseError({
34-
partialPath: "/ghq/example.test/acme/",
35-
failure: "read_directory_failed",
36-
pathMissing: true,
37-
});
38-
39-
it("treats an unreadable clone parent as a folder the clone will create", () => {
40-
expect(isMissingCloneParentBrowseFailure({ cloning: true, failure: missing })).toBe(true);
33+
it("treats only a missing folder as one the clone will create", () => {
34+
const missing = new FilesystemBrowseError({
35+
partialPath: "/ghq/example.test/acme/",
36+
failure: "read_directory_failed",
37+
pathMissing: true,
38+
});
4139
// The RPC client hands over the decoded wire error, not the server's instance.
4240
const decoded = decodeBrowseError(encodeBrowseError(missing));
4341
expect(isMissingCloneParentBrowseFailure({ cloning: true, failure: decoded })).toBe(true);
44-
});
45-
46-
it("keeps reporting the folder outside a clone and other browse failures", () => {
4742
expect(isMissingCloneParentBrowseFailure({ cloning: false, failure: missing })).toBe(false);
48-
// A file in the way (ENOTDIR) or an I/O error is a real problem cloning would not fix.
49-
const unreadable = new FilesystemBrowseError({
43+
const fileInTheWay = new FilesystemBrowseError({
5044
partialPath: "/repos/file.txt/",
5145
failure: "read_directory_failed",
5246
});
53-
expect(isMissingCloneParentBrowseFailure({ cloning: true, failure: unreadable })).toBe(false);
54-
expect(
55-
isMissingCloneParentBrowseFailure({
56-
cloning: true,
57-
failure: decodeBrowseError(encodeBrowseError(unreadable)),
58-
}),
59-
).toBe(false);
60-
expect(
61-
isMissingCloneParentBrowseFailure({
62-
cloning: true,
63-
failure: new FilesystemBrowseError({
64-
partialPath: "C:\\repo",
65-
failure: "windows_path_unsupported",
66-
}),
67-
}),
68-
).toBe(false);
69-
expect(
70-
isMissingCloneParentBrowseFailure({ cloning: true, failure: new Error("offline") }),
71-
).toBe(false);
47+
expect(isMissingCloneParentBrowseFailure({ cloning: true, failure: fileInTheWay })).toBe(false);
7248
});
7349
});
7450

7551
describe("createDestinationPathOwner", () => {
76-
function owner() {
77-
const committed: string[] = [];
78-
return { committed, paths: createDestinationPathOwner((path) => committed.push(path)) };
79-
}
80-
81-
it("fills an untouched destination with a suggestion", () => {
82-
const { committed, paths } = owner();
83-
paths.suggest("/ghq/github.com/acme/repo");
84-
expect(committed).toEqual(["/ghq/github.com/acme/repo"]);
85-
});
86-
8752
it("keeps a folder picked before a late suggestion", async () => {
88-
const { committed, paths } = owner();
53+
const committed: string[] = [];
54+
const paths = createDestinationPathOwner((path) => committed.push(path));
8955
const preload = Promise.withResolvers<void>();
9056
const navigation = paths.navigate("/work/repo", () => preload.promise);
9157

@@ -96,34 +62,19 @@ describe("createDestinationPathOwner", () => {
9662
expect(committed).toEqual(["/work/repo"]);
9763
});
9864

99-
it("keeps a destination typed back to the flat default", () => {
100-
const { committed, paths } = owner();
101-
paths.edit("~/repo");
102-
paths.suggest("/ghq/github.com/acme/repo");
103-
expect(committed).toEqual(["~/repo"]);
104-
});
105-
106-
it("marks typed and picked destinations as explicit so they skip a pending suggestion", async () => {
65+
it("lets suggestions fill the field until the user types, and again after a reset", () => {
10766
const commits: Array<[string, boolean]> = [];
10867
const paths = createDestinationPathOwner((path, explicit) => commits.push([path, explicit]));
10968
paths.suggest("/ghq/github.com/acme/repo");
11069
paths.edit("~/typed");
111-
await paths.navigate("/work/repo", async () => {});
11270
paths.suggest("/ghq/github.com/acme/late");
11371
paths.reset("~/repo");
72+
paths.suggest("/ghq/github.com/acme/next");
11473
expect(commits).toEqual([
11574
["/ghq/github.com/acme/repo", false],
11675
["~/typed", true],
117-
["/work/repo", true],
11876
["~/repo", false],
77+
["/ghq/github.com/acme/next", false],
11978
]);
12079
});
121-
122-
it("lets a new environment's default take suggestions again", () => {
123-
const { committed, paths } = owner();
124-
paths.edit("/work/repo");
125-
paths.reset("~/repo");
126-
paths.suggest("/ghq/github.com/acme/repo");
127-
expect(committed).toEqual(["/work/repo", "~/repo", "/ghq/github.com/acme/repo"]);
128-
});
12980
});

‎apps/server/src/sourceControl/SourceControlRepositoryService.test.ts‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -725,20 +725,6 @@ it.effect("nests clones under the base directory before ghq's own root", () =>
725725
}),
726726
);
727727

728-
it.effect("uses the first GHQ_ROOT entry when the base directory is empty", () =>
729-
Effect.gen(function* () {
730-
const result = yield* suggestDestination({
731-
remoteUrl: "https://github.com/octocat/t3code.git",
732-
env: { GHQ_ROOT: ":/env/ghq:/env/other" },
733-
ghqConfig: { exitCode: 0, stdout: "/srv/ghq\0" },
734-
});
735-
assert.deepStrictEqual(result, {
736-
destinationPath: "/env/ghq/github.com/octocat/t3code",
737-
gitCalls: [],
738-
});
739-
}),
740-
);
741-
742728
it.effect("uses the last ghq.root value as the primary root, like ghq root", () =>
743729
Effect.gen(function* () {
744730
const result = yield* suggestDestination({
@@ -756,19 +742,3 @@ it.effect("uses the last ghq.root value as the primary root, like ghq root", ()
756742
});
757743
}),
758744
);
759-
760-
it.effect("falls back to ~/ghq when nothing configures a root", () =>
761-
Effect.gen(function* () {
762-
const result = yield* suggestDestination({ remoteUrl: "https://github.com/octocat/t3code" });
763-
assert.strictEqual(result.destinationPath, "/home/me/ghq/github.com/octocat/t3code");
764-
}),
765-
);
766-
767-
it.effect("leaves local and unsafe URLs to the flat default", () =>
768-
Effect.gen(function* () {
769-
for (const remoteUrl of ["/srv/git/repo.git", "https://github.com/owner/../../etc"]) {
770-
const result = yield* suggestDestination({ remoteUrl });
771-
assert.deepStrictEqual(result, { destinationPath: null, gitCalls: [] });
772-
}
773-
}),
774-
);

‎packages/shared/src/cloneUrl.test.ts‎

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -39,86 +39,25 @@ describe("cloneUrlRepositoryPath", () => {
3939
it("splits every transport into host and repository path, like ghq", () => {
4040
const expected = { host: "github.com", segments: ["pingdotgg", "t3code"] };
4141
expect(cloneUrlRepositoryPath("https://github.com/pingdotgg/t3code.git")).toEqual(expected);
42-
expect(cloneUrlRepositoryPath("https://[email protected]/pingdotgg/t3code/")).toEqual(expected);
4342
expect(cloneUrlRepositoryPath("[email protected]:pingdotgg/t3code.git")).toEqual(expected);
4443
expect(cloneUrlRepositoryPath("ssh://[email protected]:2222/pingdotgg/t3code.git")).toEqual(
4544
expected,
4645
);
47-
expect(cloneUrlRepositoryPath("git@github-work:pingdotgg/t3code.git")).toEqual({
48-
...expected,
49-
host: "github-work",
50-
});
51-
});
52-
53-
it("keeps nested groups and drops ports, queries and fragments", () => {
54-
expect(cloneUrlRepositoryPath("https://gitlab.com:8443/group/sub/repo.git?x=1#y")).toEqual({
46+
expect(cloneUrlRepositoryPath("https://gitlab.com/group/sub/repo.git?x=1")).toEqual({
5547
host: "gitlab.com",
5648
segments: ["group", "sub", "repo"],
5749
});
5850
});
5951

60-
it("refuses local paths and segments that could leave the root", () => {
52+
it("refuses local paths and folders that could leave the root or break on Windows", () => {
6153
for (const url of [
62-
"",
6354
"/srv/git/repo.git",
6455
"file:///srv/git/repo.git",
65-
"C:\\Users\\me\\repo",
66-
"./repo",
67-
"https://github.com/",
68-
"https://github.com/.git",
6956
"https://github.com/owner/../../etc",
70-
"https://github.com/owner/./repo",
71-
"[email protected]:owner\\..\\repo",
72-
"git@..:owner/repo",
73-
"https://github.com/owner/re:po",
74-
"https://github.com/owner/re\u0000po",
75-
]) {
76-
expect(cloneUrlRepositoryPath(url), url).toBeNull();
77-
}
78-
});
79-
80-
it("refuses folder names Windows cannot create", () => {
81-
for (const url of [
82-
"https://git.example/team/AUX/repo.git",
83-
"https://git.example/team/aux.txt/repo.git",
84-
"https://git.example/team/Con/repo.git",
85-
"https://git.example/team/nul.tar.gz/repo.git",
86-
"https://git.example/team/com1/repo.git",
87-
"https://git.example/team/LPT9.log/repo.git",
88-
"https://git.example/team/com\u00b9/repo.git",
89-
"git@prn:team/repo.git",
90-
"https://git.example/team/LPT0/repo.git",
91-
"https://git.example/team/lpt0.log/repo.git",
92-
"https://git.example/team/CONIN$/repo.git",
93-
"https://git.example/team/conout$.log/repo.git",
94-
"https://git.example/team/ConIn$ .txt/repo.git",
9557
"https://git.example/team/AUX .txt/repo.git",
96-
"https://git.example/team/COM1 .log/repo.git",
9758
"https://git.example/team./repo.git",
98-
"https://git.example/team /repo.git",
9959
]) {
10060
expect(cloneUrlRepositoryPath(url), url).toBeNull();
10161
}
10262
});
103-
104-
it("keeps names that only resemble reserved ones", () => {
105-
expect(
106-
cloneUrlRepositoryPath(
107-
"https://git.example/auxiliary/con-tools/com10/COM0/LPT10/nul2/AUX xyz.txt/conin/.github.git",
108-
),
109-
).toEqual({
110-
host: "git.example",
111-
segments: [
112-
"auxiliary",
113-
"con-tools",
114-
"com10",
115-
"COM0",
116-
"LPT10",
117-
"nul2",
118-
"AUX xyz.txt",
119-
"conin",
120-
".github",
121-
],
122-
});
123-
});
12463
});

0 commit comments

Comments
 (0)