create-ailk 0.45.0 → 0.46.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/README.md +6 -3
- package/component-catalog.json +24 -1
- package/component-catalog.md +6 -5
- package/dist/lib/env-catalog.js +1 -1
- package/dist/lib/import-mdx.js +10 -2
- package/dist/seed-workspace.d.ts +1 -1
- package/dist/seed-workspace.js +10 -3
- package/dist/surfaces.js +1 -1
- package/package.json +3 -3
- package/templates/apps/api/.env.example +23 -0
- package/templates/apps/api/CLAUDE.md +13 -6
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +11 -0
- package/templates/apps/mcp/.env.example +8 -0
- package/templates/apps/mcp/CLAUDE.md +22 -6
- package/templates/apps/web/.env.example +1 -1
- package/templates/apps/web/CLAUDE.md +47 -16
- package/templates/apps/web/app/.well-known/mcp.json/route.ts +6 -7
- package/templates/apps/web/app/[locale]/layout.tsx +10 -7
- package/templates/apps/web/app/api/site-status/__tests__/route.test.ts +120 -0
- package/templates/apps/web/app/api/site-status/route.ts +62 -0
- package/templates/apps/web/app/llms.txt/route.ts +3 -3
- package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +21 -4
- package/templates/apps/web/app/openapi.json/route.ts +10 -9
- package/templates/apps/web/app/sitemap.xml/route.ts +3 -3
- package/templates/apps/web/auth.ts +25 -1
- package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +10 -3
- package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +61 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +112 -0
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +280 -0
- package/templates/apps/web/lib/__tests__/site-brand.test.ts +5 -6
- package/templates/apps/web/lib/__tests__/site-visibility.test.ts +64 -0
- package/templates/apps/web/lib/mcp-oauth.ts +64 -0
- package/templates/apps/web/lib/mcp-served-tools.ts +51 -9
- package/templates/apps/web/lib/offerings-pricing.ts +30 -6
- package/templates/apps/web/lib/pricing-page.ts +142 -35
- package/templates/apps/web/lib/site-brand.tsx +1 -7
- package/templates/apps/web/lib/site-visibility.ts +45 -0
- package/templates/apps/web/messages/en.json +8 -0
- package/templates/apps/web/middleware.ts +16 -1
- package/templates/apps/web/src/lib/routes.ts +3 -3
- package/versions.json +51 -51
- package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +0 -93
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Route handler tests: GET /openapi.json (#7396)
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* answers 502 — never the 404 an agent following the manifest used to get.
|
|
8
|
+
* This route serves the site's OpenAPI document on the web host by proxying
|
|
9
|
+
* the API's own `/v1/openapi.json`; when the API cannot answer it, the route
|
|
10
|
+
* answers 502 — never a 404 an agent could read as "no API".
|
|
12
11
|
* A relative `servers[]` URL is resolved against the API origin, so the
|
|
13
12
|
* document never sends an agent to this (web) host for an API call.
|
|
14
13
|
*/
|
|
@@ -342,4 +341,22 @@ describe("GET /openapi.json and the owner's discovery switch (#10510)", () => {
|
|
|
342
341
|
expect(response.headers.get("cache-control")).toBe("no-store");
|
|
343
342
|
expect(fetchSpy).not.toHaveBeenCalled();
|
|
344
343
|
});
|
|
344
|
+
|
|
345
|
+
// #11978 D2, AC-2 (e) — STEALTH hides it too, before the switch is read.
|
|
346
|
+
it("STEALTH with the switch on: 404, never cached, the API never fetched", async () => {
|
|
347
|
+
const saved = process.env["STEALTH"];
|
|
348
|
+
process.env["STEALTH"] = "true";
|
|
349
|
+
try {
|
|
350
|
+
apiAnswers(200, JSON.stringify(SPEC));
|
|
351
|
+
const response = await GET();
|
|
352
|
+
expect(response.status).toBe(404);
|
|
353
|
+
expect(await response.text()).toBe("");
|
|
354
|
+
expect(response.headers.get("cache-control")).toBe("no-store");
|
|
355
|
+
expect(fetchSpy).not.toHaveBeenCalled();
|
|
356
|
+
expect(mockSiteDiscoverable).not.toHaveBeenCalled();
|
|
357
|
+
} finally {
|
|
358
|
+
if (saved === undefined) delete process.env["STEALTH"];
|
|
359
|
+
else process.env["STEALTH"] = saved;
|
|
360
|
+
}
|
|
361
|
+
});
|
|
345
362
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GET /openapi.json
|
|
3
3
|
*
|
|
4
|
-
* The OpenAPI document
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* The site's OpenAPI document at its conventional path (#7396), for a
|
|
5
|
+
* non-MCP agent that calls the HTTP API — an OpenAPI importer such as a
|
|
6
|
+
* custom-GPT Action takes this URL directly (#11978 D9; no manifest points at
|
|
7
|
+
* it since `/.well-known/ai-plugin.json` was dropped). apps/api renders it at
|
|
8
|
+
* `/v1/openapi.json`; this route serves that same document on the web host.
|
|
9
|
+
* It is read over HTTP — apps/web never imports apps/api.
|
|
9
10
|
*
|
|
10
11
|
* A `servers[]` URL that is relative (apps/api emits `/` when
|
|
11
12
|
* AILK_PUBLIC_API_URL is unset) is resolved against the API origin before the
|
|
@@ -23,10 +24,9 @@
|
|
|
23
24
|
* host, and never calls a path this site would answer 404.
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
import { siteDiscoverable } from "@working-theory/api-client";
|
|
27
|
-
|
|
28
27
|
import { browserApiOrigin } from "../../lib/api-origin.generated";
|
|
29
28
|
import { RELAY_ROUTES } from "../../lib/relay";
|
|
29
|
+
import { siteHidden } from "../../lib/site-visibility";
|
|
30
30
|
import { TOPOLOGY } from "../../lib/topology.generated";
|
|
31
31
|
import { resolveBaseUrl } from "../../src/lib/routes";
|
|
32
32
|
|
|
@@ -159,8 +159,9 @@ function badGateway(message: string): Response {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
export async function GET(): Promise<Response> {
|
|
162
|
-
// #
|
|
163
|
-
|
|
162
|
+
// #11978 D2 — Hidden (STEALTH or the owner's switch): 404, never cached,
|
|
163
|
+
// the API never read.
|
|
164
|
+
if (await siteHidden()) return new Response(null, { status: 404, headers: { "cache-control": "no-store" } });
|
|
164
165
|
let upstream: Response;
|
|
165
166
|
try {
|
|
166
167
|
upstream = await fetch(`${apiBase()}${UPSTREAM_PATH}`, {
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
* directory is listed instead (`getDocsPages`, default `listDocsPages`).
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
|
-
import { siteDiscoverable } from "@working-theory/api-client";
|
|
41
40
|
import {
|
|
42
41
|
SCHEMA_ORG_TYPES,
|
|
43
42
|
resolvedAdapterKind,
|
|
@@ -57,6 +56,7 @@ import {
|
|
|
57
56
|
} from "../../lib/docs-index";
|
|
58
57
|
import { PUBLIC_PAGES } from "../../lib/modules.generated";
|
|
59
58
|
import { SITE_LISTING } from "../../lib/site-listing";
|
|
59
|
+
import { siteLive } from "../../lib/site-visibility";
|
|
60
60
|
import { pagePathFor, resolveBaseUrl } from "../../src/lib/routes";
|
|
61
61
|
|
|
62
62
|
// #10510 D4 — read per request: the owner's discovery switch is a runtime
|
|
@@ -71,7 +71,7 @@ export interface SitemapHandlerDeps {
|
|
|
71
71
|
getContentAdapter?: () => ContentAdapter;
|
|
72
72
|
/** The docs pages (#10041). Defaults to `listDocsPages` over this app's docs directory. */
|
|
73
73
|
getDocsPages?: () => DocsIndexPage[];
|
|
74
|
-
/** The owner's discovery switch (#10510 D4). Defaults to `
|
|
74
|
+
/** The owner's discovery switch (#10510 D4). Defaults to `siteLive` — Hidden under STEALTH too (#11978). */
|
|
75
75
|
discoverable?: () => Promise<boolean>;
|
|
76
76
|
/** The site's own listing (#10940 D3). Defaults to `SITE_LISTING`. */
|
|
77
77
|
getSiteListing?: () => SiteListing;
|
|
@@ -110,7 +110,7 @@ function buildLocaleUrl(
|
|
|
110
110
|
export function createSitemapHandler(deps: SitemapHandlerDeps = {}) {
|
|
111
111
|
const resolveAdapter = deps.getContentAdapter ?? defaultGetContentAdapter;
|
|
112
112
|
const resolveDocsPages = deps.getDocsPages ?? listDocsPages;
|
|
113
|
-
const isDiscoverable = deps.discoverable ??
|
|
113
|
+
const isDiscoverable = deps.discoverable ?? siteLive;
|
|
114
114
|
const resolveSiteListing = deps.getSiteListing ?? (() => SITE_LISTING);
|
|
115
115
|
return async function sitemapGET(): Promise<Response> {
|
|
116
116
|
// #10040 decision 7 — no public page, no sitemap: 404 before the adapter.
|
|
@@ -618,6 +618,17 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
618
618
|
/** Plain assignment, no cast — see `VerificationStore`. */
|
|
619
619
|
const verificationStore: VerificationStore = prisma;
|
|
620
620
|
|
|
621
|
+
/**
|
|
622
|
+
* #12063 FR7 — the MCP server's outside-send clear: one person's switches,
|
|
623
|
+
* for one client or (no `applicationId`) every OAuth client of theirs, in
|
|
624
|
+
* every workspace. Agent-key switches are never touched here.
|
|
625
|
+
*/
|
|
626
|
+
const clearOutsideSendSwitches = async (target: { userId: string; applicationId?: string }): Promise<void> => {
|
|
627
|
+
await prisma.outsideSendGrant.deleteMany({
|
|
628
|
+
where: { userId: target.userId, applicationId: target.applicationId ?? { not: null } },
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
|
|
621
632
|
// No cast: `AuthEmailPrisma` is declared with method shorthand, which the
|
|
622
633
|
// generated `PrismaClient` satisfies structurally (see its docblock).
|
|
623
634
|
const sendResetPassword = makeSendResetPassword({
|
|
@@ -750,6 +761,19 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
750
761
|
})}`,
|
|
751
762
|
);
|
|
752
763
|
}
|
|
764
|
+
// #12063 FR7 — the outside-send switches of those connections go with
|
|
765
|
+
// them. Guarded like its siblings: the reset has already happened.
|
|
766
|
+
try {
|
|
767
|
+
await clearOutsideSendSwitches({ userId: user.id });
|
|
768
|
+
} catch {
|
|
769
|
+
console.warn(
|
|
770
|
+
`[auth-email] ${JSON.stringify({
|
|
771
|
+
userId: user.id,
|
|
772
|
+
kind: "password-reset",
|
|
773
|
+
reason: "outside_send_clear_failed",
|
|
774
|
+
})}`,
|
|
775
|
+
);
|
|
776
|
+
}
|
|
753
777
|
/**
|
|
754
778
|
* Guarded like its sibling above, though `lib/auth-email.ts` now also
|
|
755
779
|
* guards its own signing step (#6068). BOTH, deliberately: this callback
|
|
@@ -807,7 +831,7 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
807
831
|
})),
|
|
808
832
|
);
|
|
809
833
|
};
|
|
810
|
-
const mcpServer = baseURL ? mcpAuthorizationServer({ readMemberships }) : [];
|
|
834
|
+
const mcpServer = baseURL ? mcpAuthorizationServer({ readMemberships, clearOutsideSendSwitches }) : [];
|
|
811
835
|
|
|
812
836
|
/** The phone step (#11106 D9); its sign-in and reset paths close with it. */
|
|
813
837
|
const phoneActive = phoneStepActive();
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* the transport it answers 406 to an `accept` missing either type and 415 to
|
|
15
15
|
* a POST that is not `application/json`. `tools/list` can be served in pages,
|
|
16
16
|
* and `override` can answer any request with a fixed status, a raw body, or
|
|
17
|
-
* no answer at all.
|
|
18
|
-
*
|
|
17
|
+
* no answer at all. `experimental` is put in the `initialize` result's
|
|
18
|
+
* `capabilities`, as the server reports its installed tools (#11978 D4).
|
|
19
|
+
* Every request is recorded. The stub follows the server, never the other
|
|
20
|
+
* way round.
|
|
19
21
|
*/
|
|
20
22
|
|
|
21
23
|
import {
|
|
@@ -54,6 +56,8 @@ export interface McpStubOptions {
|
|
|
54
56
|
/** Serve `tools/list` this many entries a page, `nextCursor` on all but the last. */
|
|
55
57
|
pageSize?: number;
|
|
56
58
|
override?: (request: RecordedRequest) => StubOverride | undefined;
|
|
59
|
+
/** #11978 D4 — the `initialize` result's `capabilities.experimental`. */
|
|
60
|
+
experimental?: Record<string, unknown>;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
export interface McpStub {
|
|
@@ -173,7 +177,10 @@ export async function startMcpStub(options: McpStubOptions): Promise<McpStub> {
|
|
|
173
177
|
id: rpc.id,
|
|
174
178
|
result: {
|
|
175
179
|
protocolVersion: PROTOCOL_VERSION,
|
|
176
|
-
capabilities: {
|
|
180
|
+
capabilities: {
|
|
181
|
+
tools: { listChanged: true },
|
|
182
|
+
...(options.experimental ? { experimental: options.experimental } : {}),
|
|
183
|
+
},
|
|
177
184
|
serverInfo: { name: "mcp-stub", version: "0.0.0" },
|
|
178
185
|
},
|
|
179
186
|
},
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* anonymous `/mcp` route (#11951 spec AC-1, AC-2, §5.2): the four-step
|
|
8
8
|
* exchange in both transport modes, `nextCursor` paging, every failed-read
|
|
9
9
|
* shape resolving `null`, the 60-second shared answer and the user agent.
|
|
10
|
+
* `readMcpServer` (#11978 D3, AC-5 (b)): a refusal told from an outage, and
|
|
11
|
+
* the installed tools the server reports.
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
import {
|
|
@@ -14,6 +16,7 @@ import {
|
|
|
14
16
|
MCP_TOOLS_TIMEOUT_MS,
|
|
15
17
|
MCP_TOOLS_TTL_MS,
|
|
16
18
|
__resetServedMcpToolsForTests,
|
|
19
|
+
readMcpServer,
|
|
17
20
|
readServedMcpTools,
|
|
18
21
|
} from "../mcp-served-tools";
|
|
19
22
|
|
|
@@ -332,3 +335,61 @@ describe("readServedMcpTools — sharing and the user agent (§5.2)", () => {
|
|
|
332
335
|
}
|
|
333
336
|
});
|
|
334
337
|
});
|
|
338
|
+
|
|
339
|
+
// #11978 D3, AC-5 (b) — what the site's status report says of its MCP server.
|
|
340
|
+
describe("readMcpServer — the answer the status route reports (#11978 D3)", () => {
|
|
341
|
+
const INSTALLED = ["create_booking", "get_redirect"];
|
|
342
|
+
|
|
343
|
+
it.each(["stateless", "stateful"] as const)(
|
|
344
|
+
"%s: an initialize carrying ailk/installed → answering with the installed names",
|
|
345
|
+
async (mode) => {
|
|
346
|
+
const server = await stub({ mode, experimental: { "ailk/installed": { tools: INSTALLED } } });
|
|
347
|
+
expect(await readMcpServer(server.url)).toEqual({
|
|
348
|
+
state: "answering",
|
|
349
|
+
tools: SERVED,
|
|
350
|
+
installed: INSTALLED,
|
|
351
|
+
});
|
|
352
|
+
__resetServedMcpToolsForTests();
|
|
353
|
+
expect(await readServedMcpTools(server.url)).toEqual(SERVED);
|
|
354
|
+
},
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
it("an initialize without it → installed null", async () => {
|
|
358
|
+
const server = await stub();
|
|
359
|
+
expect(await readMcpServer(server.url)).toEqual({
|
|
360
|
+
state: "answering",
|
|
361
|
+
tools: SERVED,
|
|
362
|
+
installed: null,
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it.each([
|
|
367
|
+
[{ "ailk/installed": { tools: "create_booking" } }],
|
|
368
|
+
[{ "ailk/installed": { tools: [1] } }],
|
|
369
|
+
[{ "ailk/installed": [] }],
|
|
370
|
+
])("a malformed capability %j → installed null", async (experimental) => {
|
|
371
|
+
const server = await stub({ experimental });
|
|
372
|
+
expect(await readMcpServer(server.url)).toMatchObject({ installed: null });
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it("initialize answering 404 → refused, and readServedMcpTools null", async () => {
|
|
376
|
+
const server = await stub({ override: (r) => (r.rpcMethod === "initialize" ? { status: 404 } : undefined) });
|
|
377
|
+
expect(await readMcpServer(server.url)).toEqual({ state: "refused" });
|
|
378
|
+
expect(await readServedMcpTools(server.url)).toBeNull();
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("initialize answering 500 → unreachable", async () => {
|
|
382
|
+
const server = await stub({ override: (r) => (r.rpcMethod === "initialize" ? { status: 500 } : undefined) });
|
|
383
|
+
expect(await readMcpServer(server.url)).toEqual({ state: "unreachable" });
|
|
384
|
+
expect(await readServedMcpTools(server.url)).toBeNull();
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it("a tools/list 404 after an answered initialize → unreachable, not refused", async () => {
|
|
388
|
+
const server = await stub({ override: (r) => (r.rpcMethod === "tools/list" ? { status: 404 } : undefined) });
|
|
389
|
+
expect(await readMcpServer(server.url)).toEqual({ state: "unreachable" });
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it("a refused connection → unreachable", async () => {
|
|
393
|
+
expect(await readMcpServer(await refusedUrl())).toEqual({ state: "unreachable" });
|
|
394
|
+
});
|
|
395
|
+
});
|
|
@@ -815,3 +815,115 @@ describe("offeringsPricing — the route's wire shape (#8927 D3, AC-7)", () => {
|
|
|
815
815
|
).toBeNull();
|
|
816
816
|
});
|
|
817
817
|
});
|
|
818
|
+
|
|
819
|
+
describe("offeringsPricing — the seller's button label (#12103 D1, AC-1)", () => {
|
|
820
|
+
const monthly = (plan: string) => [price(plan, "monthly", 4900, "usd")];
|
|
821
|
+
function set(offerings: OfferingsProduct[]): WorkspaceShownSet {
|
|
822
|
+
return shownSet((s) => {
|
|
823
|
+
s.offerings = offerings;
|
|
824
|
+
s.productIds = offerings.map((o) => o.productId);
|
|
825
|
+
s.recommended = { plan: null, addon: null };
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
it("labels a card with its own ctaLabel and keeps the translated default on a card without one", () => {
|
|
830
|
+
const result = mapped(
|
|
831
|
+
set([
|
|
832
|
+
product("essentials", "plan", monthly("essentials"), { ctaLabel: "Start Essentials" }),
|
|
833
|
+
product("growth", "plan", monthly("growth")),
|
|
834
|
+
]),
|
|
835
|
+
);
|
|
836
|
+
expect(card(result, "essentials").cta).toEqual({
|
|
837
|
+
label: "Start Essentials",
|
|
838
|
+
href: "/api/offerings/checkout/essentials_monthly",
|
|
839
|
+
});
|
|
840
|
+
expect(card(result, "growth").cta?.label).toBe(LABELS.cta);
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
it("labels an add-on tile and a bundle card with their own ctaLabel, the bundle href unchanged", () => {
|
|
844
|
+
const result = mapped(
|
|
845
|
+
set([
|
|
846
|
+
product("retainer", "plan", monthly("retainer")),
|
|
847
|
+
product("setup", "plan", [price("setup", "once", 50000, "usd")], {
|
|
848
|
+
requires: "retainer",
|
|
849
|
+
ctaLabel: "Start the bundle",
|
|
850
|
+
}),
|
|
851
|
+
product("seo", "addon", monthly("seo"), { ctaLabel: "Add it" }),
|
|
852
|
+
]),
|
|
853
|
+
);
|
|
854
|
+
expect(card(result, "setup").cta).toEqual({
|
|
855
|
+
label: "Start the bundle",
|
|
856
|
+
href: offeringsBundleHref("setup_once", "retainer_monthly"),
|
|
857
|
+
});
|
|
858
|
+
expect(tile(result, "seo").cta?.label).toBe("Add it");
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
it("removes a right-to-left override from the label and renders it as the button's text, linking the checkout path", () => {
|
|
862
|
+
const result = mapped(
|
|
863
|
+
set([product("essentials", "plan", monthly("essentials"), { ctaLabel: "Start now" })]),
|
|
864
|
+
);
|
|
865
|
+
expect(card(result, "essentials").cta?.label).toBe("Start now");
|
|
866
|
+
const { container } = render(
|
|
867
|
+
React.createElement(Pricing, { sectionName: "pricing", data: result.plans! }),
|
|
868
|
+
);
|
|
869
|
+
const anchor = Array.from(container.querySelectorAll("a")).find(
|
|
870
|
+
(a) => a.textContent?.includes("Start now"),
|
|
871
|
+
);
|
|
872
|
+
expect(anchor?.getAttribute("href")).toBe(hrefFor("essentials_monthly"));
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
describe("offeringsPricing — the add-on eyebrow and note (#12103 D5, AC-4)", () => {
|
|
877
|
+
const seo = (extra: Partial<OfferingsProduct>) =>
|
|
878
|
+
product("seo", "addon", [price("seo", "monthly", 900, "usd")], {
|
|
879
|
+
eyebrow: "No retainer",
|
|
880
|
+
note: "Per piece.",
|
|
881
|
+
unitLabel: "piece",
|
|
882
|
+
...extra,
|
|
883
|
+
});
|
|
884
|
+
function set(offerings: OfferingsProduct[]): WorkspaceShownSet {
|
|
885
|
+
return shownSet((s) => {
|
|
886
|
+
s.offerings = offerings;
|
|
887
|
+
s.productIds = offerings.map((o) => o.productId);
|
|
888
|
+
s.recommended = {
|
|
889
|
+
plan: null,
|
|
890
|
+
addon: offerings.find((o) => o.recommended)?.productId ?? null,
|
|
891
|
+
};
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
it("maps the eyebrow, the note and the unit label to their own tile fields", () => {
|
|
896
|
+
expect(tile(mapped(set([seo({})])), "seo")).toMatchObject({
|
|
897
|
+
eyebrow: "No retainer",
|
|
898
|
+
note: "Per piece.",
|
|
899
|
+
qualifier: "piece",
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
it("keeps the Recommended label as the recommended add-on's eyebrow, its note kept", () => {
|
|
904
|
+
expect(tile(mapped(set([seo({ recommended: true })])), "seo")).toMatchObject({
|
|
905
|
+
eyebrow: LABELS.recommended,
|
|
906
|
+
note: "Per piece.",
|
|
907
|
+
});
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
it("still maps a plan's note to its priceSubhead", () => {
|
|
911
|
+
const result = mapped();
|
|
912
|
+
expect(card(result, "growth").priceSubhead).toBe("Billed per active seat");
|
|
913
|
+
expect(card(result, "growth")).not.toHaveProperty("note");
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it("emits neither field on a tile whose product carries none", () => {
|
|
917
|
+
const t = tile(mapped(), "audit-pack");
|
|
918
|
+
expect(t).not.toHaveProperty("eyebrow");
|
|
919
|
+
expect(t).not.toHaveProperty("note");
|
|
920
|
+
});
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
describe("offeringsPricing — exclude (#12103 D2)", () => {
|
|
924
|
+
it("drops the excluded plans' cards and keeps every add-on tile", () => {
|
|
925
|
+
const result = offeringsPricing(shownSet(), { ...OPTIONS, exclude: ["growth"] })!;
|
|
926
|
+
expect(plansOf(result).map((c) => c.key)).toEqual(["starter", "basic"]);
|
|
927
|
+
expect(addonsOf(result).map((t) => t.key)).toEqual(["seo-audit", "audit-pack"]);
|
|
928
|
+
});
|
|
929
|
+
});
|