F1: conflict toast closes when the merge ends, toasts keep off the commit box

The merge store dismisses its conflict warning once the status lists no
conflicted file (resolved, committed or aborted) and replaces it on a new
conflicted merge. The toast stack moves above areas registered with
keepClearOf; the Changes window registers its commit box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-02 18:53:08 +01:00
parent e228d11ef9
commit 750ecf5e51
7 changed files with 235 additions and 9 deletions

View file

@ -3,7 +3,8 @@
* a toast, auto-dismiss of info toasts with fake timers, the overflow into
* "+n more", ARIA roles, keyboard closing, engine `notification` and
* `watchFailed` events (including untrusted fields), and the replay
* duplicate guard.
* duplicate guard, and keeping the stack off registered areas such as the
* commit box.
*/
import { mount, type VueWrapper } from "@vue/test-utils";
import { createPinia, setActivePinia, type Pinia } from "pinia";
@ -21,6 +22,8 @@ import {
MAX_VISIBLE,
notificationFromEvent,
notificationText,
STACK_BOTTOM,
stackBottom,
useNotificationsStore,
} from "../../src/stores/notifications";
@ -277,3 +280,33 @@ describe("NotificationStack", () => {
expect(stack.find('[data-test="toast"]').exists()).toBe(false);
});
});
describe("keeping areas clear", () => {
it("places the stack above an area it would cover, and ignores hidden or distant ones", () => {
const box = { left: 0, right: 1000, top: 700, bottom: 780 };
expect(stackBottom(1000, 800, [])).toBe(STACK_BOTTOM);
expect(stackBottom(1000, 800, [box])).toBe(108);
expect(stackBottom(1000, 800, [{ left: 0, right: 0, top: 0, bottom: 0 }])).toBe(STACK_BOTTOM);
expect(stackBottom(1000, 800, [{ ...box, right: 500 }])).toBe(STACK_BOTTOM);
expect(stackBottom(1000, 800, [box, { ...box, top: 600 }])).toBe(208);
});
it("moves the shown stack above a registered element until it is released", async () => {
Object.assign(window, { innerWidth: 1000, innerHeight: 800 });
const store = useNotificationsStore();
const commit = document.createElement("form");
commit.getBoundingClientRect = () => new DOMRect(0, 700, 1000, 80);
document.body.append(commit);
store.notify({ level: "warning", message: "conflicts" });
const stack = mountStack();
await stack.vm.$nextTick();
expect(stack.get('[data-test="toasts"]').attributes("style")).toContain(`bottom: ${String(STACK_BOTTOM)}px`);
const release = store.keepClearOf(commit);
await stack.vm.$nextTick();
expect(stack.get('[data-test="toasts"]').attributes("style")).toContain("bottom: 108px");
release();
await stack.vm.$nextTick();
expect(stack.get('[data-test="toasts"]').attributes("style")).toContain(`bottom: ${String(STACK_BOTTOM)}px`);
commit.remove();
});
});

View file

@ -383,6 +383,15 @@ describe("the Changes store", () => {
});
describe("the Changes window", () => {
it("keeps toasts off the commit box while it is mounted", async () => {
const wrapper = await mountChanges();
const notifications = useNotificationsStore(pinia);
expect(notifications.keepClear).toEqual([wrapper.get("[data-test=changes-commit]").element]);
mounted = mounted.filter((m) => m !== wrapper);
wrapper.unmount();
expect(notifications.keepClear).toEqual([]);
});
it("shows the branch, the counts and the three groups", async () => {
const wrapper = await mountChanges();
expect(wrapper.get("[data-test=changes-status]").text()).toBe("main: 3 staged, 2 changed, 1 untracked");

View file

@ -416,6 +416,29 @@ describe("merging", () => {
expect(useNotificationsStore(pinia).toasts.some((n) => n.text.includes("cancelled"))).toBe(true);
});
it("closes the conflict toast once no conflict is left, and a new conflicted merge replaces it", async () => {
await mountDialog();
const notifications = useNotificationsStore(pinia);
const conflictToasts = (): number => notifications.toasts.filter((n) => n.text.includes("stopped on conflicts")).length;
await runCommand("vcs.merge", { branch: "feature" });
await runCommand("vcs.merge", { branch: "feature" });
expect(conflictToasts()).toBe(1);
gitStatus = { ...gitStatus, files: [{ path: "b.php", index: "modified", worktree: "unmodified" }] };
await useVcsStatusStore(pinia).refresh();
await flushPromises();
expect(conflictToasts()).toBe(0);
});
it("closes the conflict toast when the merge is aborted", async () => {
const wrapper = await mountDialog();
await runCommand("vcs.merge", { branch: "feature" });
expect(useNotificationsStore(pinia).toasts.some((n) => n.text.includes("stopped on conflicts"))).toBe(true);
await runCommand("vcs.abortMerge");
await wrapper.get("[data-test=merge-abort]").trigger("click");
await flushPromises();
expect(useNotificationsStore(pinia).toasts.some((n) => n.text.includes("stopped on conflicts"))).toBe(false);
});
it("lists the other branches and merges the one chosen", async () => {
const wrapper = await mountDialog();
await runCommand("vcs.merge");