create-ailk 0.37.1 → 0.38.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 +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +18 -11
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +9 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +67 -0
- package/dist/routes.d.ts +103 -0
- package/dist/routes.js +708 -0
- package/dist/site-manifest.js +1 -1
- package/dist/site-roster.d.ts +2 -1
- package/dist/site-roster.js +30 -8
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +18 -0
- package/dist/surfaces.js +47 -282
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +86 -5
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +62 -20
- package/templates/apps/web/account.config.tsx +101 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
- package/templates/apps/web/app/[locale]/layout.tsx +45 -28
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/i18n/request.ts +44 -1
- package/templates/apps/web/jest.config.cjs +13 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/messages/en.json +8 -684
- package/templates/apps/web/middleware.ts +3 -1
- package/templates/apps/web/next.config.mjs +27 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +48 -47
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -1,936 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Artifacts pages (#8234, spec 8234 D3, D4; #8338, spec
|
|
3
|
-
* docs/specs/8338-account-artifacts-structured-like-the-spec.md D3, D7,
|
|
4
|
-
* AC-3).
|
|
5
|
-
*
|
|
6
|
-
* `/account/artifacts` and `/account/artifacts/[pieceId]`, rendered as the
|
|
7
|
-
* RSCs they are, with the api-client's `member.artifacts` as the one mocked
|
|
8
|
-
* read. Covers:
|
|
9
|
-
* - the list renders `AccountListFrame`'s table in the read's order (newest
|
|
10
|
-
* delivery first, never by title) with the columns Title · Type · Version
|
|
11
|
-
* · Status (#11161): Type the LATEST version's file type or Link, Version
|
|
12
|
-
* its number, Status the piece's STAGE as a tag with the review of the
|
|
13
|
-
* latest version (approval first, then that version's review) as a second
|
|
14
|
-
* tag — never one combined state; the facet nav reads "All Artifacts"
|
|
15
|
-
* then a "Status" group of the workspace's declared stages, every one in
|
|
16
|
-
* declared order and counted over every artifact; the lead line stays;
|
|
17
|
-
* - a 404 (and a 401/403 while the email is unverified) is the empty line;
|
|
18
|
-
* any other failure is the error row with Retry and no frame (7423 D12);
|
|
19
|
-
* - the artifact page lists versions newest first, each with its number,
|
|
20
|
-
* delivery date and note, and Download (this site's file route) or View
|
|
21
|
-
* (an https link, new tab, noopener) — and nothing for a link that is not
|
|
22
|
-
* https; no deliverer is shown; its status is the stage, the review a tag
|
|
23
|
-
* beside it and on the reviewed version;
|
|
24
|
-
* - an image or a PDF version renders inline (#11161 AC-4) from the same
|
|
25
|
-
* route's preview mode with Download beside it; any other file keeps
|
|
26
|
-
* Download alone;
|
|
27
|
-
* - the review form shows on the latest version only, only while the
|
|
28
|
-
* artifact is not approved and that version has no review; after a
|
|
29
|
-
* Request changes the page says the next version will appear there;
|
|
30
|
-
* - a proposal (#8516, spec
|
|
31
|
-
* docs/specs/8516-proposals-as-an-artifact-kind-spec.md D19, AC-3, AC-4)
|
|
32
|
-
* reads "Proposal" and its price, answers "Your decision on version <n>"
|
|
33
|
-
* with Approve proposal / Request changes, and in the latest version's
|
|
34
|
-
* place shows Pay now while payment is due, "Paid <date>" once paid, and
|
|
35
|
-
* the pending line on `?paid=1` before the webhook lands — while a
|
|
36
|
-
* deliverable renders exactly as before.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
import { act, fireEvent, render, screen, within } from "@testing-library/react";
|
|
40
|
-
|
|
41
|
-
jest.mock("next-intl/server", () => {
|
|
42
|
-
const msgs: unknown = require("../../../../../../messages/en.json");
|
|
43
|
-
const dig = (obj: unknown, path: string): unknown =>
|
|
44
|
-
path
|
|
45
|
-
.split(".")
|
|
46
|
-
.reduce<unknown>(
|
|
47
|
-
(acc, k) =>
|
|
48
|
-
acc !== null && typeof acc === "object"
|
|
49
|
-
? (acc as Record<string, unknown>)[k]
|
|
50
|
-
: undefined,
|
|
51
|
-
obj,
|
|
52
|
-
);
|
|
53
|
-
return {
|
|
54
|
-
__esModule: true,
|
|
55
|
-
getTranslations: async (
|
|
56
|
-
arg: string | { namespace?: string; locale?: string },
|
|
57
|
-
) => {
|
|
58
|
-
const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
|
|
59
|
-
const messages = dig(msgs, ns);
|
|
60
|
-
const t = (key: string, values?: Record<string, unknown>): string => {
|
|
61
|
-
const value = dig(messages, key);
|
|
62
|
-
if (typeof value !== "string") return `${ns}.${key}`;
|
|
63
|
-
return value.replace(/\{(\w+)\}/g, (m, name: string) =>
|
|
64
|
-
values && name in values ? String(values[name]) : m,
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
// #11175: the dated messages carry a `<date>` tag and render through `t.rich`.
|
|
68
|
-
const { withRich } = require("../../__tests__/rich-translator") as typeof import("../../__tests__/rich-translator");
|
|
69
|
-
return withRich(t, (key: string) => dig(messages, key), ns);
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
jest.mock("next/headers", () => ({
|
|
75
|
-
__esModule: true,
|
|
76
|
-
headers: jest.fn().mockResolvedValue(new Headers()),
|
|
77
|
-
cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
|
|
78
|
-
}));
|
|
79
|
-
|
|
80
|
-
const mockGetSession = jest.fn();
|
|
81
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; auth.ts's lazy Better-Auth singleton has no HTTP/DB boundary a unit test of the session fields can mock without standing up Prisma.
|
|
82
|
-
jest.mock("../../../../../../auth", () => ({
|
|
83
|
-
__esModule: true,
|
|
84
|
-
auth: {
|
|
85
|
-
api: { getSession: (...args: unknown[]) => mockGetSession(...args) },
|
|
86
|
-
},
|
|
87
|
-
}));
|
|
88
|
-
|
|
89
|
-
const mockArtifacts = jest.fn();
|
|
90
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
91
|
-
__esModule: true,
|
|
92
|
-
waitlistSignups: { me: jest.fn() },
|
|
93
|
-
subscription: { me: jest.fn() },
|
|
94
|
-
member: { artifacts: (...args: unknown[]) => mockArtifacts(...args) },
|
|
95
|
-
}));
|
|
96
|
-
|
|
97
|
-
const mockNotFound = jest.fn(() => {
|
|
98
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
99
|
-
});
|
|
100
|
-
const mockRefresh = jest.fn();
|
|
101
|
-
jest.mock("next/navigation", () => ({
|
|
102
|
-
__esModule: true,
|
|
103
|
-
notFound: () => mockNotFound(),
|
|
104
|
-
useRouter: () => ({ push: jest.fn(), refresh: mockRefresh }),
|
|
105
|
-
usePathname: () => "/account/artifacts",
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
// jsdom does not implement the pointer-capture / scroll APIs Radix Select
|
|
109
|
-
// relies on to open its listbox (packages/ui's own established precedent —
|
|
110
|
-
// packages/ui/src/__tests__/setup.ts).
|
|
111
|
-
beforeAll(() => {
|
|
112
|
-
Element.prototype.hasPointerCapture = (): boolean => false;
|
|
113
|
-
Element.prototype.setPointerCapture = (): void => {};
|
|
114
|
-
Element.prototype.releasePointerCapture = (): void => {};
|
|
115
|
-
Element.prototype.scrollIntoView = (): void => {};
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
import ArtifactPage from "../[pieceId]/page";
|
|
119
|
-
import ListPage from "../page";
|
|
120
|
-
|
|
121
|
-
const VERIFIED = {
|
|
122
|
-
user: {
|
|
123
|
-
id: "user_1",
|
|
124
|
-
name: "Ada",
|
|
125
|
-
email: "ada@example.com",
|
|
126
|
-
emailVerified: true,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const ID = {
|
|
131
|
-
zebra: "piece_01920000-0000-7000-8000-00000000000a",
|
|
132
|
-
mango: "piece_01920000-0000-7000-8000-00000000000b",
|
|
133
|
-
alpha: "piece_01920000-0000-7000-8000-00000000000c",
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
interface VersionFixture {
|
|
137
|
-
version: number;
|
|
138
|
-
file?: { filename: string; contentType: string; byteSize: number } | null;
|
|
139
|
-
link?: string | null;
|
|
140
|
-
note?: string | null;
|
|
141
|
-
deliveredAt?: string;
|
|
142
|
-
review?: "approved" | "changes-requested" | null;
|
|
143
|
-
reviewComment?: string | null;
|
|
144
|
-
reviewedAt?: string | null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function version(v: VersionFixture) {
|
|
148
|
-
const hasLink = v.link !== undefined && v.link !== null;
|
|
149
|
-
return {
|
|
150
|
-
version: v.version,
|
|
151
|
-
file: hasLink
|
|
152
|
-
? null
|
|
153
|
-
: (v.file ?? {
|
|
154
|
-
filename: `v${v.version}.pdf`,
|
|
155
|
-
contentType: "application/pdf",
|
|
156
|
-
byteSize: 10,
|
|
157
|
-
}),
|
|
158
|
-
link: v.link ?? null,
|
|
159
|
-
note: v.note ?? null,
|
|
160
|
-
deliveredAt: v.deliveredAt ?? `2026-09-0${v.version}T12:00:00.000Z`,
|
|
161
|
-
review: v.review ?? null,
|
|
162
|
-
reviewComment: v.reviewComment ?? null,
|
|
163
|
-
reviewedAt: v.reviewedAt ?? (v.review ? "2026-09-20T12:00:00.000Z" : null),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const STAGES = ["requested", "in-progress", "in-review", "delivered"];
|
|
168
|
-
const STAGE_LABELS = ["Requested", "In progress", "In review", "Delivered"];
|
|
169
|
-
|
|
170
|
-
function ok(items: unknown[], stages: string[] = STAGES, stageLabels: string[] = STAGE_LABELS) {
|
|
171
|
-
return { ok: true, body: { items, stages, stageLabels } };
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function refused(status: number, code = "x") {
|
|
175
|
-
return {
|
|
176
|
-
ok: false,
|
|
177
|
-
status,
|
|
178
|
-
body: { ok: false, error: { code, message: "x" } },
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// AC-3's fixture: Zebra (approved, delivered last), Mango (changes requested
|
|
183
|
-
// on the latest version, delivered second — never its OLDER version's date),
|
|
184
|
-
// Alpha (unreviewed) — in the read's own order (never re-sorted by title).
|
|
185
|
-
const ZEBRA = {
|
|
186
|
-
id: ID.zebra,
|
|
187
|
-
title: "Zebra logo",
|
|
188
|
-
approvedAt: "2026-09-25T09:00:00.000Z",
|
|
189
|
-
stage: "delivered",
|
|
190
|
-
stageLabel: "Delivered",
|
|
191
|
-
versions: [
|
|
192
|
-
version({
|
|
193
|
-
version: 3,
|
|
194
|
-
file: { filename: "zebra.png", contentType: "image/png", byteSize: 10 },
|
|
195
|
-
deliveredAt: "2026-10-03T12:00:00.000Z",
|
|
196
|
-
}),
|
|
197
|
-
],
|
|
198
|
-
};
|
|
199
|
-
const MANGO = {
|
|
200
|
-
id: ID.mango,
|
|
201
|
-
title: "Mango brief",
|
|
202
|
-
approvedAt: null,
|
|
203
|
-
stage: "in-progress",
|
|
204
|
-
stageLabel: "In progress",
|
|
205
|
-
versions: [
|
|
206
|
-
version({
|
|
207
|
-
version: 2,
|
|
208
|
-
review: "changes-requested",
|
|
209
|
-
reviewComment: "Warmer",
|
|
210
|
-
deliveredAt: "2026-10-02T12:00:00.000Z",
|
|
211
|
-
}),
|
|
212
|
-
version({ version: 1, deliveredAt: "2026-09-20T12:00:00.000Z" }),
|
|
213
|
-
],
|
|
214
|
-
};
|
|
215
|
-
const ALPHA = {
|
|
216
|
-
id: ID.alpha,
|
|
217
|
-
title: "Alpha deck",
|
|
218
|
-
approvedAt: null,
|
|
219
|
-
stage: "in-review",
|
|
220
|
-
stageLabel: "In review",
|
|
221
|
-
versions: [
|
|
222
|
-
version({ version: 1, link: "https://files.example.com/alpha", deliveredAt: "2026-09-18T12:00:00.000Z" }),
|
|
223
|
-
],
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
beforeEach(() => {
|
|
227
|
-
mockGetSession.mockReset().mockResolvedValue(VERIFIED);
|
|
228
|
-
mockArtifacts.mockReset().mockResolvedValue(ok([ZEBRA, MANGO, ALPHA]));
|
|
229
|
-
mockNotFound.mockClear();
|
|
230
|
-
mockRefresh.mockReset();
|
|
231
|
-
jest.spyOn(console, "error").mockImplementation(() => undefined);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
afterEach(() => {
|
|
235
|
-
jest.restoreAllMocks();
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
async function renderList(): Promise<void> {
|
|
239
|
-
render(await ListPage({ params: Promise.resolve({ locale: "en" }) }));
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async function renderArtifact(
|
|
243
|
-
pieceId: string,
|
|
244
|
-
searchParams?: Record<string, string>,
|
|
245
|
-
): Promise<void> {
|
|
246
|
-
render(
|
|
247
|
-
await ArtifactPage({
|
|
248
|
-
params: Promise.resolve({ locale: "en", pieceId }),
|
|
249
|
-
...(searchParams ? { searchParams: Promise.resolve(searchParams) } : {}),
|
|
250
|
-
}),
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** The zone `LocalTime` reads in this jsdom — jest's pinned UTC, until a case mocks the viewer's. */
|
|
255
|
-
const VIEWER_TIME_ZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
256
|
-
const MOUNTAIN = "America/Denver";
|
|
257
|
-
|
|
258
|
-
const medium = (iso: string, timeZone = VIEWER_TIME_ZONE): string =>
|
|
259
|
-
new Intl.DateTimeFormat("en", {
|
|
260
|
-
dateStyle: "medium",
|
|
261
|
-
timeZone,
|
|
262
|
-
}).format(new Date(iso));
|
|
263
|
-
|
|
264
|
-
/** The browser's zone, as `LocalTime` reads it through `resolvedOptions()`. */
|
|
265
|
-
function viewerZone(timeZone: string): void {
|
|
266
|
-
const real = Intl.DateTimeFormat.prototype.resolvedOptions;
|
|
267
|
-
jest
|
|
268
|
-
.spyOn(Intl.DateTimeFormat.prototype, "resolvedOptions")
|
|
269
|
-
.mockImplementation(function resolvedOptions(this: Intl.DateTimeFormat) {
|
|
270
|
-
return { ...real.call(this), timeZone };
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function facetItems(): HTMLElement[] {
|
|
275
|
-
return within(screen.getByTestId("artifacts-facets")).getAllByTestId(
|
|
276
|
-
/^artifacts-facets-item-/,
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
describe("/account/artifacts (D3, AC-3)", () => {
|
|
281
|
-
it("renders Title · Type · Version · Status in the read's order, the stage and review as tags, and the Status facets in declared order", async () => {
|
|
282
|
-
await renderList();
|
|
283
|
-
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
|
|
284
|
-
"Artifacts",
|
|
285
|
-
);
|
|
286
|
-
expect(screen.getByTestId("artifacts")).toHaveTextContent(
|
|
287
|
-
"Work delivered to you, newest first.",
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
const table = screen.getByTestId("artifacts-table");
|
|
291
|
-
expect(
|
|
292
|
-
within(table).getAllByRole("columnheader").map((h) => h.textContent),
|
|
293
|
-
).toEqual(["Title", "Type", "Version", "Status"]);
|
|
294
|
-
const titles = within(table).getAllByTestId(/-title$/);
|
|
295
|
-
expect(titles.map((t) => t.textContent)).toEqual([
|
|
296
|
-
"Zebra logo",
|
|
297
|
-
"Mango brief",
|
|
298
|
-
"Alpha deck",
|
|
299
|
-
]);
|
|
300
|
-
expect(titles.map((t) => t.getAttribute("href"))).toEqual([
|
|
301
|
-
`/account/artifacts/${ID.zebra}`,
|
|
302
|
-
`/account/artifacts/${ID.mango}`,
|
|
303
|
-
`/account/artifacts/${ID.alpha}`,
|
|
304
|
-
]);
|
|
305
|
-
|
|
306
|
-
// Zebra: a PNG, version 3, delivered + approved.
|
|
307
|
-
const zebraRow = screen.getByTestId(`artifacts-table-row-${ID.zebra}`);
|
|
308
|
-
const zebraCells = within(zebraRow).getAllByRole("cell");
|
|
309
|
-
expect(zebraCells[1]).toHaveTextContent(/^PNG image$/);
|
|
310
|
-
expect(zebraCells[2]).toHaveTextContent(/^Version 3$/);
|
|
311
|
-
const zebraStatus = screen.getByTestId(`artifacts-table-row-${ID.zebra}-status`);
|
|
312
|
-
expect(within(zebraStatus).getByText("Delivered")).toBeInTheDocument();
|
|
313
|
-
expect(within(zebraStatus).getByText("Approved")).toBeInTheDocument();
|
|
314
|
-
// Never the delivery date as a column, never one combined state.
|
|
315
|
-
expect(zebraRow).not.toHaveTextContent(medium("2026-10-03T12:00:00.000Z"));
|
|
316
|
-
|
|
317
|
-
// Mango: a PDF, version 2 (never its older version), in progress + changes requested.
|
|
318
|
-
const mangoRow = screen.getByTestId(`artifacts-table-row-${ID.mango}`);
|
|
319
|
-
const mangoCells = within(mangoRow).getAllByRole("cell");
|
|
320
|
-
expect(mangoCells[1]).toHaveTextContent(/^PDF$/);
|
|
321
|
-
expect(mangoCells[2]).toHaveTextContent(/^Version 2$/);
|
|
322
|
-
const mangoStatus = screen.getByTestId(`artifacts-table-row-${ID.mango}-status`);
|
|
323
|
-
expect(within(mangoStatus).getByText("In progress")).toBeInTheDocument();
|
|
324
|
-
expect(within(mangoStatus).getByText("Changes requested")).toBeInTheDocument();
|
|
325
|
-
|
|
326
|
-
// Alpha: a link, version 1, in review, unreviewed — the stage alone, no review tag.
|
|
327
|
-
const alphaRow = screen.getByTestId(`artifacts-table-row-${ID.alpha}`);
|
|
328
|
-
expect(within(alphaRow).getAllByRole("cell")[1]).toHaveTextContent(/^Link$/);
|
|
329
|
-
const alphaStatus = screen.getByTestId(`artifacts-table-row-${ID.alpha}-status`);
|
|
330
|
-
expect(alphaStatus).toHaveTextContent(/^In review$/);
|
|
331
|
-
expect(screen.queryByText("Ready for review")).toBeNull();
|
|
332
|
-
|
|
333
|
-
const captions = screen.getAllByTestId("artifacts-row");
|
|
334
|
-
// The phone rows render the same read, so their captions exist in the DOM
|
|
335
|
-
// even though only the table is visible at this (desktop) width.
|
|
336
|
-
expect(captions.map((c) => c.textContent)).toEqual([
|
|
337
|
-
expect.stringContaining("Version 3 · Delivered · Approved"),
|
|
338
|
-
expect.stringContaining("Version 2 · In progress · Changes requested"),
|
|
339
|
-
expect.stringContaining("Version 1 · In review"),
|
|
340
|
-
]);
|
|
341
|
-
|
|
342
|
-
// "All Artifacts" first (Title Case), then the declared stages in order
|
|
343
|
-
// under the Status group, each counted over every artifact, zeros kept.
|
|
344
|
-
const items = facetItems();
|
|
345
|
-
expect(items.map((i) => i.getAttribute("data-testid"))).toEqual([
|
|
346
|
-
"artifacts-facets-item-all",
|
|
347
|
-
"artifacts-facets-item-requested",
|
|
348
|
-
"artifacts-facets-item-in-progress",
|
|
349
|
-
"artifacts-facets-item-in-review",
|
|
350
|
-
"artifacts-facets-item-delivered",
|
|
351
|
-
]);
|
|
352
|
-
expect(items[0]).toHaveTextContent("All Artifacts");
|
|
353
|
-
expect(items[0]).toHaveTextContent("3");
|
|
354
|
-
expect(items[1]).toHaveTextContent("Requested");
|
|
355
|
-
expect(items[1]).toHaveTextContent("0");
|
|
356
|
-
expect(items[2]).toHaveTextContent("In progress");
|
|
357
|
-
expect(items[2]).toHaveTextContent("1");
|
|
358
|
-
expect(items[3]).toHaveTextContent("In review");
|
|
359
|
-
expect(items[3]).toHaveTextContent("1");
|
|
360
|
-
expect(items[4]).toHaveTextContent("Delivered");
|
|
361
|
-
expect(items[4]).toHaveTextContent("1");
|
|
362
|
-
expect(screen.getByTestId("artifacts-facets")).toHaveTextContent("Status");
|
|
363
|
-
expect(screen.getByTestId("artifacts-facets")).not.toHaveTextContent("Review");
|
|
364
|
-
expect(screen.queryByTestId("inbox-error")).toBeNull();
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it("a workspace's own stage list drives the facets: every declared slug, in its order, read by its served label — never the slug", async () => {
|
|
368
|
-
mockArtifacts.mockResolvedValue(
|
|
369
|
-
ok(
|
|
370
|
-
[
|
|
371
|
-
{ ...ALPHA, stage: "final-qa", stageLabel: "Final check" },
|
|
372
|
-
{ ...MANGO, stage: "scoping", stageLabel: "Scoping" },
|
|
373
|
-
],
|
|
374
|
-
["scoping", "drafting", "final-qa", "done"],
|
|
375
|
-
["Scoping", "Drafting", "Final check", "Done"],
|
|
376
|
-
),
|
|
377
|
-
);
|
|
378
|
-
await renderList();
|
|
379
|
-
const items = facetItems();
|
|
380
|
-
expect(items.map((i) => i.getAttribute("data-testid"))).toEqual([
|
|
381
|
-
"artifacts-facets-item-all",
|
|
382
|
-
"artifacts-facets-item-scoping",
|
|
383
|
-
"artifacts-facets-item-drafting",
|
|
384
|
-
"artifacts-facets-item-final-qa",
|
|
385
|
-
"artifacts-facets-item-done",
|
|
386
|
-
]);
|
|
387
|
-
expect(items[1]).toHaveTextContent("Scoping");
|
|
388
|
-
expect(items[2]).toHaveTextContent("Drafting");
|
|
389
|
-
expect(items[2]).toHaveTextContent("0");
|
|
390
|
-
expect(items[3]).toHaveTextContent("Final check");
|
|
391
|
-
expect(items[4]).toHaveTextContent("Done");
|
|
392
|
-
expect(screen.getByTestId("artifacts-facets")).not.toHaveTextContent("final-qa");
|
|
393
|
-
expect(screen.getByTestId(`artifacts-table-row-${ID.alpha}-status`)).toHaveTextContent(
|
|
394
|
-
/^Final check$/,
|
|
395
|
-
);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it("a hub older than the labels serves slugs alone: each reads as its default label (the four defaults' own, others title-cased)", async () => {
|
|
399
|
-
mockArtifacts.mockResolvedValue({
|
|
400
|
-
ok: true,
|
|
401
|
-
body: {
|
|
402
|
-
items: [{ ...ALPHA, stageLabel: undefined, stage: "final-qa" }],
|
|
403
|
-
stages: ["requested", "final-qa"],
|
|
404
|
-
},
|
|
405
|
-
});
|
|
406
|
-
await renderList();
|
|
407
|
-
const items = facetItems();
|
|
408
|
-
expect(items[1]).toHaveTextContent("Requested");
|
|
409
|
-
expect(items[2]).toHaveTextContent("Final Qa");
|
|
410
|
-
expect(screen.getByTestId(`artifacts-table-row-${ID.alpha}-status`)).toHaveTextContent(
|
|
411
|
-
/^Final Qa$/,
|
|
412
|
-
);
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
it("an older hub that serves no stages at all falls back to the four default facets", async () => {
|
|
416
|
-
mockArtifacts.mockResolvedValue({ ok: true, body: { items: [ALPHA] } });
|
|
417
|
-
await renderList();
|
|
418
|
-
expect(facetItems().map((i) => i.getAttribute("data-testid"))).toEqual([
|
|
419
|
-
"artifacts-facets-item-all",
|
|
420
|
-
"artifacts-facets-item-requested",
|
|
421
|
-
"artifacts-facets-item-in-progress",
|
|
422
|
-
"artifacts-facets-item-in-review",
|
|
423
|
-
"artifacts-facets-item-delivered",
|
|
424
|
-
]);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
it("a 404 read shows the empty line and a nav at 0, not an error row", async () => {
|
|
428
|
-
mockArtifacts.mockResolvedValue(refused(404, "not_found"));
|
|
429
|
-
await renderList();
|
|
430
|
-
expect(screen.getByTestId("artifacts-empty")).toHaveTextContent(
|
|
431
|
-
"Nothing has been delivered to you yet.",
|
|
432
|
-
);
|
|
433
|
-
expect(facetItems()).toHaveLength(5);
|
|
434
|
-
for (const item of facetItems()) expect(item).toHaveTextContent("0");
|
|
435
|
-
expect(screen.queryByTestId("inbox-error")).toBeNull();
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
it("a 403 while the email is unverified shows the empty line too", async () => {
|
|
439
|
-
mockGetSession.mockResolvedValue({
|
|
440
|
-
user: { ...VERIFIED.user, emailVerified: false },
|
|
441
|
-
});
|
|
442
|
-
mockArtifacts.mockResolvedValue(refused(403, "forbidden"));
|
|
443
|
-
await renderList();
|
|
444
|
-
expect(screen.getByTestId("artifacts-empty")).toBeInTheDocument();
|
|
445
|
-
expect(screen.queryByTestId("inbox-error")).toBeNull();
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
it.each([
|
|
449
|
-
["a 500", refused(500)],
|
|
450
|
-
["a status-0 refusal", refused(0, "insecure_transport")],
|
|
451
|
-
])("%s shows the error row with Retry and no frame", async (_case, res) => {
|
|
452
|
-
mockArtifacts.mockResolvedValue(res);
|
|
453
|
-
await renderList();
|
|
454
|
-
expect(screen.getByTestId("inbox-error")).toHaveTextContent(
|
|
455
|
-
"We couldn't load your artifacts.",
|
|
456
|
-
);
|
|
457
|
-
expect(screen.queryByTestId("artifacts-facets")).toBeNull();
|
|
458
|
-
expect(screen.queryByTestId("artifacts-table")).toBeNull();
|
|
459
|
-
expect(screen.queryByTestId("artifacts-empty")).toBeNull();
|
|
460
|
-
fireEvent.click(screen.getByTestId("inbox-retry"));
|
|
461
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
// The (authed) layout renders the sign-in gate for a missing session and
|
|
465
|
-
// the page renders in parallel with it, so a `notFound()` here streamed a
|
|
466
|
-
// 404 digest over the gate (the scaffold render sweep's
|
|
467
|
-
// `/account/artifacts -> streamed not-found`). Like `/account/general`, the
|
|
468
|
-
// page now renders its heading alone and reads nothing.
|
|
469
|
-
it("no session renders the heading alone and loads nothing", async () => {
|
|
470
|
-
mockGetSession.mockResolvedValue(null);
|
|
471
|
-
await renderList();
|
|
472
|
-
expect(screen.getByTestId("artifacts")).toBeInTheDocument();
|
|
473
|
-
expect(screen.queryByTestId("artifacts-empty")).toBeNull();
|
|
474
|
-
expect(screen.queryByTestId("inbox-error")).toBeNull();
|
|
475
|
-
expect(mockArtifacts).not.toHaveBeenCalled();
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
const VERSIONED = {
|
|
480
|
-
id: ID.alpha,
|
|
481
|
-
title: "Alpha deck",
|
|
482
|
-
approvedAt: null,
|
|
483
|
-
stage: "in-review",
|
|
484
|
-
stageLabel: "In review",
|
|
485
|
-
versions: [
|
|
486
|
-
version({
|
|
487
|
-
version: 3,
|
|
488
|
-
file: {
|
|
489
|
-
filename: "brief-v3.pdf",
|
|
490
|
-
contentType: "application/pdf",
|
|
491
|
-
byteSize: 2048,
|
|
492
|
-
},
|
|
493
|
-
note: "Final colours\nand the new mark",
|
|
494
|
-
deliveredAt: "2026-09-12T10:00:00.000Z",
|
|
495
|
-
}),
|
|
496
|
-
version({
|
|
497
|
-
version: 2,
|
|
498
|
-
link: "https://files.example.com/v2",
|
|
499
|
-
note: "Second pass",
|
|
500
|
-
deliveredAt: "2026-09-08T10:00:00.000Z",
|
|
501
|
-
review: "changes-requested",
|
|
502
|
-
reviewComment: "Bigger logo",
|
|
503
|
-
}),
|
|
504
|
-
version({
|
|
505
|
-
version: 1,
|
|
506
|
-
link: "http://insecure.example.com/v1",
|
|
507
|
-
note: "First draft",
|
|
508
|
-
deliveredAt: "2026-09-01T10:00:00.000Z",
|
|
509
|
-
review: "changes-requested",
|
|
510
|
-
reviewComment: "Warmer",
|
|
511
|
-
}),
|
|
512
|
-
],
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
describe("/account/artifacts/[pieceId] (D4, AC-2)", () => {
|
|
516
|
-
beforeEach(() => {
|
|
517
|
-
mockArtifacts.mockResolvedValue(ok([VERSIONED]));
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
it("lists the versions newest first, each with its number, delivery date and note — and no deliverer", async () => {
|
|
521
|
-
await renderArtifact(ID.alpha);
|
|
522
|
-
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
|
|
523
|
-
"Alpha deck",
|
|
524
|
-
);
|
|
525
|
-
expect(screen.getByTestId("artifact-back")).toHaveAttribute(
|
|
526
|
-
"href",
|
|
527
|
-
"/account/artifacts",
|
|
528
|
-
);
|
|
529
|
-
const blocks = screen.getAllByTestId(/^artifact-version-\d+$/);
|
|
530
|
-
expect(blocks.map((b) => b.getAttribute("data-testid"))).toEqual([
|
|
531
|
-
"artifact-version-3",
|
|
532
|
-
"artifact-version-2",
|
|
533
|
-
"artifact-version-1",
|
|
534
|
-
]);
|
|
535
|
-
for (const v of VERSIONED.versions) {
|
|
536
|
-
const block = screen.getByTestId(`artifact-version-${v.version}`);
|
|
537
|
-
expect(block).toHaveTextContent(`Version ${v.version}`);
|
|
538
|
-
expect(block).toHaveTextContent(`Delivered ${medium(v.deliveredAt)}`);
|
|
539
|
-
// #11175: the day is a <time> carrying the instant, read in the viewer's zone.
|
|
540
|
-
expect(within(block).getByText(medium(v.deliveredAt))).toHaveAttribute("dateTime", v.deliveredAt);
|
|
541
|
-
expect(block).toHaveTextContent(v.note!.replace("\n", " "));
|
|
542
|
-
}
|
|
543
|
-
expect(
|
|
544
|
-
within(screen.getByTestId("artifact-version-2")).getByText("Bigger logo"),
|
|
545
|
-
).toBeInTheDocument();
|
|
546
|
-
expect(screen.getByTestId("artifact").textContent).not.toMatch(
|
|
547
|
-
/delivered by/i,
|
|
548
|
-
);
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
it("a file version downloads through this site's route; an https link is View in a new tab; a non-https link has no action", async () => {
|
|
552
|
-
await renderArtifact(ID.alpha);
|
|
553
|
-
const download = screen.getByTestId("artifact-version-3-download");
|
|
554
|
-
expect(download).toHaveAttribute(
|
|
555
|
-
"href",
|
|
556
|
-
`/account/artifacts/${ID.alpha}/versions/3/file`,
|
|
557
|
-
);
|
|
558
|
-
expect(download).toHaveTextContent("Download brief-v3.pdf");
|
|
559
|
-
expect(screen.queryByTestId("artifact-version-3-view")).toBeNull();
|
|
560
|
-
// The status is the stage; the unreviewed latest version adds no tag.
|
|
561
|
-
expect(screen.getByTestId("artifact-status")).toHaveTextContent("In review");
|
|
562
|
-
expect(screen.queryByTestId("artifact-tag-0")).toBeNull();
|
|
563
|
-
// Version 2's review is a tag on the version, beside its dated line.
|
|
564
|
-
expect(screen.getByTestId("artifact-version-2-review")).toHaveTextContent(
|
|
565
|
-
"Changes requested",
|
|
566
|
-
);
|
|
567
|
-
expect(screen.queryByTestId("artifact-version-3-review")).toBeNull();
|
|
568
|
-
|
|
569
|
-
const view = screen.getByTestId("artifact-version-2-view");
|
|
570
|
-
expect(view).toHaveAttribute("href", "https://files.example.com/v2");
|
|
571
|
-
expect(view).toHaveAttribute("target", "_blank");
|
|
572
|
-
expect(view).toHaveAttribute("rel", "noopener noreferrer");
|
|
573
|
-
expect(view).toHaveTextContent("View");
|
|
574
|
-
|
|
575
|
-
const v1 = screen.getByTestId("artifact-version-1");
|
|
576
|
-
expect(within(v1).queryByRole("link")).toBeNull();
|
|
577
|
-
expect(screen.queryByTestId("artifact-version-1-view")).toBeNull();
|
|
578
|
-
expect(screen.queryByTestId("artifact-version-1-download")).toBeNull();
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
it("a PDF version renders inline through the route's preview mode, with Download beside it (AC-4)", async () => {
|
|
582
|
-
await renderArtifact(ID.alpha);
|
|
583
|
-
const v3 = screen.getByTestId("artifact-version-3");
|
|
584
|
-
const preview = within(v3).getByTestId("artifact-version-3-preview-pdf");
|
|
585
|
-
expect(preview.querySelector('[data-testid="document-viewer"]')).toBeInTheDocument();
|
|
586
|
-
expect(within(v3).getByTestId("artifact-version-3-download")).toBeInTheDocument();
|
|
587
|
-
// Download is the page's own, not the reader's toolbar.
|
|
588
|
-
expect(screen.queryByTestId("document-viewer-download")).toBeNull();
|
|
589
|
-
expect(screen.queryByTestId("artifact-version-3-preview-image")).toBeNull();
|
|
590
|
-
// Link versions have no preview.
|
|
591
|
-
expect(screen.queryByTestId("artifact-version-2-preview-pdf")).toBeNull();
|
|
592
|
-
await act(async () => {
|
|
593
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
594
|
-
});
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
it("an image version renders inline as the image, served through the preview mode, with Download beside it (AC-4)", async () => {
|
|
598
|
-
mockArtifacts.mockResolvedValue(
|
|
599
|
-
ok([
|
|
600
|
-
{
|
|
601
|
-
...VERSIONED,
|
|
602
|
-
versions: [
|
|
603
|
-
version({
|
|
604
|
-
version: 1,
|
|
605
|
-
file: { filename: "mark.png", contentType: "image/png", byteSize: 2048 },
|
|
606
|
-
deliveredAt: "2026-09-12T10:00:00.000Z",
|
|
607
|
-
}),
|
|
608
|
-
],
|
|
609
|
-
},
|
|
610
|
-
]),
|
|
611
|
-
);
|
|
612
|
-
await renderArtifact(ID.alpha);
|
|
613
|
-
const v1 = screen.getByTestId("artifact-version-1");
|
|
614
|
-
const target = within(v1).getByTestId("artifact-version-1-preview-image");
|
|
615
|
-
expect(target).toHaveAttribute("aria-label", "Open mark.png full size");
|
|
616
|
-
expect(target.querySelector("img")).toHaveAttribute(
|
|
617
|
-
"src",
|
|
618
|
-
`/account/artifacts/${ID.alpha}/versions/1/file?inline=1`,
|
|
619
|
-
);
|
|
620
|
-
expect(within(v1).getByTestId("artifact-version-1-download")).toHaveAttribute(
|
|
621
|
-
"href",
|
|
622
|
-
`/account/artifacts/${ID.alpha}/versions/1/file`,
|
|
623
|
-
);
|
|
624
|
-
expect(screen.queryByTestId("artifact-version-1-preview-pdf")).toBeNull();
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
it("any other file type keeps Download alone — no preview", async () => {
|
|
628
|
-
mockArtifacts.mockResolvedValue(
|
|
629
|
-
ok([
|
|
630
|
-
{
|
|
631
|
-
...VERSIONED,
|
|
632
|
-
versions: [
|
|
633
|
-
version({
|
|
634
|
-
version: 1,
|
|
635
|
-
file: { filename: "deck.zip", contentType: "application/zip", byteSize: 2048 },
|
|
636
|
-
deliveredAt: "2026-09-12T10:00:00.000Z",
|
|
637
|
-
}),
|
|
638
|
-
],
|
|
639
|
-
},
|
|
640
|
-
]),
|
|
641
|
-
);
|
|
642
|
-
await renderArtifact(ID.alpha);
|
|
643
|
-
expect(screen.getByTestId("artifact-version-1-download")).toBeInTheDocument();
|
|
644
|
-
expect(screen.queryByTestId("artifact-version-1-preview-image")).toBeNull();
|
|
645
|
-
expect(screen.queryByTestId("artifact-version-1-preview-pdf")).toBeNull();
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
it("an encoded id segment still finds the artifact", async () => {
|
|
649
|
-
await renderArtifact(encodeURIComponent(ID.alpha));
|
|
650
|
-
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
|
|
651
|
-
"Alpha deck",
|
|
652
|
-
);
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
it("an id the read did not return is a not-found", async () => {
|
|
656
|
-
await expect(renderArtifact(ID.zebra)).rejects.toThrow("NEXT_NOT_FOUND");
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
it("a 404 read is a not-found", async () => {
|
|
660
|
-
mockArtifacts.mockResolvedValue(refused(404, "not_found"));
|
|
661
|
-
await expect(renderArtifact(ID.alpha)).rejects.toThrow("NEXT_NOT_FOUND");
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
it("a 500 read renders the error row with Retry, not a not-found", async () => {
|
|
665
|
-
mockArtifacts.mockResolvedValue(refused(500));
|
|
666
|
-
await renderArtifact(ID.alpha);
|
|
667
|
-
expect(mockNotFound).not.toHaveBeenCalled();
|
|
668
|
-
expect(screen.getByTestId("inbox-error")).toHaveTextContent(
|
|
669
|
-
"We couldn't load this artifact.",
|
|
670
|
-
);
|
|
671
|
-
expect(screen.getByTestId("inbox-retry")).toHaveTextContent("Retry");
|
|
672
|
-
});
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
describe("the review form's place (D4, C3, AC-4)", () => {
|
|
676
|
-
const FORM_IDS = [
|
|
677
|
-
"artifact-review-approve",
|
|
678
|
-
"artifact-review-request-changes",
|
|
679
|
-
"artifact-review-comment",
|
|
680
|
-
];
|
|
681
|
-
|
|
682
|
-
it("shows once, inside the latest version, while the artifact is not approved and that version is unreviewed", async () => {
|
|
683
|
-
mockArtifacts.mockResolvedValue(ok([VERSIONED]));
|
|
684
|
-
await renderArtifact(ID.alpha);
|
|
685
|
-
for (const id of FORM_IDS) {
|
|
686
|
-
expect(screen.getAllByTestId(id)).toHaveLength(1);
|
|
687
|
-
expect(
|
|
688
|
-
within(screen.getByTestId("artifact-version-3")).getByTestId(id),
|
|
689
|
-
).toBeInTheDocument();
|
|
690
|
-
}
|
|
691
|
-
expect(screen.getByTestId("artifact-status")).toHaveTextContent("In review");
|
|
692
|
-
expect(screen.queryByTestId("artifact-tag-0")).toBeNull();
|
|
693
|
-
expect(screen.queryByTestId("artifact-review-waiting")).toBeNull();
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
it("is absent everywhere once the artifact is approved, which shows the stage, an Approved tag and the date", async () => {
|
|
697
|
-
const approvedAt = "2026-09-30T08:00:00.000Z";
|
|
698
|
-
mockArtifacts.mockResolvedValue(
|
|
699
|
-
ok([{ ...VERSIONED, approvedAt, stage: "delivered", stageLabel: "Done" }]),
|
|
700
|
-
);
|
|
701
|
-
await renderArtifact(ID.alpha);
|
|
702
|
-
for (const id of FORM_IDS) expect(screen.queryByTestId(id)).toBeNull();
|
|
703
|
-
// The status reads the provider's label for the terminal stage — here renamed Done.
|
|
704
|
-
expect(screen.getByTestId("artifact-status")).toHaveTextContent("Done");
|
|
705
|
-
expect(screen.getByTestId("artifact-tag-0")).toHaveTextContent("Approved");
|
|
706
|
-
expect(screen.getByTestId("artifact")).toHaveTextContent(
|
|
707
|
-
`Approved ${medium(approvedAt)}`,
|
|
708
|
-
);
|
|
709
|
-
expect(screen.queryByTestId("artifact-review-waiting")).toBeNull();
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
it("reads every dated line in the viewer's zone once the browser has one (#11175)", async () => {
|
|
713
|
-
viewerZone(MOUNTAIN);
|
|
714
|
-
// 03:30Z is still the evening before in Mountain time, so each day rolls back.
|
|
715
|
-
const approvedAt = "2026-09-30T03:30:00.000Z";
|
|
716
|
-
const [latest, ...rest] = VERSIONED.versions;
|
|
717
|
-
mockArtifacts.mockResolvedValue(
|
|
718
|
-
ok([
|
|
719
|
-
{
|
|
720
|
-
...VERSIONED,
|
|
721
|
-
approvedAt,
|
|
722
|
-
stage: "delivered",
|
|
723
|
-
stageLabel: "Delivered",
|
|
724
|
-
versions: [
|
|
725
|
-
{ ...latest!, deliveredAt: "2026-09-13T03:30:00.000Z", review: "approved", reviewedAt: approvedAt },
|
|
726
|
-
...rest,
|
|
727
|
-
],
|
|
728
|
-
},
|
|
729
|
-
]),
|
|
730
|
-
);
|
|
731
|
-
await renderArtifact(ID.alpha);
|
|
732
|
-
expect(medium(approvedAt, MOUNTAIN)).toBe("Sep 29, 2026");
|
|
733
|
-
expect(screen.getByTestId("artifact")).toHaveTextContent(`Approved ${medium(approvedAt, MOUNTAIN)}`);
|
|
734
|
-
const v3 = screen.getByTestId("artifact-version-3");
|
|
735
|
-
expect(v3).toHaveTextContent(`Delivered ${medium("2026-09-13T03:30:00.000Z", MOUNTAIN)}`);
|
|
736
|
-
expect(v3).toHaveTextContent(`You approved this version on ${medium(approvedAt, MOUNTAIN)}.`);
|
|
737
|
-
const day = within(v3).getByText(medium("2026-09-13T03:30:00.000Z", MOUNTAIN));
|
|
738
|
-
expect(day.tagName).toBe("TIME");
|
|
739
|
-
expect(day).toHaveAttribute("title", "MDT");
|
|
740
|
-
});
|
|
741
|
-
|
|
742
|
-
it("is absent on a latest version the member already asked changes on, which says the next version will appear here", async () => {
|
|
743
|
-
const [latest, ...rest] = VERSIONED.versions;
|
|
744
|
-
const reviewed = {
|
|
745
|
-
...VERSIONED,
|
|
746
|
-
versions: [
|
|
747
|
-
{
|
|
748
|
-
...latest!,
|
|
749
|
-
review: "changes-requested",
|
|
750
|
-
reviewComment: "Tighten the logo",
|
|
751
|
-
reviewedAt: "2026-09-13T10:00:00.000Z",
|
|
752
|
-
},
|
|
753
|
-
...rest,
|
|
754
|
-
],
|
|
755
|
-
};
|
|
756
|
-
mockArtifacts.mockResolvedValue(ok([reviewed]));
|
|
757
|
-
await renderArtifact(ID.alpha);
|
|
758
|
-
for (const id of FORM_IDS) expect(screen.queryByTestId(id)).toBeNull();
|
|
759
|
-
const v3 = screen.getByTestId("artifact-version-3");
|
|
760
|
-
expect(within(v3).getByTestId("artifact-review-waiting")).toHaveTextContent(
|
|
761
|
-
"You requested changes. The next version will appear here.",
|
|
762
|
-
);
|
|
763
|
-
expect(v3).toHaveTextContent(
|
|
764
|
-
`You requested changes on ${medium("2026-09-13T10:00:00.000Z")}.`,
|
|
765
|
-
);
|
|
766
|
-
expect(within(v3).getByText("Tighten the logo")).toBeInTheDocument();
|
|
767
|
-
expect(within(v3).getByTestId("artifact-version-3-review")).toHaveTextContent(
|
|
768
|
-
"Changes requested",
|
|
769
|
-
);
|
|
770
|
-
expect(screen.getByTestId("artifact-status")).toHaveTextContent("In review");
|
|
771
|
-
expect(screen.getByTestId("artifact-tag-0")).toHaveTextContent("Changes requested");
|
|
772
|
-
});
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
// #8516 D19 — a priced proposal, unreviewed, as apps/api serves it.
|
|
776
|
-
const PROPOSAL_ID = "piece_01920000-0000-7000-8000-00000000000d";
|
|
777
|
-
const PROPOSAL = {
|
|
778
|
-
id: PROPOSAL_ID,
|
|
779
|
-
title: "Site redesign",
|
|
780
|
-
approvedAt: null,
|
|
781
|
-
stage: "in-review",
|
|
782
|
-
stageLabel: "In review",
|
|
783
|
-
kind: "proposal",
|
|
784
|
-
price: { amount: 120000, currency: "usd" },
|
|
785
|
-
payment: null,
|
|
786
|
-
versions: [version({ version: 1, deliveredAt: "2026-10-01T12:00:00.000Z" })],
|
|
787
|
-
};
|
|
788
|
-
const APPROVED_AT = "2026-10-05T09:00:00.000Z";
|
|
789
|
-
const PAID_AT = "2026-10-06T09:30:00.000Z";
|
|
790
|
-
|
|
791
|
-
function approvedProposal(payment: unknown) {
|
|
792
|
-
const [latest] = PROPOSAL.versions;
|
|
793
|
-
return {
|
|
794
|
-
...PROPOSAL,
|
|
795
|
-
approvedAt: APPROVED_AT,
|
|
796
|
-
payment,
|
|
797
|
-
versions: [{ ...latest!, review: "approved", reviewedAt: APPROVED_AT }],
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
// An older hub serves no `kind`, `price` or `payment` (#8516 D4: optional).
|
|
802
|
-
const ALPHA_WITHOUT_KIND = {
|
|
803
|
-
id: ID.mango,
|
|
804
|
-
title: "Mango brief",
|
|
805
|
-
approvedAt: null,
|
|
806
|
-
versions: [version({ version: 1 })],
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
const PAY_IDS = ["artifact-pay-form", "artifact-pay", "artifact-paid-pending"];
|
|
810
|
-
|
|
811
|
-
describe("a proposal (#8516 D19, AC-3, AC-4)", () => {
|
|
812
|
-
it("renders Proposal, its price, the decision heading and Approve proposal / Request changes", async () => {
|
|
813
|
-
mockArtifacts.mockResolvedValue(ok([PROPOSAL]));
|
|
814
|
-
await renderArtifact(PROPOSAL_ID);
|
|
815
|
-
const page = screen.getByTestId("artifact");
|
|
816
|
-
expect(within(page).getByText("Proposal")).toBeInTheDocument();
|
|
817
|
-
expect(within(page).queryByText("Artifact")).toBeNull();
|
|
818
|
-
expect(screen.getByTestId("artifact-price")).toHaveTextContent(
|
|
819
|
-
"Price $1,200.00",
|
|
820
|
-
);
|
|
821
|
-
const v1 = screen.getByTestId("artifact-version-1");
|
|
822
|
-
expect(within(v1).getByRole("heading", { level: 3 })).toHaveTextContent(
|
|
823
|
-
"Your decision on version 1",
|
|
824
|
-
);
|
|
825
|
-
expect(within(v1).getByTestId("artifact-review-approve")).toHaveTextContent(
|
|
826
|
-
"Approve proposal",
|
|
827
|
-
);
|
|
828
|
-
expect(
|
|
829
|
-
within(v1).getByTestId("artifact-review-request-changes"),
|
|
830
|
-
).toHaveTextContent("Request changes");
|
|
831
|
-
for (const id of PAY_IDS) expect(screen.queryByTestId(id)).toBeNull();
|
|
832
|
-
expect(screen.queryByTestId("artifact-paid")).toBeNull();
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
it("a currency Intl cannot format falls back to the amount and code instead of erroring the page", async () => {
|
|
836
|
-
mockArtifacts.mockResolvedValue(
|
|
837
|
-
ok([{ ...PROPOSAL, price: { amount: 120000, currency: "u$" } }]),
|
|
838
|
-
);
|
|
839
|
-
await renderArtifact(PROPOSAL_ID);
|
|
840
|
-
expect(screen.getByTestId("artifact-price")).toHaveTextContent("Price 1200 U$");
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
it("a deliverable still renders Artifact, no price and Approve", async () => {
|
|
844
|
-
mockArtifacts.mockResolvedValue(
|
|
845
|
-
ok([{ ...VERSIONED, kind: "deliverable", price: null, payment: null }]),
|
|
846
|
-
);
|
|
847
|
-
await renderArtifact(ID.alpha);
|
|
848
|
-
const page = screen.getByTestId("artifact");
|
|
849
|
-
expect(within(page).getByText("Artifact")).toBeInTheDocument();
|
|
850
|
-
expect(within(page).queryByText("Proposal")).toBeNull();
|
|
851
|
-
expect(screen.queryByTestId("artifact-price")).toBeNull();
|
|
852
|
-
expect(page.textContent).not.toMatch(/Price/);
|
|
853
|
-
const v3 = screen.getByTestId("artifact-version-3");
|
|
854
|
-
expect(within(v3).getByRole("heading", { level: 3 })).toHaveTextContent(
|
|
855
|
-
"Review version 3",
|
|
856
|
-
);
|
|
857
|
-
expect(within(v3).getByTestId("artifact-review-approve")).toHaveTextContent(
|
|
858
|
-
/^Approve$/,
|
|
859
|
-
);
|
|
860
|
-
for (const id of PAY_IDS) expect(screen.queryByTestId(id)).toBeNull();
|
|
861
|
-
});
|
|
862
|
-
|
|
863
|
-
it("an older hub's artifact with no kind renders as a deliverable", async () => {
|
|
864
|
-
mockArtifacts.mockResolvedValue(ok([ALPHA_WITHOUT_KIND]));
|
|
865
|
-
await renderArtifact(ID.mango);
|
|
866
|
-
expect(
|
|
867
|
-
within(screen.getByTestId("artifact")).getByText("Artifact"),
|
|
868
|
-
).toBeInTheDocument();
|
|
869
|
-
expect(screen.queryByTestId("artifact-price")).toBeNull();
|
|
870
|
-
expect(screen.getByTestId("artifact-review-approve")).toHaveTextContent(
|
|
871
|
-
/^Approve$/,
|
|
872
|
-
);
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
it("while payment is due, Pay now sits in the latest version's place and the review form is gone", async () => {
|
|
876
|
-
mockArtifacts.mockResolvedValue(ok([approvedProposal({ status: "due" })]));
|
|
877
|
-
await renderArtifact(PROPOSAL_ID);
|
|
878
|
-
const v1 = screen.getByTestId("artifact-version-1");
|
|
879
|
-
expect(within(v1).getByTestId("artifact-pay")).toHaveTextContent("Pay now");
|
|
880
|
-
expect(screen.getAllByTestId("artifact-pay")).toHaveLength(1);
|
|
881
|
-
expect(screen.queryByTestId("artifact-review-approve")).toBeNull();
|
|
882
|
-
expect(screen.queryByTestId("artifact-paid")).toBeNull();
|
|
883
|
-
expect(screen.queryByTestId("artifact-paid-pending")).toBeNull();
|
|
884
|
-
expect(screen.getByTestId("artifact-tag-0")).toHaveTextContent("Approved");
|
|
885
|
-
});
|
|
886
|
-
|
|
887
|
-
it("once paid, the latest version says Paid <date> and offers no Pay now", async () => {
|
|
888
|
-
mockArtifacts.mockResolvedValue(
|
|
889
|
-
ok([approvedProposal({ status: "paid", paidAt: PAID_AT })]),
|
|
890
|
-
);
|
|
891
|
-
await renderArtifact(PROPOSAL_ID, { paid: "1" });
|
|
892
|
-
const v1 = screen.getByTestId("artifact-version-1");
|
|
893
|
-
expect(within(v1).getByTestId("artifact-paid")).toHaveTextContent(
|
|
894
|
-
`Paid ${medium(PAID_AT)}`,
|
|
895
|
-
);
|
|
896
|
-
expect(within(v1).getByText(medium(PAID_AT))).toHaveAttribute("dateTime", PAID_AT);
|
|
897
|
-
for (const id of PAY_IDS) expect(screen.queryByTestId(id)).toBeNull();
|
|
898
|
-
});
|
|
899
|
-
|
|
900
|
-
it("back from Stripe (?paid=1) before the webhook lands, it says the payment was received instead of Pay now", async () => {
|
|
901
|
-
mockArtifacts.mockResolvedValue(ok([approvedProposal({ status: "due" })]));
|
|
902
|
-
await renderArtifact(PROPOSAL_ID, { paid: "1" });
|
|
903
|
-
const v1 = screen.getByTestId("artifact-version-1");
|
|
904
|
-
expect(within(v1).getByTestId("artifact-paid-pending")).toHaveTextContent(
|
|
905
|
-
"Payment received — it may take a minute to show here.",
|
|
906
|
-
);
|
|
907
|
-
expect(screen.queryByTestId("artifact-pay")).toBeNull();
|
|
908
|
-
expect(screen.queryByTestId("artifact-paid")).toBeNull();
|
|
909
|
-
});
|
|
910
|
-
|
|
911
|
-
it("an approved proposal with no payment surface (payment null) shows neither Pay now nor Paid", async () => {
|
|
912
|
-
mockArtifacts.mockResolvedValue(ok([approvedProposal(null)]));
|
|
913
|
-
await renderArtifact(PROPOSAL_ID, { paid: "1" });
|
|
914
|
-
for (const id of PAY_IDS) expect(screen.queryByTestId(id)).toBeNull();
|
|
915
|
-
expect(screen.queryByTestId("artifact-paid")).toBeNull();
|
|
916
|
-
expect(screen.getByTestId("artifact-price")).toHaveTextContent(
|
|
917
|
-
"Price $1,200.00",
|
|
918
|
-
);
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
it("the list reads Proposal · Version <n> in a proposal's caption and Latest cell, and a deliverable's as before", async () => {
|
|
922
|
-
mockArtifacts.mockResolvedValue(ok([PROPOSAL, ALPHA]));
|
|
923
|
-
await renderList();
|
|
924
|
-
const captions = screen.getAllByTestId("artifacts-row");
|
|
925
|
-
expect(captions.map((c) => c.textContent)).toEqual([
|
|
926
|
-
expect.stringContaining("Proposal · Version 1 · In review"),
|
|
927
|
-
expect.stringContaining("Version 1 · In review"),
|
|
928
|
-
]);
|
|
929
|
-
expect(captions[1]!.textContent).not.toContain("Proposal");
|
|
930
|
-
const row = screen.getByTestId(`artifacts-table-row-${PROPOSAL_ID}`);
|
|
931
|
-
expect(row).toHaveTextContent("Proposal · Version 1");
|
|
932
|
-
expect(
|
|
933
|
-
screen.getByTestId(`artifacts-table-row-${ID.alpha}`),
|
|
934
|
-
).not.toHaveTextContent("Proposal");
|
|
935
|
-
});
|
|
936
|
-
});
|