refactor: 리펙토링

This commit is contained in:
DongHyeonka
2026-08-01 19:39:59 +09:00
parent 9c959ea2a5
commit c6da03369c
171 changed files with 20329 additions and 782 deletions
+27 -2
View File
@@ -9,6 +9,7 @@ import {
} from "../../src/contracts/cache-invalidation.ts";
import {
createBrowserCrossContextInvalidation,
createBrowserCrossContextInvalidationFromHost,
type BroadcastChannelFacade,
type BroadcastMessageListener,
type BrowserCrossContextInvalidationDependencies,
@@ -21,7 +22,7 @@ import {
const NOW = 1_000_000;
const CACHE_EPOCH = "cache-epoch-0001";
const TOPIC = "reference-resources";
const TOPIC = "sample-topic-alpha";
const CHANNEL_NAME = "cache-invalidation-v1";
const STORAGE_PULSE_KEY = "ca-frontend:cache-invalidation:v1:pulse";
@@ -307,6 +308,30 @@ describe("cache invalidation wire contract", () => {
});
});
describe("browser cross-context host", () => {
it("does not inspect browser capabilities when no topic is installed", () => {
const reads: string[] = [];
const host = new Proxy<Record<string, unknown>>(
{},
{
get(_target, property) {
reads.push(String(property));
throw new DOMException("Capability access denied", "SecurityError");
},
},
);
expect(
createBrowserCrossContextInvalidationFromHost({
host,
cacheEpoch: CACHE_EPOCH,
topics: [],
}),
).toBeUndefined();
expect(reads).toEqual([]);
});
});
describe("browser cross-context invalidation transport", () => {
it("publishes one exact BroadcastChannel event and filters self echo", () => {
const network = new FakeBroadcastNetwork();
@@ -525,7 +550,7 @@ describe("browser cross-context invalidation transport", () => {
true,
);
expect(JSON.stringify(observations)).not.toMatch(
/sensitive-event-identifier|reference-resources|cache-epoch-0001/,
/sensitive-event-identifier|sample-topic-alpha|cache-epoch-0001/,
);
runtime.close();
});