refactor(desktop): extract hidden Playwright CDP target helper
Move CDPTargetDescriptor and the reclaim predicate out of playwright-cdp.ts into a dedicated module so the reclamation rule can be unit-tested in isolation and reused without pulling in the whole hidden browser manager. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { isReclaimableHiddenPlaywrightTarget } from "./playwright-cdp-targets";
|
||||
|
||||
describe("playwright cdp target pruning", () => {
|
||||
it("does not reclaim blank app-owned page targets", () => {
|
||||
expect(isReclaimableHiddenPlaywrightTarget({
|
||||
id: "main-window-host",
|
||||
type: "page",
|
||||
title: "",
|
||||
url: "",
|
||||
})).toBe(false);
|
||||
});
|
||||
|
||||
it("only reclaims targets marked as hidden Playwright pages", () => {
|
||||
expect(isReclaimableHiddenPlaywrightTarget({
|
||||
id: "hidden-window",
|
||||
type: "page",
|
||||
title: "监控任务 · hidden-playwright",
|
||||
url: "data:text/html;charset=utf-8,%3Cmeta%20name%3D%22geo-hidden-playwright-token%22%3E",
|
||||
})).toBe(true);
|
||||
});
|
||||
|
||||
it("ignores regular user-visible browser targets", () => {
|
||||
expect(isReclaimableHiddenPlaywrightTarget({
|
||||
id: "renderer",
|
||||
type: "page",
|
||||
title: "GEO Rankly Desktop",
|
||||
url: "http://localhost:5173/",
|
||||
})).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user