test: trim the attach-token vitest to its two invariants

Keep the duplicate-tab case (a cloned sessionStorage token already claimed
by a live document mints its own) and the reload case (a released token is
reused); the once-per-document lock accounting, explicit rotation and the
no-Web-Locks fallback are implementation details of the same module.
This commit is contained in:
teknium1
2026-09-20 00:41:03 -07:00
committed by Teknium
parent 406ed30aa7
commit edaf00eba3

View File

@@ -112,32 +112,4 @@ describe("ptyAttachToken", () => {
expect(await reloaded.ptyAttachToken()).toBe("tab-token");
});
it("claims the token once per document so a reconnect never re-locks it", async () => {
const held = new Set<string>();
const requests: string[] = [];
const tab = await openTab(held, { [KEY]: "tab-token" }, requests);
expect(await tab.ptyAttachToken()).toBe("tab-token");
expect(await tab.ptyAttachToken()).toBe("tab-token");
expect(requests).toEqual([`hermes.pty.attach.tab-token`]);
});
it("rotates the token for an explicit fresh session", async () => {
const held = new Set<string>();
const tab = await openTab(held, { [KEY]: "tab-token" });
const rotated = await tab.ptyAttachToken(true);
expect(rotated).not.toBe("tab-token");
expect(tab.storage.getItem(KEY)).toBe(rotated);
});
it("still isolates tabs on sessionStorage when the browser has no Web Locks", async () => {
const tab = await openTab(new Set(), { [KEY]: "tab-token" });
Object.defineProperty(window.navigator, "locks", { configurable: true, value: undefined });
expect(await tab.ptyAttachToken()).toBe("tab-token");
});
});