mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:10:44 +00:00
test: merge small view render cases
This commit is contained in:
@@ -65,55 +65,7 @@ function buildProps(result: SessionsListResult): SessionsProps {
|
||||
}
|
||||
|
||||
describe("sessions view", () => {
|
||||
it("renders verbose=full without falling back to inherit", async () => {
|
||||
const container = document.createElement("div");
|
||||
render(
|
||||
renderSessions(
|
||||
buildProps(
|
||||
buildResult({
|
||||
key: "agent:main:main",
|
||||
kind: "direct",
|
||||
updatedAt: Date.now(),
|
||||
verboseLevel: "full",
|
||||
}),
|
||||
),
|
||||
),
|
||||
container,
|
||||
);
|
||||
await Promise.resolve();
|
||||
|
||||
const selects = container.querySelectorAll("select");
|
||||
const verbose = selects[2] as HTMLSelectElement | undefined;
|
||||
expect(verbose?.value).toBe("full");
|
||||
expect(Array.from(verbose?.options ?? []).some((option) => option.value === "full")).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps unknown stored values selectable instead of forcing inherit", async () => {
|
||||
const container = document.createElement("div");
|
||||
render(
|
||||
renderSessions(
|
||||
buildProps(
|
||||
buildResult({
|
||||
key: "agent:main:main",
|
||||
kind: "direct",
|
||||
updatedAt: Date.now(),
|
||||
reasoningLevel: "custom-mode",
|
||||
}),
|
||||
),
|
||||
),
|
||||
container,
|
||||
);
|
||||
await Promise.resolve();
|
||||
|
||||
const selects = container.querySelectorAll("select");
|
||||
const reasoning = selects[3] as HTMLSelectElement | undefined;
|
||||
expect(reasoning?.value).toBe("custom-mode");
|
||||
expect(
|
||||
Array.from(reasoning?.options ?? []).some((option) => option.value === "custom-mode"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("renders explicit fast mode without falling back to inherit", async () => {
|
||||
it("keeps explicit and unknown session setting values selectable", async () => {
|
||||
const container = document.createElement("div");
|
||||
render(
|
||||
renderSessions(
|
||||
@@ -123,6 +75,8 @@ describe("sessions view", () => {
|
||||
kind: "direct",
|
||||
updatedAt: Date.now(),
|
||||
fastMode: true,
|
||||
verboseLevel: "full",
|
||||
reasoningLevel: "custom-mode",
|
||||
}),
|
||||
),
|
||||
),
|
||||
@@ -132,7 +86,15 @@ describe("sessions view", () => {
|
||||
|
||||
const selects = container.querySelectorAll("select");
|
||||
const fast = selects[1] as HTMLSelectElement | undefined;
|
||||
const verbose = selects[2] as HTMLSelectElement | undefined;
|
||||
const reasoning = selects[3] as HTMLSelectElement | undefined;
|
||||
expect(fast?.value).toBe("on");
|
||||
expect(verbose?.value).toBe("full");
|
||||
expect(Array.from(verbose?.options ?? []).some((option) => option.value === "full")).toBe(true);
|
||||
expect(reasoning?.value).toBe("custom-mode");
|
||||
expect(
|
||||
Array.from(reasoning?.options ?? []).some((option) => option.value === "custom-mode"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("deselects only the current page from the header checkbox", async () => {
|
||||
|
||||
@@ -98,34 +98,14 @@ describe("renderSkills", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("opens the skill detail dialog as a modal", async () => {
|
||||
it("opens the skill detail dialog as a modal and routes close events", async () => {
|
||||
const container = document.createElement("div");
|
||||
const onDetailClose = vi.fn();
|
||||
const showModal = vi.fn(function (this: HTMLDialogElement) {
|
||||
this.setAttribute("open", "");
|
||||
});
|
||||
|
||||
installDialogMethod("showModal", showModal);
|
||||
|
||||
render(
|
||||
renderSkills(
|
||||
createProps({
|
||||
detailKey: "repo-skill",
|
||||
}),
|
||||
),
|
||||
container,
|
||||
);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(showModal).toHaveBeenCalledTimes(1);
|
||||
expect(container.querySelector("dialog")?.hasAttribute("open")).toBe(true);
|
||||
});
|
||||
|
||||
it("closes the skill detail dialog through the dialog close event", async () => {
|
||||
const container = document.createElement("div");
|
||||
const onDetailClose = vi.fn();
|
||||
|
||||
installDialogMethod("showModal", function (this: HTMLDialogElement) {
|
||||
this.setAttribute("open", "");
|
||||
});
|
||||
installDialogMethod("close", function (this: HTMLDialogElement) {
|
||||
this.removeAttribute("open");
|
||||
this.dispatchEvent(new Event("close"));
|
||||
@@ -142,6 +122,9 @@ describe("renderSkills", () => {
|
||||
);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(showModal).toHaveBeenCalledTimes(1);
|
||||
expect(container.querySelector("dialog")?.hasAttribute("open")).toBe(true);
|
||||
|
||||
container.querySelector<HTMLButtonElement>(".md-preview-dialog__header .btn")?.click();
|
||||
|
||||
expect(onDetailClose).toHaveBeenCalledTimes(1);
|
||||
|
||||
Reference in New Issue
Block a user