@decocms/blocks 8.0.0 → 8.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/deco.js +13 -0
- package/package.json +39 -3
- package/src/cms/applySectionConventions.ts +26 -2
- package/src/cms/blockSource.ts +37 -0
- package/src/cms/client.ts +5 -0
- package/src/cms/deferredTrigger.ts +58 -0
- package/src/cms/draftSource.ts +171 -57
- package/src/cms/index.ts +32 -3
- package/src/cms/loader.ts +318 -59
- package/src/cms/registry.ts +22 -0
- package/src/cms/renderJson.ts +179 -0
- package/src/cms/resolve.ts +396 -95
- package/src/cms/schema.ts +9 -5
- package/src/cms/sectionLoaders.ts +106 -56
- package/src/hooks/Image.tsx +70 -6
- package/src/hooks/LiveControls.tsx +30 -8
- package/src/hooks/Stats.tsx +134 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useLoadMore.ts +100 -0
- package/src/index.ts +37 -0
- package/src/middleware/observability.ts +173 -16
- package/src/preview/DraftPreviewBadge.tsx +306 -0
- package/src/preview/decoMark.ts +11 -0
- package/src/preview/index.ts +8 -0
- package/src/protocol/assets.ts +124 -0
- package/src/protocol/canonical.ts +7 -0
- package/src/protocol/ciphertext.ts +6 -0
- package/src/protocol/client.ts +170 -0
- package/src/protocol/conformance/cases/assets.ts +81 -0
- package/src/protocol/conformance/cases/guards.ts +314 -0
- package/src/protocol/conformance/cases/reads.ts +168 -0
- package/src/protocol/conformance/cases/types.ts +9 -0
- package/src/protocol/conformance/cases/wire.ts +138 -0
- package/src/protocol/conformance/cases/writes.ts +345 -0
- package/src/protocol/conformance/contentHashFixtures.ts +79 -0
- package/src/protocol/conformance/context.ts +222 -0
- package/src/protocol/conformance/index.ts +140 -0
- package/src/protocol/errors.ts +142 -0
- package/src/protocol/index.ts +39 -0
- package/src/protocol/keys.ts +279 -0
- package/src/protocol/params.ts +67 -0
- package/src/protocol/secrets.ts +231 -0
- package/src/protocol/server/assets.ts +119 -0
- package/src/protocol/server/auth.ts +49 -0
- package/src/protocol/server/bodyCache.ts +84 -0
- package/src/protocol/server/content.ts +175 -0
- package/src/protocol/server/core.ts +112 -0
- package/src/protocol/server/handler.ts +102 -0
- package/src/protocol/server/http.ts +139 -0
- package/src/protocol/server/index.ts +11 -0
- package/src/protocol/server/methods/apply.ts +341 -0
- package/src/protocol/server/methods/read.ts +156 -0
- package/src/protocol/server/rpc.ts +136 -0
- package/src/protocol/storage/fs/hash.ts +21 -0
- package/src/protocol/storage/fs/index.ts +338 -0
- package/src/protocol/storage/fs/lock.ts +68 -0
- package/src/protocol/storage/fs/transaction.ts +183 -0
- package/src/protocol/storage/fs/unsupported.ts +15 -0
- package/src/protocol/storage/memory.ts +238 -0
- package/src/protocol/storage.ts +182 -0
- package/src/protocol/types.ts +172 -0
- package/src/sdk/abTesting.ts +60 -3
- package/src/sdk/analytics.ts +72 -2
- package/src/sdk/cacheHeaders.ts +210 -10
- package/src/sdk/cacheStorage.ts +287 -0
- package/src/sdk/cachedLoader.ts +143 -90
- package/src/sdk/crypto.ts +16 -2
- package/src/sdk/deepOmit.ts +52 -0
- package/src/sdk/encoding.ts +2 -5
- package/src/sdk/experiments.ts +314 -0
- package/src/sdk/fetchCache.ts +269 -0
- package/src/sdk/fetchTimeout.ts +58 -0
- package/src/sdk/flags.ts +38 -8
- package/src/sdk/index.ts +7 -0
- package/src/sdk/instrumentedFetch.ts +25 -2
- package/src/sdk/nonce.ts +46 -0
- package/src/sdk/normalizeUrls.ts +2 -2
- package/src/sdk/observability.ts +8 -1
- package/src/sdk/otel.ts +131 -25
- package/src/sdk/otelHttpLog.ts +4 -4
- package/src/sdk/otelHttpMeter.ts +39 -13
- package/src/sdk/otelHttpTracer.ts +4 -4
- package/src/sdk/redirects.ts +113 -5
- package/src/sdk/responseCache.ts +82 -0
- package/src/sdk/urlUtils.ts +49 -0
- package/src/sdk/useSuggestions.ts +1 -1
- package/src/v8/analytics.ts +50 -0
- package/src/v8/background.ts +107 -0
- package/src/v8/builtins/data.ts +23 -0
- package/src/v8/builtins/index.ts +26 -0
- package/src/v8/builtins/lazy.ts +23 -0
- package/src/v8/builtins/legacy.ts +65 -0
- package/src/v8/builtins/matchers.ts +31 -0
- package/src/v8/builtins/multivariate.ts +25 -0
- package/src/v8/builtins/secret.ts +82 -0
- package/src/v8/canonical.ts +117 -0
- package/src/v8/ciphertext.ts +158 -0
- package/src/v8/cli/builtins.ts +20 -0
- package/src/v8/cli/check/index.ts +774 -0
- package/src/v8/cli/check/messages.ts +168 -0
- package/src/v8/cli/content.ts +287 -0
- package/src/v8/cli/index.ts +17 -0
- package/src/v8/cli/log.ts +18 -0
- package/src/v8/cli/main.ts +12 -0
- package/src/v8/cli/root.ts +66 -0
- package/src/v8/cli/run.ts +236 -0
- package/src/v8/cli/schema/builtinSchemas.ts +236 -0
- package/src/v8/cli/schema/generate.ts +507 -0
- package/src/v8/cli/schema/index.ts +63 -0
- package/src/v8/cli/schema/tsProgram.ts +497 -0
- package/src/v8/cli/schema/typeToSchema.ts +689 -0
- package/src/v8/cli/serve/server.ts +303 -0
- package/src/v8/cli/watch.ts +86 -0
- package/src/v8/client.ts +147 -0
- package/src/v8/cms.ts +237 -0
- package/src/v8/content.ts +195 -0
- package/src/v8/draft.ts +136 -0
- package/src/v8/errors.ts +59 -0
- package/src/v8/fetch.ts +152 -0
- package/src/v8/identity.ts +65 -0
- package/src/v8/index.ts +39 -0
- package/src/v8/json.ts +74 -0
- package/src/v8/matchRoute.ts +204 -0
- package/src/v8/remoteLoader.ts +282 -0
- package/src/v8/resolver.ts +278 -0
- package/src/v8/secrets.ts +17 -0
- package/src/v8/telemetry.ts +533 -0
- package/src/v8/types.ts +240 -0
- package/src/cms/blockSource.test.ts +0 -76
- package/src/cms/client.browserBundle.test.ts +0 -44
- package/src/cms/draftSource.test.ts +0 -343
- package/src/cms/layoutCacheRace.test.ts +0 -181
- package/src/cms/loadDecofileDirectory.test.ts +0 -109
- package/src/cms/loader.test.ts +0 -200
- package/src/cms/registry.test.ts +0 -110
- package/src/cms/resolve.test.ts +0 -980
- package/src/cms/schema.test.ts +0 -356
- package/src/cms/sectionLoaderContext.test.ts +0 -111
- package/src/cms/sectionLoaders.test.ts +0 -533
- package/src/cms/sectionMixins.test.ts +0 -167
- package/src/cms/stickyFlags.test.ts +0 -117
- package/src/flags/flags.test.ts +0 -148
- package/src/hooks/Image.test.ts +0 -100
- package/src/hooks/RenderSection.test.tsx +0 -81
- package/src/matchers/builtins.test.ts +0 -318
- package/src/matchers/override.test.ts +0 -205
- package/src/middleware/hydrationContext.test.ts +0 -61
- package/src/middleware/observability.test.ts +0 -242
- package/src/middleware/validateSection.test.ts +0 -147
- package/src/sdk/abTesting.test.ts +0 -326
- package/src/sdk/cacheHeaders.test.ts +0 -115
- package/src/sdk/cachedLoader.test.ts +0 -122
- package/src/sdk/cachedLoaderModule.test.ts +0 -209
- package/src/sdk/cn.test.ts +0 -34
- package/src/sdk/composite.test.ts +0 -121
- package/src/sdk/cookie.test.ts +0 -108
- package/src/sdk/encoding.test.ts +0 -71
- package/src/sdk/env.test.ts +0 -33
- package/src/sdk/flags.test.ts +0 -91
- package/src/sdk/http.test.ts +0 -71
- package/src/sdk/inflightTimeout.test.ts +0 -35
- package/src/sdk/instrumentedFetch.test.ts +0 -559
- package/src/sdk/invoke.test.ts +0 -115
- package/src/sdk/logger.test.ts +0 -432
- package/src/sdk/otel.test.ts +0 -526
- package/src/sdk/otelAdapters.test.ts +0 -89
- package/src/sdk/otelHttpLog.test.ts +0 -457
- package/src/sdk/otelHttpMeter.test.ts +0 -292
- package/src/sdk/otelHttpTracer.test.ts +0 -474
- package/src/sdk/requestContextStorage.browser.test.ts +0 -29
- package/src/sdk/urlRedaction.test.ts +0 -73
- package/src/sdk/useDevice.test.ts +0 -130
- package/src/sdk/useScript.test.ts +0 -128
- package/src/sdk/useSuggestions.test.ts +0 -230
- package/tsconfig.json +0 -7
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
clearLoaderCache,
|
|
4
|
-
createCachedLoaderFromModule,
|
|
5
|
-
createLoaderEntry,
|
|
6
|
-
type LoaderModule,
|
|
7
|
-
} from "./cachedLoader";
|
|
8
|
-
import { RequestContext } from "./requestContext";
|
|
9
|
-
|
|
10
|
-
/** A loader whose `default` we can count calls on and control resolution of. */
|
|
11
|
-
function makeLoader<T>(result: T) {
|
|
12
|
-
let resolve!: (v: T) => void;
|
|
13
|
-
const gate = new Promise<T>((r) => (resolve = r));
|
|
14
|
-
const fn = vi.fn(async (_props: unknown, _req?: Request) => {
|
|
15
|
-
await gate;
|
|
16
|
-
return result;
|
|
17
|
-
});
|
|
18
|
-
return { fn, release: () => resolve(result) };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
clearLoaderCache();
|
|
23
|
-
vi.restoreAllMocks();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe("createCachedLoaderFromModule — dedup-only (no SWR)", () => {
|
|
27
|
-
it("runs on every call when the module has no `cache` export (apps no-store default)", async () => {
|
|
28
|
-
const { fn, release } = makeLoader("x");
|
|
29
|
-
release();
|
|
30
|
-
const mod: LoaderModule = { default: fn };
|
|
31
|
-
const loader = createCachedLoaderFromModule("site/loaders/plain", mod);
|
|
32
|
-
|
|
33
|
-
// No wrap at all → returns the original function identity.
|
|
34
|
-
expect(loader).toBe(fn);
|
|
35
|
-
|
|
36
|
-
await loader({ a: 1 });
|
|
37
|
-
await loader({ a: 1 });
|
|
38
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("runs on every call for `no-cache` (only stale-while-revalidate opts into dedup)", async () => {
|
|
42
|
-
const { fn, release } = makeLoader("x");
|
|
43
|
-
const mod: LoaderModule = { default: fn, cache: "no-cache" };
|
|
44
|
-
const loader = createCachedLoaderFromModule("site/loaders/nocache", mod);
|
|
45
|
-
|
|
46
|
-
expect(loader).toBe(fn);
|
|
47
|
-
const p1 = loader({ a: 1 });
|
|
48
|
-
const p2 = loader({ a: 1 });
|
|
49
|
-
release();
|
|
50
|
-
await Promise.all([p1, p2]);
|
|
51
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("collapses concurrent identical calls into ONE upstream call when `cache` opts in", async () => {
|
|
55
|
-
const { fn, release } = makeLoader("shelf");
|
|
56
|
-
const mod: LoaderModule = { default: fn, cache: "stale-while-revalidate" };
|
|
57
|
-
const loader = createCachedLoaderFromModule("site/loaders/related", mod);
|
|
58
|
-
|
|
59
|
-
// Three sections on one render invoke the same loader concurrently.
|
|
60
|
-
const p1 = loader({ slug: "abc" });
|
|
61
|
-
const p2 = loader({ slug: "abc" });
|
|
62
|
-
const p3 = loader({ slug: "abc" });
|
|
63
|
-
release();
|
|
64
|
-
const [r1, r2, r3] = await Promise.all([p1, p2, p3]);
|
|
65
|
-
|
|
66
|
-
expect(r1).toBe("shelf");
|
|
67
|
-
expect(r2).toBe("shelf");
|
|
68
|
-
expect(r3).toBe("shelf");
|
|
69
|
-
// The #339 N+1 fix: 3 concurrent references → 1 upstream call.
|
|
70
|
-
expect(fn).toHaveBeenCalledTimes(1);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("does NOT retain results across settlement (no cross-request staleness)", async () => {
|
|
74
|
-
const { fn, release } = makeLoader("v");
|
|
75
|
-
release();
|
|
76
|
-
const mod: LoaderModule = { default: fn, cache: "stale-while-revalidate" };
|
|
77
|
-
const loader = createCachedLoaderFromModule("site/loaders/nostale", mod);
|
|
78
|
-
|
|
79
|
-
await loader({ slug: "abc" });
|
|
80
|
-
// Sequential (non-concurrent) call after the first settled → re-runs.
|
|
81
|
-
await loader({ slug: "abc" });
|
|
82
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("dedups by the module's custom cacheKey(props, req), not raw props", async () => {
|
|
86
|
-
const { fn, release } = makeLoader("p");
|
|
87
|
-
const mod: LoaderModule = {
|
|
88
|
-
default: fn,
|
|
89
|
-
cache: "stale-while-revalidate",
|
|
90
|
-
// Key only on pathname — ignores tracking params on the URL.
|
|
91
|
-
cacheKey: (_props, req) => new URL(req!.url).pathname,
|
|
92
|
-
};
|
|
93
|
-
const loader = createCachedLoaderFromModule("site/loaders/pdp", mod);
|
|
94
|
-
|
|
95
|
-
const reqA = new Request("https://x.test/produto?utm_source=a");
|
|
96
|
-
const reqB = new Request("https://x.test/produto?utm_source=b");
|
|
97
|
-
const p1 = loader({ id: 1 }, reqA);
|
|
98
|
-
const p2 = loader({ id: 2 }, reqB); // different props + url, same pathname
|
|
99
|
-
release();
|
|
100
|
-
await Promise.all([p1, p2]);
|
|
101
|
-
|
|
102
|
-
expect(fn).toHaveBeenCalledTimes(1);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("runs fresh (no dedup) when cacheKey returns null", async () => {
|
|
106
|
-
const { fn, release } = makeLoader("p");
|
|
107
|
-
const mod: LoaderModule = {
|
|
108
|
-
default: fn,
|
|
109
|
-
cache: "stale-while-revalidate",
|
|
110
|
-
cacheKey: () => null,
|
|
111
|
-
};
|
|
112
|
-
const loader = createCachedLoaderFromModule("site/loaders/personalized", mod);
|
|
113
|
-
|
|
114
|
-
const req = new Request("https://x.test/");
|
|
115
|
-
const p1 = loader({ id: 1 }, req);
|
|
116
|
-
const p2 = loader({ id: 1 }, req);
|
|
117
|
-
release();
|
|
118
|
-
await Promise.all([p1, p2]);
|
|
119
|
-
|
|
120
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("sources req from RequestContext when the caller passes none (CMS-resolution path)", async () => {
|
|
124
|
-
const { fn, release } = makeLoader("p");
|
|
125
|
-
const seen: string[] = [];
|
|
126
|
-
const mod: LoaderModule = {
|
|
127
|
-
default: fn,
|
|
128
|
-
cache: "stale-while-revalidate",
|
|
129
|
-
cacheKey: (_props, req) => {
|
|
130
|
-
seen.push(new URL(req!.url).pathname);
|
|
131
|
-
return new URL(req!.url).pathname;
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
const loader = createCachedLoaderFromModule("site/loaders/ctx", mod);
|
|
135
|
-
|
|
136
|
-
const req = new Request("https://x.test/categoria");
|
|
137
|
-
await RequestContext.run(req, async () => {
|
|
138
|
-
// Called with ONLY props, mirroring resolve.ts internalResolve.
|
|
139
|
-
const p1 = loader({ a: 1 });
|
|
140
|
-
const p2 = loader({ a: 1 });
|
|
141
|
-
release();
|
|
142
|
-
await Promise.all([p1, p2]);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
expect(seen).toContain("/categoria");
|
|
146
|
-
expect(fn).toHaveBeenCalledTimes(1);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("falls back to props-hash dedup when cacheKey needs req but none is available", async () => {
|
|
150
|
-
const { fn, release } = makeLoader("p");
|
|
151
|
-
const mod: LoaderModule = {
|
|
152
|
-
default: fn,
|
|
153
|
-
cache: "stale-while-revalidate",
|
|
154
|
-
// Would throw on undefined req — the wrapper must not call it without one.
|
|
155
|
-
cacheKey: (_props, req) => new URL(req!.url).pathname,
|
|
156
|
-
};
|
|
157
|
-
const loader = createCachedLoaderFromModule("site/loaders/noreq", mod);
|
|
158
|
-
|
|
159
|
-
// No req arg, no RequestContext scope.
|
|
160
|
-
const p1 = loader({ a: 1 });
|
|
161
|
-
const p2 = loader({ a: 1 });
|
|
162
|
-
release();
|
|
163
|
-
await expect(Promise.all([p1, p2])).resolves.toEqual(["p", "p"]);
|
|
164
|
-
expect(fn).toHaveBeenCalledTimes(1);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("propagates loader errors and clears the in-flight entry", async () => {
|
|
168
|
-
const err = new Error("upstream down");
|
|
169
|
-
const fn = vi.fn(async () => {
|
|
170
|
-
throw err;
|
|
171
|
-
});
|
|
172
|
-
const mod: LoaderModule = { default: fn, cache: "stale-while-revalidate" };
|
|
173
|
-
const loader = createCachedLoaderFromModule("site/loaders/boom", mod);
|
|
174
|
-
|
|
175
|
-
await expect(loader({ a: 1 })).rejects.toThrow("upstream down");
|
|
176
|
-
// A retry after failure is not blocked by a stuck in-flight entry.
|
|
177
|
-
await expect(loader({ a: 1 })).rejects.toThrow("upstream down");
|
|
178
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
describe("createLoaderEntry — lazy import + wrap", () => {
|
|
183
|
-
it("imports the module once and dedups concurrent calls", async () => {
|
|
184
|
-
const { fn, release } = makeLoader("lazy");
|
|
185
|
-
const importFn = vi.fn(async () => ({
|
|
186
|
-
default: fn,
|
|
187
|
-
cache: "stale-while-revalidate" as const,
|
|
188
|
-
}));
|
|
189
|
-
const entry = createLoaderEntry("site/loaders/lazy", importFn);
|
|
190
|
-
|
|
191
|
-
const p1 = entry({ a: 1 });
|
|
192
|
-
const p2 = entry({ a: 1 });
|
|
193
|
-
release();
|
|
194
|
-
await Promise.all([p1, p2]);
|
|
195
|
-
|
|
196
|
-
expect(importFn).toHaveBeenCalledTimes(1);
|
|
197
|
-
expect(fn).toHaveBeenCalledTimes(1);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it("passes non-opted-in loaders straight through", async () => {
|
|
201
|
-
const { fn, release } = makeLoader("plain");
|
|
202
|
-
release();
|
|
203
|
-
const entry = createLoaderEntry("site/loaders/plain", async () => ({ default: fn }));
|
|
204
|
-
|
|
205
|
-
await entry({ a: 1 });
|
|
206
|
-
await entry({ a: 1 });
|
|
207
|
-
expect(fn).toHaveBeenCalledTimes(2);
|
|
208
|
-
});
|
|
209
|
-
});
|
package/src/sdk/cn.test.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { clx, cn } from "./cn";
|
|
3
|
-
|
|
4
|
-
describe("cn", () => {
|
|
5
|
-
it("joins strings", () => {
|
|
6
|
-
expect(cn("a", "b", "c")).toBe("a b c");
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("supports conditional objects", () => {
|
|
10
|
-
expect(cn("a", { b: true, c: false }, "d")).toBe("a b d");
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("filters out falsy values", () => {
|
|
14
|
-
expect(cn("a", null, undefined, false, 0 as any, "b")).toBe("a b");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("merges conflicting Tailwind utilities (last one wins)", () => {
|
|
18
|
-
expect(cn("p-2", "p-4")).toBe("p-4");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("merges hover variants independently from base utilities", () => {
|
|
22
|
-
expect(cn("p-2", "hover:p-4")).toBe("p-2 hover:p-4");
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe("clx (re-exported)", () => {
|
|
27
|
-
it("filters falsy and joins with single spaces", () => {
|
|
28
|
-
expect(clx("a", null, "b", undefined, "c")).toBe("a b c");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("does NOT merge conflicting utilities (that's cn's job)", () => {
|
|
32
|
-
expect(clx("p-2", "p-4")).toBe("p-2 p-4");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { MeterAdapter } from "../middleware/observability";
|
|
3
|
-
import { createCompositeLogger, createCompositeMeter } from "./composite";
|
|
4
|
-
import type { LoggerAdapter } from "./logger";
|
|
5
|
-
|
|
6
|
-
describe("createCompositeLogger", () => {
|
|
7
|
-
afterEach(() => vi.restoreAllMocks());
|
|
8
|
-
|
|
9
|
-
it("fans calls out to every adapter", () => {
|
|
10
|
-
const aCalls: any[][] = [];
|
|
11
|
-
const bCalls: any[][] = [];
|
|
12
|
-
const a: LoggerAdapter = { log: (...args) => void aCalls.push(args) };
|
|
13
|
-
const b: LoggerAdapter = { log: (...args) => void bCalls.push(args) };
|
|
14
|
-
const composite = createCompositeLogger([a, b]);
|
|
15
|
-
|
|
16
|
-
composite.log("info", "hello", { foo: 1 });
|
|
17
|
-
|
|
18
|
-
expect(aCalls).toEqual([["info", "hello", { foo: 1 }]]);
|
|
19
|
-
expect(bCalls).toEqual([["info", "hello", { foo: 1 }]]);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("filters falsy entries (null/undefined/false)", () => {
|
|
23
|
-
const calls: any[] = [];
|
|
24
|
-
const a: LoggerAdapter = { log: (...args) => void calls.push(args) };
|
|
25
|
-
const composite = createCompositeLogger([null, a, undefined, false]);
|
|
26
|
-
composite.log("info", "ok");
|
|
27
|
-
// adapter receives the call with no third arg (undefined is omitted)
|
|
28
|
-
expect(calls.length).toBe(1);
|
|
29
|
-
expect(calls[0][0]).toBe("info");
|
|
30
|
-
expect(calls[0][1]).toBe("ok");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("isolates errors so one bad adapter does not block others", () => {
|
|
34
|
-
const errSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
35
|
-
const okCalls: any[][] = [];
|
|
36
|
-
const broken: LoggerAdapter = {
|
|
37
|
-
log() {
|
|
38
|
-
throw new Error("boom");
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
const ok: LoggerAdapter = { log: (...args) => void okCalls.push(args) };
|
|
42
|
-
const composite = createCompositeLogger([broken, ok]);
|
|
43
|
-
|
|
44
|
-
expect(() => composite.log("error", "still goes through")).not.toThrow();
|
|
45
|
-
expect(okCalls.length).toBe(1);
|
|
46
|
-
expect(okCalls[0][0]).toBe("error");
|
|
47
|
-
expect(okCalls[0][1]).toBe("still goes through");
|
|
48
|
-
expect(errSpy).toHaveBeenCalled(); // composite reports the failure
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("returns the single adapter directly when only one is provided", () => {
|
|
52
|
-
const a: LoggerAdapter = { log: () => {} };
|
|
53
|
-
expect(createCompositeLogger([a])).toBe(a);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("createCompositeMeter", () => {
|
|
58
|
-
afterEach(() => vi.restoreAllMocks());
|
|
59
|
-
|
|
60
|
-
function recorder() {
|
|
61
|
-
const counter: any[] = [];
|
|
62
|
-
const gauge: any[] = [];
|
|
63
|
-
const histo: any[] = [];
|
|
64
|
-
const meter: MeterAdapter = {
|
|
65
|
-
counterInc: (n, v, l) => void counter.push([n, v, l]),
|
|
66
|
-
gaugeSet: (n, v, l) => void gauge.push([n, v, l]),
|
|
67
|
-
histogramRecord: (n, v, l) => void histo.push([n, v, l]),
|
|
68
|
-
};
|
|
69
|
-
return { meter, counter, gauge, histo };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
it("fans counter/gauge/histogram across meters", () => {
|
|
73
|
-
const a = recorder();
|
|
74
|
-
const b = recorder();
|
|
75
|
-
const composite = createCompositeMeter([a.meter, b.meter]);
|
|
76
|
-
|
|
77
|
-
composite.counterInc("c", 1, { p: "/" });
|
|
78
|
-
composite.gaugeSet?.("g", 5);
|
|
79
|
-
composite.histogramRecord?.("h", 100, { route: "/p" });
|
|
80
|
-
|
|
81
|
-
expect(a.counter[0].slice(0, 2)).toEqual(["c", 1]);
|
|
82
|
-
expect(a.counter[0][2]).toEqual({ p: "/" });
|
|
83
|
-
expect(b.counter[0].slice(0, 2)).toEqual(["c", 1]);
|
|
84
|
-
expect(a.gauge[0].slice(0, 2)).toEqual(["g", 5]);
|
|
85
|
-
expect(b.gauge[0].slice(0, 2)).toEqual(["g", 5]);
|
|
86
|
-
expect(a.histo[0]).toEqual(["h", 100, { route: "/p" }]);
|
|
87
|
-
expect(b.histo[0]).toEqual(["h", 100, { route: "/p" }]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("isolates errors per meter and per call type", () => {
|
|
91
|
-
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
92
|
-
const broken: MeterAdapter = {
|
|
93
|
-
counterInc: () => {
|
|
94
|
-
throw new Error("c");
|
|
95
|
-
},
|
|
96
|
-
gaugeSet: () => {
|
|
97
|
-
throw new Error("g");
|
|
98
|
-
},
|
|
99
|
-
histogramRecord: () => {
|
|
100
|
-
throw new Error("h");
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
const ok = recorder();
|
|
104
|
-
const composite = createCompositeMeter([broken, ok.meter]);
|
|
105
|
-
|
|
106
|
-
composite.counterInc("c", 1);
|
|
107
|
-
composite.gaugeSet?.("g", 5);
|
|
108
|
-
composite.histogramRecord?.("h", 100);
|
|
109
|
-
|
|
110
|
-
expect(ok.counter[0].slice(0, 2)).toEqual(["c", 1]);
|
|
111
|
-
expect(ok.gauge[0].slice(0, 2)).toEqual(["g", 5]);
|
|
112
|
-
expect(ok.histo[0].slice(0, 2)).toEqual(["h", 100]);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("skips meters that don't implement optional ops", () => {
|
|
116
|
-
const onlyCounter: MeterAdapter = { counterInc: () => {} };
|
|
117
|
-
const composite = createCompositeMeter([onlyCounter]);
|
|
118
|
-
expect(() => composite.gaugeSet?.("g", 1)).not.toThrow();
|
|
119
|
-
expect(() => composite.histogramRecord?.("h", 1)).not.toThrow();
|
|
120
|
-
});
|
|
121
|
-
});
|
package/src/sdk/cookie.test.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
deleteResponseCookie,
|
|
4
|
-
getCookies,
|
|
5
|
-
setResponseCookie,
|
|
6
|
-
} from "./cookie";
|
|
7
|
-
|
|
8
|
-
describe("getCookies", () => {
|
|
9
|
-
it("returns an empty object when no Cookie header is present", () => {
|
|
10
|
-
expect(getCookies(new Headers())).toEqual({});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("parses a single cookie", () => {
|
|
14
|
-
const h = new Headers({ cookie: "session=abc" });
|
|
15
|
-
expect(getCookies(h)).toEqual({ session: "abc" });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("parses multiple cookies separated by '; '", () => {
|
|
19
|
-
const h = new Headers({ cookie: "a=1; b=2; c=3" });
|
|
20
|
-
expect(getCookies(h)).toEqual({ a: "1", b: "2", c: "3" });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("URL-decodes values", () => {
|
|
24
|
-
const h = new Headers({ cookie: "u=hello%20world" });
|
|
25
|
-
expect(getCookies(h)).toEqual({ u: "hello world" });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("falls back to the raw value when decoding fails", () => {
|
|
29
|
-
// Lone '%' is invalid in URL encoding.
|
|
30
|
-
const h = new Headers({ cookie: "x=100%" });
|
|
31
|
-
expect(getCookies(h)).toEqual({ x: "100%" });
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("ignores entries without an '='", () => {
|
|
35
|
-
const h = new Headers({ cookie: "garbage; ok=yes" });
|
|
36
|
-
expect(getCookies(h)).toEqual({ ok: "yes" });
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("trims whitespace around names", () => {
|
|
40
|
-
const h = new Headers({ cookie: " a=1; b=2 " });
|
|
41
|
-
expect(getCookies(h)).toEqual({ a: "1", b: "2" });
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("setResponseCookie", () => {
|
|
46
|
-
it("appends a Set-Cookie header with the cookie name and value", () => {
|
|
47
|
-
const h = new Headers();
|
|
48
|
-
setResponseCookie(h, { name: "session", value: "abc" });
|
|
49
|
-
expect(h.get("set-cookie")).toBe("session=abc");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("serializes maxAge, path, secure, httpOnly, sameSite, domain", () => {
|
|
53
|
-
const h = new Headers();
|
|
54
|
-
setResponseCookie(h, {
|
|
55
|
-
name: "session",
|
|
56
|
-
value: "abc",
|
|
57
|
-
maxAge: 3600,
|
|
58
|
-
path: "/",
|
|
59
|
-
domain: "example.com",
|
|
60
|
-
secure: true,
|
|
61
|
-
httpOnly: true,
|
|
62
|
-
sameSite: "Lax",
|
|
63
|
-
});
|
|
64
|
-
const value = h.get("set-cookie")!;
|
|
65
|
-
expect(value).toContain("session=abc");
|
|
66
|
-
expect(value).toContain("Max-Age=3600");
|
|
67
|
-
expect(value).toContain("Domain=example.com");
|
|
68
|
-
expect(value).toContain("Path=/");
|
|
69
|
-
expect(value).toContain("Secure");
|
|
70
|
-
expect(value).toContain("HttpOnly");
|
|
71
|
-
expect(value).toContain("SameSite=Lax");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("serializes expires as a UTC string", () => {
|
|
75
|
-
const h = new Headers();
|
|
76
|
-
const date = new Date("2030-01-01T00:00:00Z");
|
|
77
|
-
setResponseCookie(h, { name: "x", value: "y", expires: date });
|
|
78
|
-
expect(h.get("set-cookie")).toContain(`Expires=${date.toUTCString()}`);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("appends multiple cookies (does not overwrite the first)", () => {
|
|
82
|
-
const h = new Headers();
|
|
83
|
-
setResponseCookie(h, { name: "a", value: "1" });
|
|
84
|
-
setResponseCookie(h, { name: "b", value: "2" });
|
|
85
|
-
// Headers.getAll isn't standard; getSetCookie() is the modern API.
|
|
86
|
-
const all = (h as any).getSetCookie?.() as string[] | undefined;
|
|
87
|
-
if (all) {
|
|
88
|
-
expect(all).toEqual(["a=1", "b=2"]);
|
|
89
|
-
} else {
|
|
90
|
-
// Fallback: the combined header value should mention both.
|
|
91
|
-
const v = h.get("set-cookie")!;
|
|
92
|
-
expect(v).toContain("a=1");
|
|
93
|
-
expect(v).toContain("b=2");
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe("deleteResponseCookie", () => {
|
|
99
|
-
it("emits a Set-Cookie that expires immediately", () => {
|
|
100
|
-
const h = new Headers();
|
|
101
|
-
deleteResponseCookie(h, "session", { path: "/" });
|
|
102
|
-
const value = h.get("set-cookie")!;
|
|
103
|
-
expect(value).toContain("session=");
|
|
104
|
-
expect(value).toContain("Max-Age=0");
|
|
105
|
-
expect(value).toContain(`Expires=${new Date(0).toUTCString()}`);
|
|
106
|
-
expect(value).toContain("Path=/");
|
|
107
|
-
});
|
|
108
|
-
});
|
package/src/sdk/encoding.test.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
decodeBase64,
|
|
4
|
-
decodeBase64Url,
|
|
5
|
-
encodeBase64,
|
|
6
|
-
encodeBase64Url,
|
|
7
|
-
} from "./encoding";
|
|
8
|
-
|
|
9
|
-
describe("encodeBase64 / decodeBase64", () => {
|
|
10
|
-
it("round-trips ASCII strings", () => {
|
|
11
|
-
const data = "hello, world";
|
|
12
|
-
const b64 = encodeBase64(data);
|
|
13
|
-
expect(b64).toBe("aGVsbG8sIHdvcmxk");
|
|
14
|
-
const decoded = new TextDecoder().decode(decodeBase64(b64));
|
|
15
|
-
expect(decoded).toBe(data);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("round-trips multi-byte UTF-8", () => {
|
|
19
|
-
const data = "São Paulo — café ☕";
|
|
20
|
-
const b64 = encodeBase64(data);
|
|
21
|
-
const decoded = new TextDecoder().decode(decodeBase64(b64));
|
|
22
|
-
expect(decoded).toBe(data);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("accepts Uint8Array input", () => {
|
|
26
|
-
const bytes = new Uint8Array([1, 2, 3, 4, 5]);
|
|
27
|
-
const b64 = encodeBase64(bytes);
|
|
28
|
-
expect(decodeBase64(b64)).toEqual(bytes);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("accepts ArrayBuffer input", () => {
|
|
32
|
-
const buf = new Uint8Array([255, 254, 253]).buffer;
|
|
33
|
-
const b64 = encodeBase64(buf);
|
|
34
|
-
expect(Array.from(decodeBase64(b64))).toEqual([255, 254, 253]);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("handles inputs larger than the chunking window", () => {
|
|
38
|
-
// 0x8000 + 7 bytes — forces the chunking branch.
|
|
39
|
-
const bytes = new Uint8Array(0x8000 + 7);
|
|
40
|
-
for (let i = 0; i < bytes.length; i++) bytes[i] = i & 0xff;
|
|
41
|
-
const b64 = encodeBase64(bytes);
|
|
42
|
-
expect(decodeBase64(b64)).toEqual(bytes);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe("encodeBase64Url / decodeBase64Url", () => {
|
|
47
|
-
it("uses URL-safe alphabet and strips padding", () => {
|
|
48
|
-
// Inputs that produce '+', '/', and padding under standard base64.
|
|
49
|
-
const bytes = new Uint8Array([251, 255, 191, 251, 239, 254]);
|
|
50
|
-
const standard = encodeBase64(bytes);
|
|
51
|
-
const url = encodeBase64Url(bytes);
|
|
52
|
-
// Every '+' becomes '-', '/' becomes '_', trailing '=' is stripped.
|
|
53
|
-
expect(url).toBe(
|
|
54
|
-
standard.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""),
|
|
55
|
-
);
|
|
56
|
-
expect(url).not.toContain("+");
|
|
57
|
-
expect(url).not.toContain("/");
|
|
58
|
-
expect(url).not.toContain("=");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("round-trips through the URL-safe pair", () => {
|
|
62
|
-
const data = new Uint8Array(64);
|
|
63
|
-
for (let i = 0; i < data.length; i++) data[i] = (i * 7) & 0xff;
|
|
64
|
-
expect(decodeBase64Url(encodeBase64Url(data))).toEqual(data);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("decodes inputs missing their padding", () => {
|
|
68
|
-
// 'a' = 0x61. encodeBase64('a') = 'YQ==', URL form drops to 'YQ'.
|
|
69
|
-
expect(new TextDecoder().decode(decodeBase64Url("YQ"))).toBe("a");
|
|
70
|
-
});
|
|
71
|
-
});
|
package/src/sdk/env.test.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
// isDevMode() memoises its result in module-level state after the first
|
|
4
|
-
// call, so each case below resets modules and re-imports fresh to get an
|
|
5
|
-
// unmemoised read for the NODE_ENV value it's stubbing.
|
|
6
|
-
describe("isDevMode", () => {
|
|
7
|
-
afterEach(() => {
|
|
8
|
-
vi.unstubAllEnvs();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("is false when NODE_ENV is production", async () => {
|
|
12
|
-
vi.stubEnv("NODE_ENV", "production");
|
|
13
|
-
vi.stubEnv("DECO_PREVIEW", "");
|
|
14
|
-
vi.resetModules();
|
|
15
|
-
const { isDevMode } = await import("./env");
|
|
16
|
-
expect(isDevMode()).toBe(false);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("is true when NODE_ENV is development", async () => {
|
|
20
|
-
vi.stubEnv("NODE_ENV", "development");
|
|
21
|
-
vi.resetModules();
|
|
22
|
-
const { isDevMode } = await import("./env");
|
|
23
|
-
expect(isDevMode()).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("is true when DECO_PREVIEW=true even if NODE_ENV is production", async () => {
|
|
27
|
-
vi.stubEnv("NODE_ENV", "production");
|
|
28
|
-
vi.stubEnv("DECO_PREVIEW", "true");
|
|
29
|
-
vi.resetModules();
|
|
30
|
-
const { isDevMode } = await import("./env");
|
|
31
|
-
expect(isDevMode()).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/src/sdk/flags.test.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
parseSegmentCookie,
|
|
4
|
-
type StoredFlag,
|
|
5
|
-
segmentCacheToken,
|
|
6
|
-
serializeSegmentCookie,
|
|
7
|
-
trafficToPct,
|
|
8
|
-
} from "./flags";
|
|
9
|
-
|
|
10
|
-
describe("trafficToPct", () => {
|
|
11
|
-
it("maps a ratio to a 0-100 integer", () => {
|
|
12
|
-
expect(trafficToPct(0.5)).toBe(50);
|
|
13
|
-
expect(trafficToPct(0.234)).toBe(23);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("clamps out-of-range and non-finite values", () => {
|
|
17
|
-
expect(trafficToPct(0)).toBe(0);
|
|
18
|
-
expect(trafficToPct(-1)).toBe(0);
|
|
19
|
-
expect(trafficToPct(1)).toBe(100);
|
|
20
|
-
expect(trafficToPct(2)).toBe(100);
|
|
21
|
-
expect(trafficToPct(NaN)).toBe(0);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe("deco_segment round-trip", () => {
|
|
26
|
-
it("round-trips a single active flag", () => {
|
|
27
|
-
const flags: StoredFlag[] = [{ name: "TestHero", value: true, pct: 50 }];
|
|
28
|
-
expect(parseSegmentCookie(serializeSegmentCookie(flags))).toEqual(flags);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("round-trips active + inactive flags (sorted by name)", () => {
|
|
32
|
-
const flags: StoredFlag[] = [
|
|
33
|
-
{ name: "Zeta", value: false, pct: 20 },
|
|
34
|
-
{ name: "Alpha", value: true, pct: 70 },
|
|
35
|
-
];
|
|
36
|
-
expect(parseSegmentCookie(serializeSegmentCookie(flags))).toEqual([
|
|
37
|
-
{ name: "Alpha", value: true, pct: 70 },
|
|
38
|
-
{ name: "Zeta", value: false, pct: 20 },
|
|
39
|
-
]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("produces the classic deco_segment shape that OneDollarStats reads", () => {
|
|
43
|
-
const raw = serializeSegmentCookie([
|
|
44
|
-
{ name: "TestHero", value: true, pct: 50 },
|
|
45
|
-
{ name: "Promo", value: false, pct: 30 },
|
|
46
|
-
]);
|
|
47
|
-
// Mirrors @decocms/apps OneDollarStats readFlagsFromCookie decode.
|
|
48
|
-
const seg = JSON.parse(decodeURIComponent(atob(raw)));
|
|
49
|
-
expect(seg.active).toContain("TestHero");
|
|
50
|
-
expect(seg.inactiveDrawn).toContain("Promo");
|
|
51
|
-
expect(seg.pct).toEqual({ TestHero: 50, Promo: 30 });
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("is raw base64 (no percent-escapes) so atob() works directly", () => {
|
|
55
|
-
const raw = serializeSegmentCookie([{ name: "TestHero", value: true, pct: 50 }]);
|
|
56
|
-
expect(raw).not.toMatch(/%/);
|
|
57
|
-
expect(() => atob(raw)).not.toThrow();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("parseSegmentCookie robustness", () => {
|
|
62
|
-
it("returns [] for empty / nullish / malformed input", () => {
|
|
63
|
-
expect(parseSegmentCookie(undefined)).toEqual([]);
|
|
64
|
-
expect(parseSegmentCookie(null)).toEqual([]);
|
|
65
|
-
expect(parseSegmentCookie("")).toEqual([]);
|
|
66
|
-
expect(parseSegmentCookie("not-base64-!!!")).toEqual([]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("marks classic segments without a pct fingerprint as pct: -1", () => {
|
|
70
|
-
const raw = btoa(encodeURIComponent(JSON.stringify({ active: ["Legacy"], inactiveDrawn: [] })));
|
|
71
|
-
expect(parseSegmentCookie(raw)).toEqual([{ name: "Legacy", value: true, pct: -1 }]);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe("segmentCacheToken", () => {
|
|
76
|
-
it("is empty for no flags so non-A/B pages share a cache entry", () => {
|
|
77
|
-
expect(segmentCacheToken([])).toBe("");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("includes the pct fingerprint so a traffic change re-buckets", () => {
|
|
81
|
-
const at50 = segmentCacheToken([{ name: "TestHero", value: true, pct: 50 }]);
|
|
82
|
-
const at70 = segmentCacheToken([{ name: "TestHero", value: true, pct: 70 }]);
|
|
83
|
-
expect(at50).not.toBe(at70);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("differs by decision so cohorts split", () => {
|
|
87
|
-
const on = segmentCacheToken([{ name: "TestHero", value: true, pct: 50 }]);
|
|
88
|
-
const off = segmentCacheToken([{ name: "TestHero", value: false, pct: 50 }]);
|
|
89
|
-
expect(on).not.toBe(off);
|
|
90
|
-
});
|
|
91
|
-
});
|