mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
A failed Maven/Gradle reload left its error balloon on screen after a later reload succeeded: syncTool notified on failure under build-sync-<tool> but never expired that key on success. A clean sync now expires it (the Notifications tool window keeps the entry). The same holds for the language-server prompts (not installed, JDK required, outdated build): a server turning ready expires them, for when the fix came from a settings page rather than the prompt's button. expireNotification leaves the state untouched when no balloon is shown. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com>
40 lines
1.7 KiB
TypeScript
40 lines
1.7 KiB
TypeScript
import { afterEach, describe, expect, it } from "vitest";
|
|
import { useProject } from "@/platform/project";
|
|
import { activateWorkbench } from "./activate";
|
|
import { expireNotification, notify, useNotifications } from "./notificationStore";
|
|
|
|
afterEach(() => {
|
|
useNotifications.setState({ items: [] });
|
|
useProject.setState({ project: null, lightEdit: false });
|
|
});
|
|
|
|
describe("notifications across project changes", () => {
|
|
it("keeps app-level update notifications and drops project ones", () => {
|
|
useProject.setState({
|
|
project: { root: "/p", name: "p", trusted: true, isGit: false, settings: {} } as never,
|
|
});
|
|
const dispose = activateWorkbench();
|
|
try {
|
|
notify({ level: "info", title: "Downloading OpenIDEA 0.1.35", key: "app.update", sticky: true });
|
|
notify({ level: "info", title: "Git refresh failed", group: "vcs" });
|
|
useProject.setState({ project: null });
|
|
expect(useNotifications.getState().items.map((n) => n.title)).toEqual(["Downloading OpenIDEA 0.1.35"]);
|
|
} finally {
|
|
dispose();
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("expiring a notification", () => {
|
|
it("hides its balloon, keeps it in the log, and leaves the state alone when nothing is shown", () => {
|
|
notify({ level: "error", title: "Cannot reload Maven projects", key: "build-sync-maven" });
|
|
expireNotification("build-sync-maven");
|
|
const [item] = useNotifications.getState().items;
|
|
expect(item).toMatchObject({ title: "Cannot reload Maven projects", balloon: false });
|
|
const before = useNotifications.getState();
|
|
expireNotification("build-sync-maven");
|
|
expireNotification("unknown");
|
|
expect(useNotifications.getState()).toBe(before);
|
|
});
|
|
});
|