1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveBrowserRecordingStopTarget } from "./browserRecordingScope";
4
5describe("resolveBrowserRecordingStopTarget", () => {
6 it("stops the only active recording when the implicit browser target changed", () => {
7 expect(resolveBrowserRecordingStopTarget(new Set(["tab-recording"]), "tab-browsing")).toBe(
8 "tab-recording",
9 );
10 });
11
12 it("prefers an implicit target that is actively recording", () => {
13 expect(
14 resolveBrowserRecordingStopTarget(
15 new Set(["tab-recording-a", "tab-recording-b"]),
16 "tab-recording-b",
17 ),
18 ).toBe("tab-recording-b");
19 });
20
21 it("does not guess when multiple recordings are active and the implicit target is not one", () => {
22 expect(
23 resolveBrowserRecordingStopTarget(
24 new Set(["tab-recording-a", "tab-recording-b"]),
25 "tab-browsing",
26 ),
27 ).toBeNull();
28 });
29
30 it("only stops an explicitly requested tab when that tab is recording", () => {
31 const activeTabIds = new Set(["tab-recording"]);
32 expect(resolveBrowserRecordingStopTarget(activeTabIds, "tab-browsing", "tab-recording")).toBe(
33 "tab-recording",
34 );
35 expect(resolveBrowserRecordingStopTarget(activeTabIds, "tab-recording", "tab-browsing")).toBe(
36 null,
37 );
38 });
39
40 it("returns null when no matching recording is active", () => {
41 expect(resolveBrowserRecordingStopTarget(new Set(), "tab-browsing")).toBeNull();
42 });
43});