A3: add untracked files to .gitignore from the Changes context menu
git.ignore appends one anchored, escaped literal pattern per path to the work tree root's .gitignore, skipping patterns already there. The Changes window gets a row context menu (right click, Shift+F10, context-menu key) with Open and Add to .gitignore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ce681871ad
commit
68599fa2ac
14 changed files with 633 additions and 5 deletions
|
|
@ -430,6 +430,35 @@ describe("the Changes window", () => {
|
|||
expect(callsOf("file.open").map((c) => c.params)).toEqual([{ path: "src/a.php" }]);
|
||||
});
|
||||
|
||||
it("adds an untracked file to .gitignore from its context menu", async () => {
|
||||
const wrapper = await mountChanges();
|
||||
const rows = wrapper.findAll("[data-test=changes-row]");
|
||||
await rows[0]?.trigger("contextmenu", { clientX: 10, clientY: 10 });
|
||||
const items = (): HTMLElement[] => [...document.querySelectorAll<HTMLElement>("[data-test=changes-menu-item]")];
|
||||
expect(items().map((item) => item.dataset.item)).toEqual(["open", "ignore"]);
|
||||
expect(items()[1]?.getAttribute("aria-disabled")).toBe("true");
|
||||
items()[1]?.click();
|
||||
await flushPromises();
|
||||
expect(callsOf("git.ignore")).toHaveLength(0);
|
||||
document.querySelector<HTMLElement>("[data-test=changes-menu]")?.dispatchEvent(
|
||||
new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
|
||||
);
|
||||
await flushPromises();
|
||||
expect(document.querySelector("[data-test=changes-menu]")).toBeNull();
|
||||
|
||||
const list = wrapper.get("[data-test=changes-list]");
|
||||
await list.trigger("keydown", { key: "End" });
|
||||
await list.trigger("keydown", { key: "F10", shiftKey: true });
|
||||
expect(items()[1]?.getAttribute("aria-disabled")).toBe("false");
|
||||
const refreshes = callsOf("git.status").length;
|
||||
items()[1]?.click();
|
||||
await flushPromises();
|
||||
expect(callsOf("git.ignore").map((c) => c.params)).toEqual([{ paths: ["tmp.txt"] }]);
|
||||
expect(callsOf("git.status").length).toBe(refreshes + 1);
|
||||
expect(useNotificationsStore(pinia).toasts.map((toast) => toast.text)).toContain("Added to .gitignore: tmp.txt");
|
||||
expect(document.querySelector("[data-test=changes-menu]")).toBeNull();
|
||||
});
|
||||
|
||||
it("opens through vcs.showDiff when it is provided, and never opens a deleted file", async () => {
|
||||
const wrapper = await mountChanges();
|
||||
const rows = wrapper.findAll("[data-test=changes-row]");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue