From c75a630ede63283962819675ea8c93651d182d8e Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Fri, 6 Nov 2026 14:14:44 +0800 Subject: [PATCH] test(vcs): check the files a commit takes from its options Commits take the checked files through vcs_commit's options instead of staging them first; the Commit e2e tests now read them from there. Also translates "Remote connection cancelled". --- e2e/commit.spec.ts | 5 +++-- e2e/commitInclusion.spec.ts | 16 ++++++---------- src/platform/locales/text/en.json | 3 ++- src/platform/locales/text/zh.json | 3 ++- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/e2e/commit.spec.ts b/e2e/commit.spec.ts index 6d0c18526..6f2f8af1d 100644 --- a/e2e/commit.spec.ts +++ b/e2e/commit.spec.ts @@ -69,7 +69,8 @@ test("⌘K commits the checked changes with the typed message", async ({ workben await expect(page.getByText(/1 file committed: Return order DTOs from create/)).toBeVisible(); const [committed] = await ipcCalls(page, "vcs_commit"); expect(committed).toMatchObject({ repo: ROOT, message: "Return order DTOs from create" }); - const staged = (await ipcCalls(page, "vcs_stage")).flatMap((a) => a.paths as string[]); - expect(staged).toEqual([`${ROOT}/build.gradle.kts`]); + // The commit takes the checked file itself; the index isn't staged beforehand. + expect((committed!.options as { stage: string[] }).stage).toEqual([`${ROOT}/build.gradle.kts`]); + expect(await ipcCalls(page, "vcs_stage")).toHaveLength(0); await expect(changes.getByRole("checkbox", { name: "Include build.gradle.kts in commit" })).toBeHidden(); }); diff --git a/e2e/commitInclusion.spec.ts b/e2e/commitInclusion.spec.ts index b5a0bda45..b5d0e0380 100644 --- a/e2e/commitInclusion.spec.ts +++ b/e2e/commitInclusion.spec.ts @@ -8,12 +8,11 @@ import { expect, ipcCalls, stubDesktop, test } from "./fixtures"; const ROOT = "/dev/acme-api"; const NAMES = Array.from({ length: 20 }, (_, i) => `src/f${i}.ts`); -/** Twenty modified tracked files; `vcs_stage` + `vcs_commit` take the staged ones out of the status. */ +/** Twenty modified tracked files; `vcs_commit` takes the files it commits out of the status. */ async function stubTwentyChanges(page: Page) { await stubDesktop(page); await page.evaluate( async ({ root, names }) => { - const staged = new Set(); const committed = new Set(); const all = names.map((rel) => ({ path: `${root}/${rel}`, @@ -33,14 +32,10 @@ async function stubTwentyChanges(page: Page) { operation: null, }); h.vcs_status = () => all.filter((f) => !committed.has(f.path)); - h.vcs_stage = (args) => { - for (const path of args.paths as string[]) staged.add(path); - return null; - }; + h.vcs_stage = () => null; h.vcs_unstage = () => null; - h.vcs_commit = () => { - for (const path of staged) committed.add(path); - staged.clear(); + h.vcs_commit = (args) => { + for (const path of (args.options as { stage: string[] }).stage) committed.add(path); return "2222222"; }; const vcsModule = "/src/features/vcs/store.ts"; @@ -71,7 +66,8 @@ test("changes left out of a commit stay unchecked (#1539)", async ({ workbench: await panel.getByRole("textbox", { name: "Commit message" }).fill("Commit 5 of 20"); await panel.getByRole("button", { name: "Commit", exact: true }).click(); await expect(page.getByText(/5 files committed: Commit 5 of 20/)).toBeVisible(); - expect((await ipcCalls(page, "vcs_stage")).flatMap((a) => a.paths as string[]).sort()).toEqual( + const [commit] = await ipcCalls(page, "vcs_commit"); + expect([...(commit!.options as { stage: string[] }).stage].sort()).toEqual( NAMES.slice(0, 5) .map((rel) => `${ROOT}/${rel}`) .sort(), diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 66c7ef7e7..22f787063 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -42,5 +42,6 @@ "Update source": "Update source", "Where updates are downloaded from. If it can't be reached, the other source is tried.": "Where updates are downloaded from. If it can't be reached, the other source is tried.", "Automatic": "Automatic", - "CNB (China mirror)": "CNB (China mirror)" + "CNB (China mirror)": "CNB (China mirror)", + "Remote connection cancelled": "Remote connection cancelled" } diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index c7053ec3e..55d45068c 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -6381,5 +6381,6 @@ "Updates": "更新", "Update source": "更新源", "Where updates are downloaded from. If it can't be reached, the other source is tried.": "从哪里下载更新。无法连接时会改用另一个源。", - "CNB (China mirror)": "CNB(国内镜像)" + "CNB (China mirror)": "CNB(国内镜像)", + "Remote connection cancelled": "远程连接已取消" }