Files
Netcatty/application/testSupport/browserLockFixture.ts
T
陈大猫 bace30578c feat: add synced custom host monitoring panels (#3703)
* feat: add synced custom host monitoring panels

* fix: preserve shared monitoring demand and complete terminal stats

* fix: transfer queued monitoring prompts when a window closes

* fix: keep reused hosts sampling while authentication is queued

* docs: record monitoring acceptance evidence

* fix: transfer pending monitoring auth after panel stop

* fix: release monitor owners in direct SSH runtime

* fix: keep worker monitoring sender compatibility

* fix: include monitoring configuration in automatic sync

* fix: disambiguate independent synced monitoring panel names

* test: assert existing panel order after cloud merge

* test: model browser locks and await monitoring state on Node 22
2026-10-17 15:05:30 +08:00

27 lines
812 B
TypeScript

/** Serialized Web Locks fixture for tests with a simulated browser window. */
export function installBrowserLockFixture(): void {
const tails = new Map<string, Promise<void>>();
const locks = {
async request<T>(name: string, task: () => Promise<T>): Promise<T> {
const previous = tails.get(name) ?? Promise.resolve();
let release!: () => void;
const gate = new Promise<void>((resolve) => {
release = resolve;
});
const tail = previous.then(() => gate);
tails.set(name, tail);
await previous;
try {
return await task();
} finally {
release();
if (tails.get(name) === tail) tails.delete(name);
}
},
};
Object.defineProperty(globalThis, "navigator", {
configurable: true,
value: { locks },
});
}