fix: align bound query keys with invalidation prefixes
This commit is contained in:
@@ -20,7 +20,11 @@ import {
|
||||
type QueryInvalidationCoordinator,
|
||||
} from "../../src/contracts/query-invalidation.ts";
|
||||
import { createFailure } from "../../src/contracts/errors.ts";
|
||||
import { createRuntimeIdentityRegistry } from "../../src/contracts/query-keys.ts";
|
||||
import {
|
||||
createQueryInvalidationPrefix,
|
||||
createRuntimeIdentityRegistry,
|
||||
defineQueryNamespaceIdentity,
|
||||
} from "../../src/contracts/query-keys.ts";
|
||||
import {
|
||||
bindQuery,
|
||||
type QueryResultMeasure,
|
||||
@@ -216,6 +220,38 @@ describe("application query inbound bridge", () => {
|
||||
});
|
||||
|
||||
describe("scope-bound query commit fence", () => {
|
||||
it("binds the namespace-first V2 query key", () => {
|
||||
const scope = scopeSnapshot();
|
||||
const definition = {
|
||||
definitionId: "reference-detail-v1",
|
||||
definitionVersion: 1,
|
||||
owner: "platform-test",
|
||||
namespace: "reference-resource",
|
||||
namespaceVersion: 1,
|
||||
operationId: "GET_REFERENCE_RESOURCE",
|
||||
profileId: "DETAIL_STANDARD" as const,
|
||||
measureResult: measureOne,
|
||||
execute: async () => ({ ok: true as const, value: "value" }),
|
||||
};
|
||||
|
||||
const bound = bindQuery(definition, "resource-1", scope);
|
||||
|
||||
expect(bound.queryKey).toEqual([
|
||||
"query",
|
||||
2,
|
||||
"reference-resource",
|
||||
1,
|
||||
"scope-fingerprint-0001",
|
||||
1,
|
||||
"scope-identity-token-0001",
|
||||
]);
|
||||
expect(bound.queryKey.slice(0, 4)).toEqual(
|
||||
createQueryInvalidationPrefix(
|
||||
defineQueryNamespaceIdentity("reference-resource", 1),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it("discards a successful result whose scope was fenced during execution", async () => {
|
||||
const client = queryClient();
|
||||
const scope = scopeSnapshot();
|
||||
|
||||
Reference in New Issue
Block a user