chore: sync the frontend template from ebea300 to af3d8e6
Carries 359 template commits, tag v0.2.0 plus one documentation commit: the generator-built feature index with its app, bounded-context and feature declarations, the src/platform kernel and scale tooling, the 2026-09-24 src review fixes, and the 2026-09-25 maturity review round with its CHANGELOG [보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them merged with product changes; 127 are not carried. Product identity is unchanged: name, version 0.1.0, routes, design and the TechLog domain. Three decisions worth naming. TechLog stays composed directly, as the last two syncs recorded; its directory carries a NOT_INSTALLED marker that says so, and every installed-* composer takes the template's projection with TechLog added on top. The reference sample is no longer installed: the template now installs a feature only through feature-module.ts and context-routes.ts, which load the screens this product deleted, so its three operations, six schemas and one topic leave the registries, recorded as registry change evidence. And AppRouter mounts the platform and TechLog routes only; the template's bounded-context route gateway waits for a generator-installed feature. Required fixes: readSubject on the BFF session owner (without it every HTTP Studio session would close as integration-failed), zod through the facade in nine TechLog files, noUnusedLocals, and public/config.json written out to match the local profile. Derived baselines were recomputed after reproducing both sides' values: CI contract 101 commands / 106 references / 141 artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime config schema baseline equals the schema at8210d48. Verified here: types, lint, architecture, adapter inventory, CI contract, i18n, design system, diagnostics, browser security, dev release manifest, TechLog contract and build pass; 220 component, 155 integration, 15 contract, 418 TechLog, 43 reference-feature, 18 recipe and 46 release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at8210d48first and unchanged: check:registries (byte-identical), test:runtime-schema, verify:documentation. Brought by the template and escalated rather than suppressed: check:request-fanout on TechLog's cursor pagination, check:remediation-ledger (fails upstream too), the shared-chunk hash test, and the registry-dependent sample removal and second-feature tests. Playwright suites were not run. Full record, the five open questions and the follow-ups in docs/operations/template-sync-2026-09-29.md. (cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { WEB_PUSH_PROTOCOLS, webPushSuccess } from "../../src/contracts/web-push.ts";
|
||||
import {
|
||||
WEB_PUSH_PROTOCOLS,
|
||||
webPushSuccess,
|
||||
type PushAuthoritySnapshot,
|
||||
} from "../../src/contracts/web-push.ts";
|
||||
import { createPushAssociationFenceStore } from "../../src/adapters/web-push/push-association-fence-store.ts";
|
||||
import {
|
||||
createWebPushSubscriptionAdapter,
|
||||
@@ -153,6 +157,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway({ register }),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
idempotencyKeyFactory: () => "idempotency_01",
|
||||
});
|
||||
@@ -207,6 +212,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway({ register }),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
});
|
||||
|
||||
@@ -224,7 +230,12 @@ describe("Web Push window subscription adapter", () => {
|
||||
expect(await fenceStore.read()).toEqual({ ok: true, value: null });
|
||||
});
|
||||
|
||||
it("compensates a stale backend session binding without activating local authority", async () => {
|
||||
// 06-02 (D-4). Only a subscription this call created is unsubscribed; an
|
||||
// existing one may belong to another tab's association.
|
||||
it.each([
|
||||
{ existing: true, unsubscribeCalls: 0 },
|
||||
{ existing: false, unsubscribeCalls: 1 },
|
||||
])("compensates a stale backend session binding without activating local authority (existing native: $existing)", async ({ existing, unsubscribeCalls }) => {
|
||||
const fenceStore = createPushAssociationFenceStore(
|
||||
createFakePushControlStoreDependencies(),
|
||||
);
|
||||
@@ -241,7 +252,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
registration: {
|
||||
active: true,
|
||||
pushManager: {
|
||||
getSubscription: async () => native,
|
||||
getSubscription: async () => (existing ? native : null),
|
||||
subscribe: async () => native,
|
||||
},
|
||||
getNotifications: async () => [],
|
||||
@@ -256,6 +267,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
revoke,
|
||||
}),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
idempotencyKeyFactory: () => "idempotency_01",
|
||||
});
|
||||
@@ -276,7 +288,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
associationEpoch: "association_stale",
|
||||
signal: expect.any(AbortSignal),
|
||||
});
|
||||
expect(unsubscribe).toHaveBeenCalledOnce();
|
||||
expect(unsubscribe).toHaveBeenCalledTimes(unsubscribeCalls);
|
||||
expect(await fenceStore.read()).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
@@ -346,6 +358,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway({ revoke }),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
});
|
||||
|
||||
@@ -417,6 +430,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway(),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
});
|
||||
|
||||
@@ -486,6 +500,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway({ revoke }),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
});
|
||||
|
||||
@@ -553,6 +568,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway({ revoke }),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
});
|
||||
|
||||
@@ -609,6 +625,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway({ revoke }),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
});
|
||||
|
||||
@@ -658,6 +675,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway(),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
nativeOperationDeadlineMs: 1,
|
||||
scheduler: clock.scheduler,
|
||||
});
|
||||
@@ -694,6 +712,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway(),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
});
|
||||
|
||||
const inspection = adapter.inspect({ authority });
|
||||
@@ -729,6 +748,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
fenceStore,
|
||||
gateway: gateway(),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
});
|
||||
|
||||
for (let attempt = 0; attempt < 2; attempt += 1) {
|
||||
@@ -792,6 +812,7 @@ describe("Web Push window subscription adapter", () => {
|
||||
revoke,
|
||||
}),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
backendOperationDeadlineMs: 1,
|
||||
scheduler: clock.scheduler,
|
||||
idempotencyKeyFactory: () => "idempotency_01",
|
||||
@@ -828,3 +849,458 @@ describe("Web Push window subscription adapter", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* R-6.7. A server ABSENT answer is re-registered only when this browser's
|
||||
* local association was ACTIVE (the server lost it). A REVOKED or
|
||||
* UNASSOCIATED fence with a leftover native subscription must not sign the
|
||||
* current account up without its own opt-in.
|
||||
*/
|
||||
describe("Web Push reconcile with a server ABSENT association (R-6.7)", () => {
|
||||
function reconcileAdapter(
|
||||
fenceStore: ReturnType<typeof createPushAssociationFenceStore>,
|
||||
native: WindowPushSubscriptionFacade,
|
||||
register: WebPushRegistrationGateway["register"],
|
||||
) {
|
||||
return createWebPushSubscriptionAdapter({
|
||||
secureContext: true,
|
||||
userActivationIsActive: () => false,
|
||||
permission: {
|
||||
permission: () => "granted",
|
||||
requestPermission: async () => "granted",
|
||||
},
|
||||
registration: {
|
||||
active: true,
|
||||
pushManager: {
|
||||
getSubscription: async () => native,
|
||||
subscribe: async () => native,
|
||||
},
|
||||
getNotifications: async () => [],
|
||||
},
|
||||
fenceStore,
|
||||
gateway: gateway({
|
||||
register,
|
||||
reconcile: async () => webPushSuccess({ state: "ABSENT" as const }),
|
||||
}),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
idempotencyKeyFactory: () => "idempotency_02",
|
||||
});
|
||||
}
|
||||
|
||||
it("re-registers when the local association is ACTIVE (crash recovery)", async () => {
|
||||
const fenceStore = await activeFenceStore();
|
||||
const unsubscribe = vi.fn(async () => true);
|
||||
const register = vi.fn(async () =>
|
||||
webPushSuccess({
|
||||
associationEpoch: "association_02",
|
||||
sessionBindingEpoch: "session_01",
|
||||
}),
|
||||
);
|
||||
const adapter = reconcileAdapter(
|
||||
fenceStore,
|
||||
subscription(unsubscribe),
|
||||
register,
|
||||
);
|
||||
|
||||
expect(await adapter.reconcile({ authority })).toEqual({
|
||||
ok: true,
|
||||
value: { state: "PUSH_READY" },
|
||||
});
|
||||
expect(register).toHaveBeenCalledOnce();
|
||||
expect(unsubscribe).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
/** Logout rotated the fence to the next account, but unsubscribe failed. */
|
||||
async function revokedForNextAccount() {
|
||||
const fenceStore = await activeFenceStore();
|
||||
const current = await fenceStore.read();
|
||||
if (!current.ok || !current.value) throw new Error("expected control");
|
||||
const revoked = await fenceStore.rotateAndRevoke({
|
||||
expectedRevision: current.value.revision,
|
||||
previousAuthority: authority,
|
||||
nextAuthority,
|
||||
updatedAt: "2026-07-28T00:00:02.000Z",
|
||||
});
|
||||
if (!revoked.ok) throw new Error("expected revoked control");
|
||||
return fenceStore;
|
||||
}
|
||||
|
||||
it.each([
|
||||
{ state: "REVOKED", fenceStore: revokedForNextAccount },
|
||||
{
|
||||
state: "UNASSOCIATED",
|
||||
fenceStore: async () =>
|
||||
createPushAssociationFenceStore(
|
||||
createFakePushControlStoreDependencies(),
|
||||
),
|
||||
},
|
||||
])(
|
||||
"unsubscribes instead of registering when the local association is $state",
|
||||
async ({ fenceStore }) => {
|
||||
const unsubscribe = vi.fn(async () => true);
|
||||
// The backend would accept the next account's registration.
|
||||
const register = vi.fn(async () =>
|
||||
webPushSuccess({
|
||||
associationEpoch: "association_02",
|
||||
sessionBindingEpoch: nextAuthority.sessionBindingEpoch,
|
||||
}),
|
||||
);
|
||||
const adapter = reconcileAdapter(
|
||||
await fenceStore(),
|
||||
subscription(unsubscribe),
|
||||
register,
|
||||
);
|
||||
|
||||
expect(await adapter.reconcile({ authority: nextAuthority })).toEqual({
|
||||
ok: true,
|
||||
value: {
|
||||
state: "PUSH_UNAVAILABLE",
|
||||
reason: "BACKEND_ASSOCIATION_MISSING",
|
||||
},
|
||||
});
|
||||
expect(register).not.toHaveBeenCalled();
|
||||
expect(unsubscribe).toHaveBeenCalledOnce();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* 06-02 (D-4). The native subscription is one per service worker registration
|
||||
* and the fence record one per origin, so every tab shares both. enable,
|
||||
* reconcile and revoke hold the origin-wide `web-push-control` Web Lock
|
||||
* (Node's `navigator.locks` here, shared by both adapters like two tabs), and
|
||||
* a compensation unsubscribes only a subscription its own call created.
|
||||
*/
|
||||
describe("06-02 two tabs share one native subscription and one fence", () => {
|
||||
function sharedTabs(
|
||||
reconcileAnswer: (
|
||||
serverAssociation: string | null,
|
||||
) => Promise<"WAIT_FOR_REGISTER" | "NOW">,
|
||||
lockManager: Pick<LockManager, "request"> | null = navigator.locks,
|
||||
) {
|
||||
const dependencies = createFakePushControlStoreDependencies();
|
||||
const unsubscribe = vi.fn(async () => {
|
||||
current = null;
|
||||
return true;
|
||||
});
|
||||
const native = subscription(unsubscribe);
|
||||
let current: WindowPushSubscriptionFacade | null = null;
|
||||
const server: { association: string | null } = { association: null };
|
||||
let releaseRegister!: () => void;
|
||||
const registerGate = new Promise<void>((resolve) => {
|
||||
releaseRegister = resolve;
|
||||
});
|
||||
let registerReached!: () => void;
|
||||
const registerStarted = new Promise<void>((resolve) => {
|
||||
registerReached = resolve;
|
||||
});
|
||||
const shared: WebPushRegistrationGateway = {
|
||||
async register() {
|
||||
registerReached();
|
||||
await registerGate;
|
||||
server.association = "association_01";
|
||||
return webPushSuccess({
|
||||
associationEpoch: "association_01",
|
||||
sessionBindingEpoch: "session_01",
|
||||
});
|
||||
},
|
||||
async reconcile() {
|
||||
if ((await reconcileAnswer(server.association)) === "WAIT_FOR_REGISTER") {
|
||||
await registerGate;
|
||||
}
|
||||
return webPushSuccess(
|
||||
server.association
|
||||
? {
|
||||
state: "ACTIVE" as const,
|
||||
associationEpoch: server.association,
|
||||
sessionBindingEpoch: "session_01",
|
||||
}
|
||||
: { state: "ABSENT" as const },
|
||||
);
|
||||
},
|
||||
async revoke(input) {
|
||||
if (server.association === input.associationEpoch) {
|
||||
server.association = null;
|
||||
}
|
||||
return webPushSuccess({ state: "REVOKED" as const });
|
||||
},
|
||||
};
|
||||
function tab(activation: boolean) {
|
||||
return createWebPushSubscriptionAdapter({
|
||||
secureContext: true,
|
||||
userActivationIsActive: () => activation,
|
||||
permission: {
|
||||
permission: () => "granted",
|
||||
requestPermission: async () => "granted",
|
||||
},
|
||||
registration: {
|
||||
active: true,
|
||||
pushManager: {
|
||||
getSubscription: async () => current,
|
||||
subscribe: async () => {
|
||||
current = native;
|
||||
return native;
|
||||
},
|
||||
},
|
||||
getNotifications: async () => [],
|
||||
},
|
||||
fenceStore: createPushAssociationFenceStore(dependencies),
|
||||
gateway: shared,
|
||||
vapidPublicKey,
|
||||
now: () => now,
|
||||
...(lockManager ? { lockManager } : {}),
|
||||
});
|
||||
}
|
||||
return {
|
||||
tab,
|
||||
server,
|
||||
unsubscribe,
|
||||
registerStarted,
|
||||
releaseRegister: () => releaseRegister(),
|
||||
nativeAlive: () => current === native,
|
||||
fence: async () =>
|
||||
await createPushAssociationFenceStore(dependencies).read(),
|
||||
};
|
||||
}
|
||||
|
||||
async function raceEnableWithReconcile(
|
||||
tabs: ReturnType<typeof sharedTabs>,
|
||||
) {
|
||||
const tab1 = tabs.tab(true);
|
||||
const tab2 = tabs.tab(false);
|
||||
const enabling = tab1.enable({
|
||||
authority,
|
||||
signal: new AbortController().signal,
|
||||
});
|
||||
// Tab 1 prepared the fence, subscribed and is waiting on register.
|
||||
await tabs.registerStarted;
|
||||
const reconciling = tab2.reconcile({ authority });
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
tabs.releaseRegister();
|
||||
return await Promise.all([enabling, reconciling]);
|
||||
}
|
||||
|
||||
function expectReadyTabsStillReceive(
|
||||
tabs: ReturnType<typeof sharedTabs>,
|
||||
results: readonly unknown[],
|
||||
) {
|
||||
const ready = { ok: true, value: { state: "PUSH_READY" } };
|
||||
expect(results).toContainEqual(ready);
|
||||
expect(tabs.unsubscribe).not.toHaveBeenCalled();
|
||||
expect(tabs.nativeAlive()).toBe(true);
|
||||
expect(tabs.server.association).toBe("association_01");
|
||||
}
|
||||
|
||||
it("keeps the shared state when the reconciling tab would win the fence CAS", async () => {
|
||||
// Order 1: the server commits tab 1's register, tab 2 sees it first.
|
||||
const tabs = sharedTabs(async () => "WAIT_FOR_REGISTER");
|
||||
const results = await raceEnableWithReconcile(tabs);
|
||||
|
||||
expect(results).toEqual([
|
||||
{ ok: true, value: { state: "PUSH_READY" } },
|
||||
{ ok: true, value: { state: "PUSH_READY" } },
|
||||
]);
|
||||
expectReadyTabsStillReceive(tabs, results);
|
||||
expect(await tabs.fence()).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
control: {
|
||||
association: {
|
||||
state: "ACTIVE",
|
||||
associationEpoch: "association_01",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the shared state when a tab reconciles during another tab's unfinished opt-in", async () => {
|
||||
// Order 2: the server still answers ABSENT while tab 1's register runs.
|
||||
const tabs = sharedTabs(async () => "NOW");
|
||||
const results = await raceEnableWithReconcile(tabs);
|
||||
|
||||
expect(results[0]).toEqual({ ok: true, value: { state: "PUSH_READY" } });
|
||||
expectReadyTabsStillReceive(tabs, results);
|
||||
});
|
||||
|
||||
it("aborts a tab that is still waiting for another tab's lock", async () => {
|
||||
const tabs = sharedTabs(async () => "NOW");
|
||||
const enabling = tabs.tab(true).enable({
|
||||
authority,
|
||||
signal: new AbortController().signal,
|
||||
});
|
||||
await tabs.registerStarted;
|
||||
const waiting = new AbortController();
|
||||
const reconciling = tabs.tab(false).reconcile({
|
||||
authority,
|
||||
signal: waiting.signal,
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
waiting.abort();
|
||||
|
||||
expect(await reconciling).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "ABORTED", operation: "SUBSCRIPTION_RECONCILE" },
|
||||
});
|
||||
tabs.releaseRegister();
|
||||
expect(await enabling).toEqual({
|
||||
ok: true,
|
||||
value: { state: "PUSH_READY" },
|
||||
});
|
||||
expect(tabs.unsubscribe).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("reports PUSH_UNSUPPORTED without side effects when Web Locks are missing", async () => {
|
||||
const tabs = sharedTabs(async () => "NOW", null);
|
||||
expect(
|
||||
await tabs.tab(true).enable({
|
||||
authority,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).toEqual({ ok: true, value: { state: "PUSH_UNSUPPORTED" } });
|
||||
expect(tabs.nativeAlive()).toBe(false);
|
||||
expect(await tabs.fence()).toEqual({ ok: true, value: null });
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 06-06. The session changed from A to B without `revoke` (expiry, cleared
|
||||
* cookies, a crash during logout). B cannot name A's stored authority, so
|
||||
* `revokeForeign` rotates a fence another fence generation holds. A fence B
|
||||
* already holds, for example because another tab of B opted in, is left alone.
|
||||
*/
|
||||
describe("06-06 account switch without logout", () => {
|
||||
async function fenceFor(owner: PushAuthoritySnapshot, associationEpoch: string) {
|
||||
const store = createPushAssociationFenceStore(
|
||||
createFakePushControlStoreDependencies(),
|
||||
);
|
||||
const prepared = await store.prepare({
|
||||
authority: owner,
|
||||
updatedAt: "2026-07-28T00:00:00.000Z",
|
||||
});
|
||||
if (!prepared.ok) throw new Error("expected prepared control");
|
||||
const active = await store.activate({
|
||||
expectedRevision: prepared.value.revision,
|
||||
authority: owner,
|
||||
associationEpoch,
|
||||
updatedAt: "2026-07-28T00:00:01.000Z",
|
||||
});
|
||||
if (!active.ok) throw new Error("expected active control");
|
||||
return store;
|
||||
}
|
||||
|
||||
function adapterOver(
|
||||
fenceStore: ReturnType<typeof createPushAssociationFenceStore>,
|
||||
) {
|
||||
const unsubscribe = vi.fn(async () => {
|
||||
current = null;
|
||||
return true;
|
||||
});
|
||||
let current: WindowPushSubscriptionFacade | null = subscription(unsubscribe);
|
||||
const revoke = vi.fn(gateway().revoke);
|
||||
const register = vi.fn(async () =>
|
||||
webPushSuccess({
|
||||
associationEpoch: "association_02",
|
||||
sessionBindingEpoch: nextAuthority.sessionBindingEpoch,
|
||||
}),
|
||||
);
|
||||
const adapter = createWebPushSubscriptionAdapter({
|
||||
secureContext: true,
|
||||
userActivationIsActive: () => true,
|
||||
permission: {
|
||||
permission: () => "granted",
|
||||
requestPermission: async () => "granted",
|
||||
},
|
||||
registration: {
|
||||
active: true,
|
||||
pushManager: {
|
||||
getSubscription: async () => current,
|
||||
subscribe: async () => {
|
||||
current = subscription();
|
||||
return current;
|
||||
},
|
||||
},
|
||||
getNotifications: async () => [],
|
||||
},
|
||||
fenceStore,
|
||||
gateway: gateway({ register, revoke }),
|
||||
vapidPublicKey,
|
||||
lockManager: navigator.locks,
|
||||
now: () => now,
|
||||
});
|
||||
return { adapter, unsubscribe, revoke, register };
|
||||
}
|
||||
|
||||
it("lets B take over A's ACTIVE fence in one call and opt in again", async () => {
|
||||
const fenceStore = await fenceFor(authority, "association_01");
|
||||
const tab = adapterOver(fenceStore);
|
||||
// Without it B is stuck: the fence still belongs to A.
|
||||
expect(
|
||||
await tab.adapter.enable({
|
||||
authority: nextAuthority,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).toMatchObject({ ok: false, error: { code: "STALE_AUTHORITY" } });
|
||||
|
||||
expect(
|
||||
await tab.adapter.revokeForeign({ nextAuthority }),
|
||||
).toEqual({
|
||||
ok: true,
|
||||
value: { state: "PUSH_UNAVAILABLE", reason: "REVOKED" },
|
||||
});
|
||||
expect(tab.revoke.mock.calls).toEqual([
|
||||
[{ associationEpoch: "association_01", signal: expect.any(AbortSignal) }],
|
||||
]);
|
||||
expect(tab.unsubscribe).toHaveBeenCalledOnce();
|
||||
expect(await fenceStore.read()).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
control: {
|
||||
...nextAuthority,
|
||||
association: { state: "REVOKED", associationEpoch: "association_01" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
await tab.adapter.enable({
|
||||
authority: nextAuthority,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).toEqual({ ok: true, value: { state: "PUSH_READY" } });
|
||||
});
|
||||
|
||||
it("leaves a fence B already holds alone and reports it like inspect", async () => {
|
||||
const fenceStore = await fenceFor(nextAuthority, "association_02");
|
||||
const before = await fenceStore.read();
|
||||
const tab = adapterOver(fenceStore);
|
||||
|
||||
expect(await tab.adapter.revokeForeign({ nextAuthority })).toEqual({
|
||||
ok: true,
|
||||
value: { state: "PUSH_READY" },
|
||||
});
|
||||
expect(tab.revoke).not.toHaveBeenCalled();
|
||||
expect(tab.unsubscribe).not.toHaveBeenCalled();
|
||||
expect(await fenceStore.read()).toEqual(before);
|
||||
});
|
||||
|
||||
it("does not treat a new release of the same session as another account", async () => {
|
||||
const fenceStore = await fenceFor(authority, "association_01");
|
||||
const before = await fenceStore.read();
|
||||
const tab = adapterOver(fenceStore);
|
||||
|
||||
expect(
|
||||
await tab.adapter.revokeForeign({
|
||||
nextAuthority: { ...authority, releaseEpoch: "release_02" },
|
||||
}),
|
||||
).toEqual({
|
||||
ok: true,
|
||||
value: { state: "PUSH_UNAVAILABLE", reason: "SESSION_AUTHORITY_CHANGED" },
|
||||
});
|
||||
expect(tab.revoke).not.toHaveBeenCalled();
|
||||
expect(tab.unsubscribe).not.toHaveBeenCalled();
|
||||
expect(await fenceStore.read()).toEqual(before);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user