Skip to content

Commit 9f3176e

Browse files
test(mobile): fold the PR workspace and identity cases into existing tests
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6cef806 commit 9f3176e

2 files changed

Lines changed: 6 additions & 34 deletions

File tree

‎apps/mobile/src/features/threads/new-task-project-selection.test.ts‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ describe("resolveEnvironmentProjectMatch", () => {
8383
makeProject("t3code-clone", "server", { repositoryKey: "github.com/t3tools/t3code" }),
8484
];
8585
expect(resolveEnvironmentProjectMatch(target, selected)).toBe(target[1]);
86+
expect(isSameRepository(target[1]!, selected)).toBe(true);
8687
});
8788

8889
it("falls back to workspace basename, then title, for unindexed projects", () => {
@@ -92,6 +93,7 @@ describe("resolveEnvironmentProjectMatch", () => {
9293
makeProject("srv", "server", { workspaceRoot: "/home/me/t3code" }),
9394
];
9495
expect(resolveEnvironmentProjectMatch(byBasename, selected)).toBe(byBasename[1]);
96+
expect(isSameRepository(byBasename[1]!, selected)).toBe(false);
9597

9698
const byTitle = [
9799
makeProject("other", "server"),
@@ -114,21 +116,6 @@ describe("resolveEnvironmentProjectMatch", () => {
114116
expect(resolveEnvironmentProjectMatch([fork, unindexed], selected)).toBe(unindexed);
115117
expect(resolveEnvironmentProjectMatch([fork], selected)).toBe(fork);
116118
});
117-
118-
it("vouches for the same repository only when both identities are known", () => {
119-
const selected = makeProject("t3code", "mac", {
120-
repositoryKey: "github.com/t3tools/t3code",
121-
workspaceRoot: "/Users/me/t3code",
122-
});
123-
const clone = makeProject("clone", "server", { repositoryKey: "github.com/t3tools/t3code" });
124-
const sameName = makeProject("same-name", "server", { workspaceRoot: "/srv/t3code" });
125-
expect(isSameRepository(resolveEnvironmentProjectMatch([clone], selected), selected)).toBe(
126-
true,
127-
);
128-
expect(isSameRepository(resolveEnvironmentProjectMatch([sameName], selected), selected)).toBe(
129-
false,
130-
);
131-
});
132119
});
133120

134121
describe("resolveDraftProjectSelection", () => {

‎apps/mobile/src/state/use-composer-drafts.test.ts‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ describe("mobile composer drafts", () => {
18901890
expect(getComposerDraftSnapshot(second).text).toBe("second idea");
18911891
});
18921892

1893-
it("retargets a new-task draft to another project without losing its text", () => {
1893+
it("retargets a new-task draft to another project, keeping only a pull request workspace", () => {
18941894
const from = {
18951895
environmentId: EnvironmentId.make("environment-1"),
18961896
projectId: ProjectId.make("project-1"),
@@ -1921,35 +1921,20 @@ describe("mobile composer drafts", () => {
19211921
expect(moved.project).toEqual({ ...to, createdAt });
19221922
expect(findNewTaskDraftKeys(appAtomRegistry.get(composerDraftsAtom), from)).toEqual([]);
19231923
expect(findNewTaskDraftKeys(appAtomRegistry.get(composerDraftsAtom), to)).toEqual([key]);
1924-
});
19251924

1926-
it("keeps a pull request worktree selection when the draft moves between machines and back", () => {
1927-
const from = {
1928-
environmentId: EnvironmentId.make("environment-1"),
1929-
projectId: ProjectId.make("project-1"),
1930-
};
1931-
const to = {
1932-
environmentId: EnvironmentId.make("environment-2"),
1933-
projectId: ProjectId.make("project-2"),
1934-
};
19351925
const pullRequestSelection = {
19361926
mode: "worktree" as const,
19371927
branch: "feature/pr-head",
19381928
worktreePath: null,
19391929
startFromOrigin: false,
19401930
pullRequestReference: "https://github.com/acme/repo/pull/42",
19411931
};
1942-
const key = createNewTaskDraft(from);
1943-
setComposerDraftText(key, "Review this PR");
19441932
updateComposerDraftSettings(key, { workspaceSelection: pullRequestSelection });
1945-
1946-
retargetNewTaskDraft(key, to, { keepPullRequestWorkspace: true });
1947-
expect(getComposerDraftSnapshot(key).workspaceSelection).toEqual(pullRequestSelection);
1948-
19491933
retargetNewTaskDraft(key, from, { keepPullRequestWorkspace: true });
19501934
expect(getComposerDraftSnapshot(key).workspaceSelection).toEqual(pullRequestSelection);
1951-
1952-
retargetNewTaskDraft(key, to);
1935+
retargetNewTaskDraft(key, to, { keepPullRequestWorkspace: true });
1936+
expect(getComposerDraftSnapshot(key).workspaceSelection).toEqual(pullRequestSelection);
1937+
retargetNewTaskDraft(key, from);
19531938
expect(getComposerDraftSnapshot(key).workspaceSelection).toBeUndefined();
19541939
});
19551940

0 commit comments

Comments
 (0)