mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import { cleanup, render } from "@testing-library/react";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { ControlOverlay } from "../ControlOverlay";
|
|
|
|
describe("ControlOverlay", () => {
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
it("keeps page blocker none under automationBypass but Interrupt stays clickable", () => {
|
|
const { container } = render(
|
|
<ControlOverlay
|
|
visible={true}
|
|
interrupting={false}
|
|
automationBypass={true}
|
|
onInterrupt={() => {}}
|
|
/>,
|
|
);
|
|
|
|
const blocker = container.querySelector("[data-slot='control-overlay-blocker']");
|
|
expect(blocker).toBeTruthy();
|
|
expect((blocker as HTMLElement).style.pointerEvents).toBe("none");
|
|
|
|
const pill = container.querySelector("[data-slot='control-overlay-pill']");
|
|
expect(pill).toBeTruthy();
|
|
expect((pill as HTMLElement).style.pointerEvents).toBe("auto");
|
|
|
|
const stopBtn = container.querySelector("[data-slot='control-overlay-stop-all']");
|
|
expect(stopBtn).toBeTruthy();
|
|
expect((stopBtn as HTMLElement).style.pointerEvents).toBe("auto");
|
|
});
|
|
|
|
it("uses pointer-events auto on blocker when automationBypass is false", () => {
|
|
const { container } = render(
|
|
<ControlOverlay
|
|
visible={true}
|
|
interrupting={false}
|
|
automationBypass={false}
|
|
onInterrupt={() => {}}
|
|
/>,
|
|
);
|
|
|
|
const blocker = container.querySelector("[data-slot='control-overlay-blocker']");
|
|
expect(blocker).toBeTruthy();
|
|
expect((blocker as HTMLElement).style.pointerEvents).toBe("auto");
|
|
});
|
|
|
|
it("calls onInterrupt from the stop button", () => {
|
|
const onInterrupt = vi.fn();
|
|
const { container } = render(
|
|
<ControlOverlay
|
|
visible={true}
|
|
interrupting={false}
|
|
automationBypass={false}
|
|
onInterrupt={onInterrupt}
|
|
/>,
|
|
);
|
|
|
|
const stopBtn = container.querySelector("[data-slot='control-overlay-stop-all']");
|
|
(stopBtn as HTMLButtonElement).click();
|
|
|
|
expect(onInterrupt).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|