create-ailk 0.36.0 → 0.37.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/component-catalog.json +40 -1
- package/component-catalog.md +7 -5
- package/dist/surfaces.js +60 -19
- package/dist/update.d.ts +19 -1
- package/dist/update.js +293 -35
- package/package.json +3 -3
- package/templates/.env.example +17 -0
- package/templates/apps/api/.env.example +38 -0
- package/templates/apps/api/CLAUDE.md +3 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +1 -1
- package/templates/apps/web/CLAUDE.md +28 -1
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +240 -76
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +369 -196
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +19 -3
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +309 -113
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +192 -65
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +55 -58
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +2 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +3 -2
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +18 -21
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
- package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +263 -0
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
- package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
- package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
- package/templates/apps/web/lib/account-config.ts +132 -8
- package/templates/apps/web/lib/auth-routes.ts +11 -6
- package/templates/apps/web/lib/offerings-pricing.ts +4 -1
- package/templates/apps/web/messages/en.json +156 -80
- package/versions.json +48 -48
- package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
- package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
- package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
* 5. The deletion request: the answer names who it went to; the action's
|
|
21
21
|
* refusal mapping; a Support pointer with no member API.
|
|
22
22
|
* 6. `#billing` forwards to Billing; `#general` and no fragment stay.
|
|
23
|
+
* 7. #11167 — the member General: Color mode on every site, the photo from
|
|
24
|
+
* the member profile read, no Name field (the photo saves alone, the
|
|
25
|
+
* account name follows the contact's first and last names on save,
|
|
26
|
+
* never a hand-set one), the Contact details as a level-2 section with
|
|
27
|
+
* no lead, the hints as placeholders.
|
|
23
28
|
*/
|
|
24
29
|
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
25
30
|
import { tmpdir } from "node:os";
|
|
@@ -73,6 +78,7 @@ const mockUpdateProfile = jest.fn();
|
|
|
73
78
|
const mockRequestDeletion = jest.fn();
|
|
74
79
|
const mockContact = jest.fn();
|
|
75
80
|
const mockUpdateContact = jest.fn();
|
|
81
|
+
const mockProfile = jest.fn();
|
|
76
82
|
const mockHubMe = jest.fn();
|
|
77
83
|
const mockLeadsSubmit = jest.fn();
|
|
78
84
|
jest.mock("@working-theory/api-client", () => ({
|
|
@@ -87,6 +93,7 @@ jest.mock("@working-theory/api-client", () => ({
|
|
|
87
93
|
requestDeletion: (...args: unknown[]) => mockRequestDeletion(...args),
|
|
88
94
|
contact: (...args: unknown[]) => mockContact(...args),
|
|
89
95
|
updateContact: (...args: unknown[]) => mockUpdateContact(...args),
|
|
96
|
+
profile: (...args: unknown[]) => mockProfile(...args),
|
|
90
97
|
},
|
|
91
98
|
hubSignIn: { me: (...args: unknown[]) => mockHubMe(...args) },
|
|
92
99
|
visitorForwardHeaders: () => null,
|
|
@@ -124,11 +131,15 @@ import type { AccountSettingsSection } from "@working-theory/templates/account";
|
|
|
124
131
|
import { accountSettingsSections } from "../../../../../lib/account-config";
|
|
125
132
|
import { seal } from "../../../../../lib/hub-session/seal";
|
|
126
133
|
import { BillingAnchor } from "../general/billing-anchor";
|
|
134
|
+
import { accountNameFollowsContact, derivedAccountName } from "../general/account-name";
|
|
127
135
|
import { saveContact } from "../general/contact-actions";
|
|
128
136
|
import Page from "../general/page";
|
|
137
|
+
import { savePhoto } from "../general/photo-actions";
|
|
129
138
|
import { saveProfile } from "../profile-actions";
|
|
130
139
|
|
|
131
140
|
const PHOTO = "https://cdn.example.com/ada.png";
|
|
141
|
+
/** The photo the member API holds — the hub's, which a spoke's session never carries (#11167). */
|
|
142
|
+
const HUB_PHOTO = "https://lh3.googleusercontent.com/a/ada";
|
|
132
143
|
const SESSION = {
|
|
133
144
|
user: {
|
|
134
145
|
id: "user_1",
|
|
@@ -186,6 +197,7 @@ beforeEach(() => {
|
|
|
186
197
|
mockRequestDeletion.mockReset().mockResolvedValue(ok({ sentTo: "site-operator" }));
|
|
187
198
|
mockContact.mockReset().mockResolvedValue(ok({ contact: null }));
|
|
188
199
|
mockUpdateContact.mockReset().mockResolvedValue(ok({ contact: null }));
|
|
200
|
+
mockProfile.mockReset().mockResolvedValue(ok({ name: "Ada Lovelace", image: HUB_PHOTO }));
|
|
189
201
|
mockHubMe.mockReset();
|
|
190
202
|
mockLeadsSubmit.mockReset();
|
|
191
203
|
mockUpdateUser.mockReset().mockResolvedValue({ data: { status: true }, error: null });
|
|
@@ -254,13 +266,31 @@ describe("AC-1 — the frame (D2, D7)", () => {
|
|
|
254
266
|
}
|
|
255
267
|
});
|
|
256
268
|
|
|
257
|
-
it("the pane holds the email read-only
|
|
269
|
+
it("the pane holds the email read-only and the photo input, and no Name field (#11167 ruling 5)", async () => {
|
|
258
270
|
await renderPage();
|
|
259
271
|
const pane = screen.getByTestId("account-settings-general");
|
|
260
272
|
expect(within(pane).getByTestId("account-general-email")).toHaveTextContent("ada@example.com");
|
|
261
273
|
expect(within(pane).queryByRole("textbox", { name: "Email" })).not.toBeInTheDocument();
|
|
262
|
-
expect(within(pane).
|
|
263
|
-
expect(within(pane).
|
|
274
|
+
expect(within(pane).queryByLabelText("Name")).not.toBeInTheDocument();
|
|
275
|
+
expect(within(pane).queryByTestId("account-general-name")).not.toBeInTheDocument();
|
|
276
|
+
// The photo is the member profile's — the hub's row (#11167 ruling 4).
|
|
277
|
+
expect(within(pane).getByLabelText("Photo")).toHaveValue(HUB_PHOTO);
|
|
278
|
+
expect(mockProfile).toHaveBeenCalledWith(COOKIE_INIT);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it("a failed member profile read falls back to the session's photo", async () => {
|
|
282
|
+
mockProfile.mockRejectedValue(new Error("down"));
|
|
283
|
+
await renderPage();
|
|
284
|
+
expect(screen.getByLabelText("Photo")).toHaveValue(PHOTO);
|
|
285
|
+
mockProfile.mockResolvedValue(refusal(503, "tenant_unresolved"));
|
|
286
|
+
document.body.innerHTML = "";
|
|
287
|
+
await renderPage();
|
|
288
|
+
expect(screen.getByLabelText("Photo")).toHaveValue(PHOTO);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("the rail still shows the account name", async () => {
|
|
292
|
+
await renderPage();
|
|
293
|
+
expect(within(screen.getByTestId("account-settings-rail")).getByText("Ada Lovelace")).toBeInTheDocument();
|
|
264
294
|
});
|
|
265
295
|
|
|
266
296
|
it("renders no deletion block — Request account deletion moved to Privacy (#8438 D16)", async () => {
|
|
@@ -271,13 +301,22 @@ describe("AC-1 — the frame (D2, D7)", () => {
|
|
|
271
301
|
|
|
272
302
|
it("the photo is never rendered as an image", async () => {
|
|
273
303
|
await renderPage();
|
|
274
|
-
expect(document.querySelector(`img[src="${
|
|
304
|
+
expect(document.querySelector(`img[src="${HUB_PHOTO}"]`)).toBeNull();
|
|
275
305
|
});
|
|
276
306
|
|
|
277
|
-
it("a light-only theme renders
|
|
307
|
+
it("a light-only theme renders the color-mode control too (#11167 ruling 3)", async () => {
|
|
278
308
|
writeSite('theme:\n colors:\n light:\n bg: "#fdfcfa"\n text: "#1c1917"');
|
|
279
309
|
await renderPage();
|
|
280
|
-
expect(screen.
|
|
310
|
+
expect(screen.getByTestId("account-color-mode")).toBeInTheDocument();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it("the color-mode control writes the theme cookie", async () => {
|
|
314
|
+
await renderPage();
|
|
315
|
+
const group = screen.getByRole("radiogroup", { name: "Color mode" });
|
|
316
|
+
fireEvent.click(within(group).getByRole("radio", { name: "Dark" }));
|
|
317
|
+
expect(document.cookie).toContain("ailk-theme=dark");
|
|
318
|
+
document.cookie = "ailk-theme=; max-age=0; path=/";
|
|
319
|
+
document.documentElement.removeAttribute("data-theme");
|
|
281
320
|
});
|
|
282
321
|
|
|
283
322
|
it("the color-mode control holds Light · Auto · Dark", async () => {
|
|
@@ -321,45 +360,36 @@ describe("the standalone shape (#8430)", () => {
|
|
|
321
360
|
|
|
322
361
|
// ── 2. The profile form on the member path (AC-3) ─────────────────────────────
|
|
323
362
|
|
|
324
|
-
describe("AC-3 —
|
|
325
|
-
it("a
|
|
363
|
+
describe("AC-3 — the photo through the member API (D4, D8; #11167 ruling 5: the photo alone)", () => {
|
|
364
|
+
it("a typed photo sends { image } alone — never the name — then refreshes", async () => {
|
|
326
365
|
await renderPage();
|
|
327
366
|
const save = screen.getByTestId("account-general-save");
|
|
328
367
|
expect(save).toBeDisabled();
|
|
329
|
-
|
|
368
|
+
const next = "https://cdn.example.com/new.png";
|
|
369
|
+
mockUpdateProfile.mockResolvedValue(ok({ name: "Ada Lovelace", image: next }));
|
|
370
|
+
fireEvent.change(screen.getByLabelText("Photo"), { target: { value: ` ${next} ` } });
|
|
330
371
|
await clickSave();
|
|
331
372
|
expect(mockUpdateProfile).toHaveBeenCalledTimes(1);
|
|
332
|
-
expect(mockUpdateProfile).toHaveBeenCalledWith({
|
|
373
|
+
expect(mockUpdateProfile).toHaveBeenCalledWith({ image: next }, COOKIE_INIT);
|
|
333
374
|
await waitFor(() => expect(mockRefresh).toHaveBeenCalledTimes(1));
|
|
334
375
|
expect(screen.getByTestId("account-general-status")).toHaveTextContent("Saved.");
|
|
335
376
|
expect(mockUpdateUser).not.toHaveBeenCalled();
|
|
336
377
|
});
|
|
337
378
|
|
|
338
|
-
it("a typed photo sends { name, image }", async () => {
|
|
339
|
-
await renderPage();
|
|
340
|
-
const next = "https://cdn.example.com/new.png";
|
|
341
|
-
mockUpdateProfile.mockResolvedValue(ok({ name: "Ada Lovelace", image: next }));
|
|
342
|
-
fireEvent.change(screen.getByLabelText("Photo"), { target: { value: next } });
|
|
343
|
-
await clickSave();
|
|
344
|
-
expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada Lovelace", image: next }, COOKIE_INIT);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
379
|
it("emptying a started photo sends image: null", async () => {
|
|
348
380
|
await renderPage();
|
|
349
381
|
mockUpdateProfile.mockResolvedValue(ok({ name: "Ada Lovelace", image: null }));
|
|
350
382
|
fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "" } });
|
|
351
383
|
await clickSave();
|
|
352
|
-
expect(mockUpdateProfile).toHaveBeenCalledWith({
|
|
384
|
+
expect(mockUpdateProfile).toHaveBeenCalledWith({ image: null }, COOKIE_INIT);
|
|
353
385
|
});
|
|
354
386
|
|
|
355
|
-
it("a refused photo says so plainly and
|
|
387
|
+
it("a refused photo says so plainly and the field keeps what was typed (AC-MAA-07)", async () => {
|
|
356
388
|
mockUpdateProfile.mockResolvedValue(refusal(400, "link_not_https"));
|
|
357
389
|
await renderPage();
|
|
358
|
-
fireEvent.change(screen.getByLabelText("Name"), { target: { value: "Ada King" } });
|
|
359
390
|
fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "http://cdn.example.com/a.png" } });
|
|
360
391
|
await clickSave();
|
|
361
392
|
expect(screen.getByRole("alert")).toHaveTextContent("Enter a link that starts with https://.");
|
|
362
|
-
expect(screen.getByLabelText("Name")).toHaveValue("Ada King");
|
|
363
393
|
expect(screen.getByLabelText("Photo")).toHaveValue("http://cdn.example.com/a.png");
|
|
364
394
|
expect(mockRefresh).not.toHaveBeenCalled();
|
|
365
395
|
});
|
|
@@ -371,18 +401,18 @@ describe("AC-3 — name and photo through the member API (D4, D8)", () => {
|
|
|
371
401
|
])("a refusal shows its message and keeps the edit (%#)", async (answer, message) => {
|
|
372
402
|
mockUpdateProfile.mockResolvedValue(answer);
|
|
373
403
|
await renderPage();
|
|
374
|
-
fireEvent.change(screen.getByLabelText("
|
|
404
|
+
fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "https://cdn.example.com/b.png" } });
|
|
375
405
|
await clickSave();
|
|
376
406
|
expect(screen.getByTestId("account-general-status")).toHaveTextContent(message);
|
|
377
|
-
expect(screen.getByLabelText("
|
|
407
|
+
expect(screen.getByLabelText("Photo")).toHaveValue("https://cdn.example.com/b.png");
|
|
378
408
|
});
|
|
379
409
|
|
|
380
|
-
it("a
|
|
410
|
+
it("a photo that is not a link is refused inline, with no call", async () => {
|
|
381
411
|
await renderPage();
|
|
382
|
-
fireEvent.change(screen.getByLabelText("
|
|
412
|
+
fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "ada.png" } });
|
|
383
413
|
await clickSave();
|
|
384
414
|
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
385
|
-
expect(screen.getByRole("alert")).toHaveTextContent("Enter
|
|
415
|
+
expect(screen.getByRole("alert")).toHaveTextContent("Enter a link that starts with https://.");
|
|
386
416
|
});
|
|
387
417
|
|
|
388
418
|
it("a 503 from the pieces read still offers the member writes", async () => {
|
|
@@ -392,6 +422,39 @@ describe("AC-3 — name and photo through the member API (D4, D8)", () => {
|
|
|
392
422
|
});
|
|
393
423
|
});
|
|
394
424
|
|
|
425
|
+
describe("AC-3 — savePhoto (#11167)", () => {
|
|
426
|
+
it("calls member.updateProfile with the image alone and forwardedCookieInit()'s init", async () => {
|
|
427
|
+
mockHeaders.mockResolvedValue(new Headers({ origin: "https://site.example.com" }));
|
|
428
|
+
mockUpdateProfile.mockResolvedValue(ok({ name: "Ada Lovelace", image: PHOTO }));
|
|
429
|
+
await expect(savePhoto(` ${PHOTO} `)).resolves.toEqual({ ok: true, image: PHOTO });
|
|
430
|
+
expect(mockUpdateProfile).toHaveBeenCalledWith(
|
|
431
|
+
{ image: PHOTO },
|
|
432
|
+
{ headers: { cookie: "session=abc", origin: "https://site.example.com" } },
|
|
433
|
+
);
|
|
434
|
+
await savePhoto(" ");
|
|
435
|
+
expect(mockUpdateProfile).toHaveBeenLastCalledWith({ image: null }, expect.anything());
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it.each([
|
|
439
|
+
[refusal(400, "link_not_https"), "photo"],
|
|
440
|
+
[refusal(400, "invalid_input"), "failed"],
|
|
441
|
+
[refusal(403, "email_unverified"), "unverified"],
|
|
442
|
+
[refusal(404, "not_found"), "unavailable"],
|
|
443
|
+
[refusal(503, "tenant_unresolved"), "unavailable"],
|
|
444
|
+
[refusal(500, "internal"), "failed"],
|
|
445
|
+
])("maps %j to %s", async (answer, reason) => {
|
|
446
|
+
mockUpdateProfile.mockResolvedValue(answer);
|
|
447
|
+
await expect(savePhoto(PHOTO)).resolves.toEqual({ ok: false, reason });
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it("refuses an image that is neither a string nor null, and a throw is failed", async () => {
|
|
451
|
+
await expect(savePhoto(42 as never)).resolves.toEqual({ ok: false, reason: "photo" });
|
|
452
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
453
|
+
mockUpdateProfile.mockRejectedValue(new TypeError("fetch failed"));
|
|
454
|
+
await expect(savePhoto(PHOTO)).resolves.toEqual({ ok: false, reason: "failed" });
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
|
|
395
458
|
describe("AC-3 — saveProfile (D6)", () => {
|
|
396
459
|
it("calls member.updateProfile with forwardedCookieInit()'s init and answers the saved pair", async () => {
|
|
397
460
|
mockHeaders.mockResolvedValue(new Headers({ origin: "https://site.example.com" }));
|
|
@@ -529,6 +592,43 @@ describe("AC-6 — the contact details (#8435 D13)", () => {
|
|
|
529
592
|
expect(within(section).getByTestId("contact-details-save")).toHaveTextContent("Save contact details");
|
|
530
593
|
});
|
|
531
594
|
|
|
595
|
+
// #11167 rulings 6, 7, 11, 12 — the headings order and the three strings
|
|
596
|
+
// that are gone: the Contact details lead, the Photo help copy and the
|
|
597
|
+
// phone's Format caption.
|
|
598
|
+
it("General is the h1 and Contact details a level-2 section under it; the lead and the two hints are gone", async () => {
|
|
599
|
+
await renderPage();
|
|
600
|
+
const headings = screen.getAllByRole("heading").map((h) => [h.tagName, h.textContent]);
|
|
601
|
+
expect(headings[0]).toEqual(["H1", "General"]);
|
|
602
|
+
expect(headings).toContainEqual(["H2", "Contact details"]);
|
|
603
|
+
expect(headings.map(([tag]) => tag)).not.toContain("H3");
|
|
604
|
+
for (const absent of [
|
|
605
|
+
"Kept on this site, for the people you work with here.",
|
|
606
|
+
"A link to a square image, starting with https://. Leave it empty to show your initials.",
|
|
607
|
+
"Format: (201) 555-0123",
|
|
608
|
+
]) {
|
|
609
|
+
expect(screen.queryByText(absent)).not.toBeInTheDocument();
|
|
610
|
+
}
|
|
611
|
+
expect(screen.getByLabelText("Photo")).toHaveAttribute("placeholder", "https://");
|
|
612
|
+
expect(screen.getByTestId("field-telephone")).toHaveAttribute("placeholder", "(###) ###-####");
|
|
613
|
+
// The Address group label is the fieldset's hidden legend (ruling 12).
|
|
614
|
+
expect(screen.getByTestId("field-contact-address-legend")).toHaveClass("sr-only");
|
|
615
|
+
expect(screen.getAllByText("Address")).toHaveLength(1);
|
|
616
|
+
// Each group is a card of the pane (ruling 2): color mode, the form, the contact.
|
|
617
|
+
const cards = screen.getAllByTestId("account-settings-general-card");
|
|
618
|
+
expect(cards.length).toBeGreaterThanOrEqual(3);
|
|
619
|
+
expect(cards[2]).toContainElement(screen.getByTestId("account-contact-section"));
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it("a saved contact refreshes the route, so the rail follows the derived name", async () => {
|
|
623
|
+
mockContact.mockResolvedValue(ok({ contact: CONTACT }));
|
|
624
|
+
await renderPage();
|
|
625
|
+
fireEvent.change(screen.getByTestId("contact-company"), { target: { value: "Acme" } });
|
|
626
|
+
await act(async () => {
|
|
627
|
+
fireEvent.submit(screen.getByTestId("contact-details-form"));
|
|
628
|
+
});
|
|
629
|
+
await waitFor(() => expect(mockRefresh).toHaveBeenCalledTimes(1));
|
|
630
|
+
});
|
|
631
|
+
|
|
532
632
|
it("with no confirmed contact yet, the form starts blank", async () => {
|
|
533
633
|
await renderPage();
|
|
534
634
|
expect(screen.getByTestId("contact-given-name")).toHaveValue("");
|
|
@@ -632,6 +732,120 @@ describe("AC-6 — saveContact (#8435 D13)", () => {
|
|
|
632
732
|
});
|
|
633
733
|
});
|
|
634
734
|
|
|
735
|
+
// ── #11167 ruling 5 — the account name follows the contact ──────────────────
|
|
736
|
+
|
|
737
|
+
describe("the account name follows the contact (#11167 ruling 5)", () => {
|
|
738
|
+
type Names = { givenName: string | null; familyName: string | null };
|
|
739
|
+
const NAMES: Names = { givenName: "Ada", familyName: "King" };
|
|
740
|
+
const BLANK_REST = { telephone: null, address: null, companyName: null, jobTitle: null };
|
|
741
|
+
const saved = (names: Names) => ok({ contact: { ...names, ...BLANK_REST } });
|
|
742
|
+
const previous = (names: Names | null) =>
|
|
743
|
+
ok({ contact: names === null ? null : { ...names, ...BLANK_REST } });
|
|
744
|
+
// The account name is the STORED one (`member.profile`), never the session's
|
|
745
|
+
// copy — a spoke's cookie holds the name from its last re-seal.
|
|
746
|
+
const stored = (name: string | null) => mockProfile.mockResolvedValue(ok({ name, image: null }));
|
|
747
|
+
const BODY = { ...NAMES, ...BLANK_REST };
|
|
748
|
+
|
|
749
|
+
it("derivedAccountName is 'First Last', trimmed, cut to the profile width, and empty with neither name", () => {
|
|
750
|
+
expect(derivedAccountName({ givenName: " Ada ", familyName: "King" })).toBe("Ada King");
|
|
751
|
+
expect(derivedAccountName({ givenName: "A".repeat(150), familyName: "B".repeat(150) })).toHaveLength(200);
|
|
752
|
+
expect(derivedAccountName({ givenName: "Ada", familyName: null })).toBe("Ada");
|
|
753
|
+
expect(derivedAccountName({ givenName: null, familyName: " " })).toBe("");
|
|
754
|
+
expect(derivedAccountName(null)).toBe("");
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
it("accountNameFollowsContact: an empty name follows; the last derived value follows; a hand-set name never does", () => {
|
|
758
|
+
expect(accountNameFollowsContact("", null)).toBe(true);
|
|
759
|
+
expect(accountNameFollowsContact(null, { givenName: "Ada", familyName: "Lovelace" })).toBe(true);
|
|
760
|
+
expect(accountNameFollowsContact("Ada Lovelace", { givenName: "Ada", familyName: "Lovelace" })).toBe(true);
|
|
761
|
+
expect(accountNameFollowsContact("Countess Ada", { givenName: "Ada", familyName: "Lovelace" })).toBe(false);
|
|
762
|
+
expect(accountNameFollowsContact("Ada Lovelace", null)).toBe(false);
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
it("an empty account name takes 'First Last' after the contact saves", async () => {
|
|
766
|
+
stored(null);
|
|
767
|
+
mockContact.mockResolvedValue(previous(null));
|
|
768
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
769
|
+
await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
|
|
770
|
+
expect(mockUpdateProfile).toHaveBeenCalledTimes(1);
|
|
771
|
+
expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada King" }, COOKIE_INIT);
|
|
772
|
+
// The stored name and the previous contact are read before the save.
|
|
773
|
+
expect(mockProfile).toHaveBeenCalledWith(COOKIE_INIT);
|
|
774
|
+
expect(mockContact.mock.invocationCallOrder[0]).toBeLessThan(mockUpdateContact.mock.invocationCallOrder[0]!);
|
|
775
|
+
expect(mockProfile.mock.invocationCallOrder[0]).toBeLessThan(mockUpdateContact.mock.invocationCallOrder[0]!);
|
|
776
|
+
// A single site has no hub session to re-seal.
|
|
777
|
+
expect(mockHubMe).not.toHaveBeenCalled();
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
it("a name that equals the last derived value follows the new names", async () => {
|
|
781
|
+
stored("Ada Lovelace");
|
|
782
|
+
mockContact.mockResolvedValue(previous({ givenName: "Ada", familyName: "Lovelace" }));
|
|
783
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
784
|
+
await saveContact(BODY);
|
|
785
|
+
expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada King" }, COOKIE_INIT);
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
it("the stored name decides, not the session's copy: a hand-set name on the hub is kept even when the session still carries the derived one", async () => {
|
|
789
|
+
mockGetSession.mockResolvedValue({ ...SESSION, user: { ...SESSION.user, name: "Ada Lovelace" } });
|
|
790
|
+
stored("Countess Ada");
|
|
791
|
+
mockContact.mockResolvedValue(previous({ givenName: "Ada", familyName: "Lovelace" }));
|
|
792
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
793
|
+
await saveContact(BODY);
|
|
794
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
it("when the stored name cannot be read, nothing follows", async () => {
|
|
798
|
+
mockProfile.mockResolvedValue(refusal(503, "tenant_unresolved"));
|
|
799
|
+
mockContact.mockResolvedValue(previous(null));
|
|
800
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
801
|
+
await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
|
|
802
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
it("a hand-set name is never overwritten", async () => {
|
|
806
|
+
stored("Countess Ada");
|
|
807
|
+
mockContact.mockResolvedValue(previous({ givenName: "Ada", familyName: "Lovelace" }));
|
|
808
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
809
|
+
await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
|
|
810
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
it("a name already equal to the derived one, or a contact with no names, writes nothing", async () => {
|
|
814
|
+
stored("Ada King");
|
|
815
|
+
mockContact.mockResolvedValue(previous(NAMES));
|
|
816
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
817
|
+
await saveContact(BODY);
|
|
818
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
819
|
+
|
|
820
|
+
stored(null);
|
|
821
|
+
mockUpdateContact.mockResolvedValue(saved({ givenName: null, familyName: null }));
|
|
822
|
+
await saveContact({ ...BODY, givenName: null, familyName: null });
|
|
823
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
it("when the previous contact cannot be read, only an empty name follows", async () => {
|
|
827
|
+
mockContact.mockRejectedValue(new Error("down"));
|
|
828
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
829
|
+
stored("Ada Lovelace");
|
|
830
|
+
await saveContact(BODY);
|
|
831
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
832
|
+
stored("");
|
|
833
|
+
await saveContact(BODY);
|
|
834
|
+
expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada King" }, COOKIE_INIT);
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
it("a refused contact save derives nothing, and a failed follow still answers ok", async () => {
|
|
838
|
+
stored(null);
|
|
839
|
+
mockUpdateContact.mockResolvedValue(refusal(403, "email_unverified"));
|
|
840
|
+
await expect(saveContact(BODY)).resolves.toEqual({ ok: false, reason: "unverified" });
|
|
841
|
+
expect(mockUpdateProfile).not.toHaveBeenCalled();
|
|
842
|
+
|
|
843
|
+
mockUpdateContact.mockResolvedValue(saved(NAMES));
|
|
844
|
+
mockUpdateProfile.mockRejectedValue(new Error("down"));
|
|
845
|
+
await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
|
|
635
849
|
// The deletion-request cases moved to privacy.test.tsx — Request account
|
|
636
850
|
// deletion now renders on Privacy, not General (#8438 D16).
|
|
637
851
|
|