дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
A watch row's context menu in the Variables view gets Remove All Watches next to Remove Watch; it empties the project's stored watch list. Verified with debugger and locale vitest and typecheck; main merged in (locale conflict resolved). Co-authored-by: mansur-akhmadi <[email protected]>
67 рядки
1.9 KiB
TypeScript
67 рядки
1.9 KiB
TypeScript
import { beforeEach, describe, expect, it } from "vitest";
|
|
import { addWatch, loadWatches, removeAllWatches, useDebug } from "../state";
|
|
|
|
const SHARED = "openidea.debugger.watches";
|
|
const of = (root: string) => `${SHARED}:${root}`;
|
|
const watches = () => useDebug.getState().watches;
|
|
|
|
beforeEach(() => {
|
|
localStorage.clear();
|
|
loadWatches(null);
|
|
});
|
|
|
|
describe("watch storage", () => {
|
|
it("loads a project's own watches", () => {
|
|
localStorage.setItem(of("/a"), '["x"]');
|
|
loadWatches("/a");
|
|
expect(watches()).toEqual(["x"]);
|
|
});
|
|
|
|
it("starts a project from the shared list once", () => {
|
|
localStorage.setItem(SHARED, '["legacy"]');
|
|
loadWatches("/b");
|
|
expect(watches()).toEqual(["legacy"]);
|
|
expect(localStorage.getItem(of("/b"))).toBe('["legacy"]');
|
|
expect(localStorage.getItem(SHARED)).toBe('["legacy"]');
|
|
});
|
|
|
|
it("keeps projects apart", () => {
|
|
loadWatches("/a");
|
|
addWatch("y");
|
|
loadWatches("/b");
|
|
expect(watches()).not.toContain("y");
|
|
loadWatches("/a");
|
|
expect(watches()).toContain("y");
|
|
});
|
|
|
|
it("an emptied list stays empty", () => {
|
|
localStorage.setItem(SHARED, '["legacy"]');
|
|
localStorage.setItem(of("/a"), "[]");
|
|
loadWatches("/a");
|
|
expect(watches()).toEqual([]);
|
|
});
|
|
|
|
it("Remove All Watches empties the project's stored list", () => {
|
|
localStorage.setItem(SHARED, '["legacy"]');
|
|
loadWatches("/a");
|
|
addWatch("x");
|
|
addWatch("y");
|
|
loadWatches("/b");
|
|
addWatch("z");
|
|
loadWatches("/a");
|
|
removeAllWatches();
|
|
expect(watches()).toEqual([]);
|
|
expect(localStorage.getItem(of("/a"))).toBe("[]");
|
|
loadWatches("/a");
|
|
expect(watches()).toEqual([]);
|
|
loadWatches("/b");
|
|
expect(watches()).toEqual(["legacy", "z"]);
|
|
});
|
|
|
|
it("without a project nothing is stored", () => {
|
|
loadWatches(null);
|
|
addWatch("z");
|
|
expect(localStorage.length).toBe(0);
|
|
});
|
|
});
|