deer-flow/frontend/tests/unit/core/settings/thread-model-selection.dom.test.ts
Totoro 0baa99ca90
feat(models): add scoped model controls to Web chats (#7249)
* test: stabilize reporter evidence and guard missing chat nodes

* feat(models): scope Web model choices to tasks, turns and conversations

* test(e2e): mock model-control preview for ordinary chat submissions

* fix(models): harden scoped choices and stale Agent submissions

---------

Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
2026-10-22 08:08:23 +08:00

32 lines
1.1 KiB
TypeScript

import { afterEach, expect, it, rs } from "@rstest/core";
import { safeLocalStorage } from "@/core/settings/local";
import {
getBaseSettingsSnapshot,
getThreadModelSnapshot,
selectThreadModel,
updateLocalSettings,
} from "@/core/settings/store";
afterEach(() => {
rs.restoreAllMocks();
});
it("does not claim to save a default when browser storage rejects the write", () => {
rs.spyOn(safeLocalStorage, "setItem").mockReturnValue(false);
expect(() => selectThreadModel("blocked-write-thread", "model-B")).toThrow();
expect(getThreadModelSnapshot("blocked-write-thread")).toBeUndefined();
});
it("persists only the selected conversation without editing account preferences", () => {
updateLocalSettings("context", { model_name: "parent-A" });
const before = getBaseSettingsSnapshot();
selectThreadModel("selection-test-thread", "model-B");
expect(getThreadModelSnapshot("selection-test-thread")).toBe("model-B");
expect(getBaseSettingsSnapshot()).toBe(before);
expect(getThreadModelSnapshot("unrelated-test-thread")).toBeUndefined();
expect(
localStorage.getItem("deerflow.thread-model.selection-test-thread"),
).toBe("model-B");
});