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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tests for the New menu's
|
|
2
|
+
* Tests for the New menu's popups (#8233, spec
|
|
3
3
|
* docs/specs/8233-member-new-menu-the-new-spec.md D5–D10; AC-3, AC-4, AC-5).
|
|
4
4
|
*
|
|
5
5
|
* The Inbox page renders with every action offered; each case opens a popup
|
|
@@ -9,14 +9,18 @@
|
|
|
9
9
|
* Covers:
|
|
10
10
|
* 1. Request quote renders the request-quote magnet's CURRENT steps, read
|
|
11
11
|
* on each open — a step the provider adds shows on the next open — and
|
|
12
|
-
* posts the typed answers, a blank optional one omitted (AC-3).
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* posts the typed answers, a blank optional one omitted (AC-3). #11155:
|
|
13
|
+
* the date and the budget band are required (the browser refuses a
|
|
14
|
+
* submit without them, so nothing is posted), the date is a date input
|
|
15
|
+
* floored at today, the link's https refusal shows inline under it.
|
|
16
|
+
* 2. Send message (#11152) is a link to the member thread page,
|
|
17
|
+
* /account/inbox/thread — the lightbox is retired; the thread's
|
|
18
|
+
* composer posts through the same write (`thread.test.tsx`). Schedule
|
|
19
|
+
* appointment (#11154) is a link to /account/appointments: the schedule
|
|
20
|
+
* popup is retired, so one booking path remains — the member's booking
|
|
21
|
+
* page.
|
|
18
22
|
* 3. A refusal shows a plain message, keeps every typed value and leaves
|
|
19
|
-
* the popup open
|
|
23
|
+
* the popup open (AC-5).
|
|
20
24
|
* 4. No popup asks for a name or an email.
|
|
21
25
|
*/
|
|
22
26
|
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
@@ -60,11 +64,8 @@ jest.mock("../../../../../auth", () => ({
|
|
|
60
64
|
const mockNotFound = jest.fn();
|
|
61
65
|
const mockMemberMessages = jest.fn();
|
|
62
66
|
const mockMemberMeetingTypes = jest.fn();
|
|
63
|
-
const mockMemberAvailability = jest.fn();
|
|
64
67
|
const mockMemberRequestForm = jest.fn();
|
|
65
68
|
const mockMemberRequestQuote = jest.fn();
|
|
66
|
-
const mockMemberSendMessage = jest.fn();
|
|
67
|
-
const mockMemberBook = jest.fn();
|
|
68
69
|
jest.mock("@working-theory/api-client", () => ({
|
|
69
70
|
__esModule: true,
|
|
70
71
|
// #8765 D7 — no agreement outstanding, so the Inbox loads.
|
|
@@ -78,13 +79,11 @@ jest.mock("@working-theory/api-client", () => ({
|
|
|
78
79
|
pieces: (...args: unknown[]) => mockNotFound(...args),
|
|
79
80
|
purchases: (...args: unknown[]) => mockNotFound(...args),
|
|
80
81
|
appointments: (...args: unknown[]) => mockNotFound(...args),
|
|
82
|
+
welcome: (...args: unknown[]) => mockNotFound(...args),
|
|
81
83
|
messages: (...args: unknown[]) => mockMemberMessages(...args),
|
|
82
84
|
meetingTypes: (...args: unknown[]) => mockMemberMeetingTypes(...args),
|
|
83
|
-
availability: (...args: unknown[]) => mockMemberAvailability(...args),
|
|
84
85
|
requestForm: (...args: unknown[]) => mockMemberRequestForm(...args),
|
|
85
86
|
requestQuote: (...args: unknown[]) => mockMemberRequestQuote(...args),
|
|
86
|
-
sendMessage: (...args: unknown[]) => mockMemberSendMessage(...args),
|
|
87
|
-
book: (...args: unknown[]) => mockMemberBook(...args),
|
|
88
87
|
},
|
|
89
88
|
}));
|
|
90
89
|
|
|
@@ -98,6 +97,7 @@ jest.mock("next/navigation", () => ({
|
|
|
98
97
|
}));
|
|
99
98
|
|
|
100
99
|
import { PhoneTabProvider } from "@working-theory/templates/account";
|
|
100
|
+
import { toIsoDate } from "@working-theory/ui/primitives";
|
|
101
101
|
import { requestQuoteFlowConfig } from "@working-theory/validation";
|
|
102
102
|
|
|
103
103
|
import Page from "../page";
|
|
@@ -131,14 +131,6 @@ const TYPES = [
|
|
|
131
131
|
{ slug: "consult", title: "Consultation", durationMinutes: 30 },
|
|
132
132
|
{ slug: "review", title: "Design review", durationMinutes: 60 },
|
|
133
133
|
];
|
|
134
|
-
const SLOTS = [
|
|
135
|
-
{ start: "2026-10-20T15:00:00.000Z", end: "2026-10-20T15:30:00.000Z" },
|
|
136
|
-
{ start: "2026-10-21T16:00:00.000Z", end: "2026-10-21T16:30:00.000Z" },
|
|
137
|
-
];
|
|
138
|
-
const AVAILABILITY = {
|
|
139
|
-
event: { title: "Consultation", durationMinutes: 30, timeZone: "UTC" },
|
|
140
|
-
slots: SLOTS,
|
|
141
|
-
};
|
|
142
134
|
|
|
143
135
|
const FORM = {
|
|
144
136
|
form: { title: "Request a quote", defaultLocale: "en", steps: requestQuoteFlowConfig.steps },
|
|
@@ -159,8 +151,6 @@ const FORM_PLUS_STEP = {
|
|
|
159
151
|
};
|
|
160
152
|
|
|
161
153
|
const RECEIPT = ok({ id: "intx_1", createdAt: "2026-10-11T10:00:00.000Z" });
|
|
162
|
-
const BROWSER_TIME_ZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
163
|
-
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
164
154
|
|
|
165
155
|
beforeAll(() => {
|
|
166
156
|
if (typeof globalThis.PointerEvent === "undefined") {
|
|
@@ -177,11 +167,8 @@ beforeEach(() => {
|
|
|
177
167
|
mockNotFound.mockReset().mockResolvedValue(notFound);
|
|
178
168
|
mockMemberMessages.mockReset().mockResolvedValue(ok({ items: [] }));
|
|
179
169
|
mockMemberMeetingTypes.mockReset().mockResolvedValue(ok({ items: TYPES }));
|
|
180
|
-
mockMemberAvailability.mockReset().mockResolvedValue(ok(AVAILABILITY));
|
|
181
170
|
mockMemberRequestForm.mockReset().mockResolvedValue(ok(FORM));
|
|
182
171
|
mockMemberRequestQuote.mockReset().mockResolvedValue(RECEIPT);
|
|
183
|
-
mockMemberSendMessage.mockReset().mockResolvedValue(RECEIPT);
|
|
184
|
-
mockMemberBook.mockReset().mockResolvedValue(ok({ bookingId: "bk_1" }));
|
|
185
172
|
});
|
|
186
173
|
|
|
187
174
|
async function renderInbox(): Promise<void> {
|
|
@@ -209,6 +196,26 @@ function type(control: HTMLElement, value: string): void {
|
|
|
209
196
|
fireEvent.change(control, { target: { value } });
|
|
210
197
|
}
|
|
211
198
|
|
|
199
|
+
/** A future ISO date the server's "not before today" rule accepts. */
|
|
200
|
+
const FUTURE_DATE = "2999-01-01";
|
|
201
|
+
|
|
202
|
+
/** Today as the member's own `YYYY-MM-DD` — the date input's `min`. */
|
|
203
|
+
const localToday = (): string => toIsoDate(new Date());
|
|
204
|
+
|
|
205
|
+
/** Picks a band through the Select's native mirror (Radix bubbles a change on it back into the value). */
|
|
206
|
+
function pickBudget(popup: HTMLElement, value: string): void {
|
|
207
|
+
const native = popup.querySelector('select[name="answer.budget"]');
|
|
208
|
+
if (!(native instanceof HTMLSelectElement)) throw new Error("no budget select");
|
|
209
|
+
fireEvent.change(native, { target: { value } });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Fills the three required default answers. */
|
|
213
|
+
async function fillRequired(popup: HTMLElement): Promise<void> {
|
|
214
|
+
type(await within(popup).findByLabelText("What do you need?"), "A logo");
|
|
215
|
+
type(within(popup).getByLabelText("When do you need it?"), FUTURE_DATE);
|
|
216
|
+
pickBudget(popup, "1k-5k");
|
|
217
|
+
}
|
|
218
|
+
|
|
212
219
|
function expectNoIdentityFields(popup: HTMLElement): void {
|
|
213
220
|
expect(within(popup).queryAllByLabelText(/name|e-?mail/i)).toEqual([]);
|
|
214
221
|
expect(popup.querySelector('input[type="email"]')).toBeNull();
|
|
@@ -217,18 +224,80 @@ function expectNoIdentityFields(popup: HTMLElement): void {
|
|
|
217
224
|
// ── Request quote ────────────────────────────────────────────────────────────
|
|
218
225
|
|
|
219
226
|
describe("Request quote — the magnet's current steps, read on each open (AC-3)", () => {
|
|
220
|
-
it("renders the four default fields
|
|
227
|
+
it("renders the four default fields — need, a date and a budget band required, the link optional — and no identity field (#11155)", async () => {
|
|
221
228
|
await renderInbox();
|
|
222
229
|
const popup = await openPopup("Request quote");
|
|
223
230
|
await within(popup).findByLabelText("What do you need?");
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
expect(within(popup).getByLabelText(label)).not.toBeRequired();
|
|
227
|
-
}
|
|
231
|
+
// Two text boxes: the need and the link. The date and the band are their own controls.
|
|
232
|
+
expect(within(popup).getAllByRole("textbox")).toHaveLength(2);
|
|
228
233
|
expect(within(popup).getByLabelText("What do you need?")).toBeRequired();
|
|
234
|
+
|
|
235
|
+
const timing = within(popup).getByLabelText("When do you need it?");
|
|
236
|
+
expect(timing).toHaveAttribute("type", "date");
|
|
237
|
+
expect(timing).toBeRequired();
|
|
238
|
+
expect(timing).toHaveAttribute("min", localToday());
|
|
239
|
+
expect(within(popup).getByRole("button", { name: "Pick a date" })).toBeInTheDocument();
|
|
240
|
+
|
|
241
|
+
expect(within(popup).getByRole("combobox", { name: "Budget range" })).toBeInTheDocument();
|
|
242
|
+
const native = popup.querySelector('select[name="answer.budget"]');
|
|
243
|
+
expect(native).toBeRequired();
|
|
244
|
+
expect(Array.from((native as HTMLSelectElement).options).map((o) => o.value).filter(Boolean)).toEqual([
|
|
245
|
+
"under-1k",
|
|
246
|
+
"1k-5k",
|
|
247
|
+
"5k-10k",
|
|
248
|
+
"10k-25k",
|
|
249
|
+
"25k-plus",
|
|
250
|
+
]);
|
|
251
|
+
|
|
252
|
+
const link = within(popup).getByLabelText("Reference folder or document");
|
|
253
|
+
expect(link).not.toBeRequired();
|
|
254
|
+
expect(link).toHaveAttribute("placeholder", "https://");
|
|
255
|
+
expect(within(popup).queryByText("A rough range is fine.")).toBeNull();
|
|
256
|
+
expect(within(popup).queryByText(/Must start with https/)).toBeNull();
|
|
229
257
|
expectNoIdentityFields(popup);
|
|
230
258
|
});
|
|
231
259
|
|
|
260
|
+
it("posts nothing while the required date or budget is blank: the browser refuses the submit (#11155)", async () => {
|
|
261
|
+
await renderInbox();
|
|
262
|
+
const popup = await openPopup("Request quote");
|
|
263
|
+
type(await within(popup).findByLabelText("What do you need?"), "A logo");
|
|
264
|
+
fireEvent.click(within(popup).getByTestId("new-quote-submit"));
|
|
265
|
+
expect(within(popup).getByLabelText("When do you need it?")).toBeInvalid();
|
|
266
|
+
expect(popup.querySelector('select[name="answer.budget"]')).toBeInvalid();
|
|
267
|
+
|
|
268
|
+
type(within(popup).getByLabelText("When do you need it?"), FUTURE_DATE);
|
|
269
|
+
fireEvent.click(within(popup).getByTestId("new-quote-submit"));
|
|
270
|
+
expect(within(popup).getByLabelText("When do you need it?")).toBeValid();
|
|
271
|
+
expect(popup.querySelector('select[name="answer.budget"]')).toBeInvalid();
|
|
272
|
+
|
|
273
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
274
|
+
expect(mockMemberRequestQuote).not.toHaveBeenCalled();
|
|
275
|
+
expect(screen.getByTestId("account-new-popup")).toBeInTheDocument();
|
|
276
|
+
expect(within(popup).getByLabelText("What do you need?")).toHaveValue("A logo");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("a date before today is refused by the server as answers_invalid; the message shows and every answer is kept (#11155)", async () => {
|
|
280
|
+
mockMemberRequestQuote.mockResolvedValue(refusal(400, "answers_invalid"));
|
|
281
|
+
await renderInbox();
|
|
282
|
+
const popup = await openPopup("Request quote");
|
|
283
|
+
await fillRequired(popup);
|
|
284
|
+
// The input's own floor is bypassed the way a stale tab or a hand-built post would.
|
|
285
|
+
const timing = within(popup).getByLabelText("When do you need it?");
|
|
286
|
+
timing.removeAttribute("min");
|
|
287
|
+
type(timing, "2000-01-01");
|
|
288
|
+
fireEvent.click(within(popup).getByTestId("new-quote-submit"));
|
|
289
|
+
expect(
|
|
290
|
+
await within(popup).findByText("Some answers do not fit this form. Check them and try again."),
|
|
291
|
+
).toBeInTheDocument();
|
|
292
|
+
expect(mockMemberRequestQuote).toHaveBeenCalledWith(
|
|
293
|
+
{ answers: { need: "A logo", timing: "2000-01-01", budget: "1k-5k" } },
|
|
294
|
+
INIT,
|
|
295
|
+
);
|
|
296
|
+
expect(within(popup).getByLabelText("When do you need it?")).toHaveValue("2000-01-01");
|
|
297
|
+
expect(within(popup).getByLabelText("What do you need?")).toHaveValue("A logo");
|
|
298
|
+
expect(screen.getByTestId("account-new-popup")).toBeInTheDocument();
|
|
299
|
+
});
|
|
300
|
+
|
|
232
301
|
it("shows a step the provider added on the next open, with no page re-render", async () => {
|
|
233
302
|
await renderInbox();
|
|
234
303
|
let popup = await openPopup("Request quote");
|
|
@@ -239,16 +308,19 @@ describe("Request quote — the magnet's current steps, read on each open (AC-3)
|
|
|
239
308
|
mockMemberRequestForm.mockResolvedValue(ok(FORM_PLUS_STEP));
|
|
240
309
|
popup = await openPopup("Request quote");
|
|
241
310
|
expect(await within(popup).findByLabelText("Deadline")).toBeInTheDocument();
|
|
242
|
-
expect(within(popup).getAllByRole("textbox")).toHaveLength(
|
|
311
|
+
expect(within(popup).getAllByRole("textbox")).toHaveLength(3);
|
|
243
312
|
});
|
|
244
313
|
|
|
245
314
|
it("posts the typed answers through member.requestQuote, a blank optional answer omitted", async () => {
|
|
246
315
|
await renderInbox();
|
|
247
316
|
const popup = await openPopup("Request quote");
|
|
248
|
-
|
|
317
|
+
await fillRequired(popup);
|
|
249
318
|
fireEvent.click(within(popup).getByTestId("new-quote-submit"));
|
|
250
319
|
await waitFor(() => expect(mockMemberRequestQuote).toHaveBeenCalledTimes(1));
|
|
251
|
-
expect(mockMemberRequestQuote).toHaveBeenCalledWith(
|
|
320
|
+
expect(mockMemberRequestQuote).toHaveBeenCalledWith(
|
|
321
|
+
{ answers: { need: "A logo", timing: FUTURE_DATE, budget: "1k-5k" } },
|
|
322
|
+
INIT,
|
|
323
|
+
);
|
|
252
324
|
await waitFor(() => expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument());
|
|
253
325
|
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
254
326
|
});
|
|
@@ -274,183 +346,73 @@ describe("Request quote — the magnet's current steps, read on each open (AC-3)
|
|
|
274
346
|
|
|
275
347
|
// ── Send message ─────────────────────────────────────────────────────────────
|
|
276
348
|
|
|
277
|
-
describe("Send message —
|
|
278
|
-
|
|
279
|
-
type(within(popup).getByLabelText("Subject"), "Hello");
|
|
280
|
-
type(within(popup).getByLabelText("Message"), "Line 1\nLine 2");
|
|
281
|
-
type(within(popup).getByLabelText("Link"), link);
|
|
282
|
-
fireEvent.click(within(popup).getByTestId("new-message-submit"));
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
it("posts the three values as typed, closes and refreshes the Inbox", async () => {
|
|
349
|
+
describe("Send message — a link to the member thread page, no lightbox (#11152)", () => {
|
|
350
|
+
it("navigates to /account/inbox/thread and opens nothing over the Inbox", async () => {
|
|
286
351
|
await renderInbox();
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
expect(mockMemberSendMessage).toHaveBeenCalledWith(
|
|
292
|
-
{ subject: "Hello", body: "Line 1\nLine 2", link: "https://example.com/brief" },
|
|
293
|
-
INIT,
|
|
294
|
-
);
|
|
295
|
-
await waitFor(() => expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument());
|
|
296
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it("with the link left blank, posts no link key", async () => {
|
|
300
|
-
await renderInbox();
|
|
301
|
-
const popup = await openPopup("Send message");
|
|
302
|
-
await fill(popup, " ");
|
|
303
|
-
await waitFor(() => expect(mockMemberSendMessage).toHaveBeenCalledTimes(1));
|
|
304
|
-
expect(mockMemberSendMessage.mock.calls[0]![0]).toEqual({
|
|
305
|
-
subject: "Hello",
|
|
306
|
-
body: "Line 1\nLine 2",
|
|
352
|
+
fireEvent.pointerDown(screen.getByTestId("account-new-menu-trigger"), {
|
|
353
|
+
button: 0,
|
|
354
|
+
ctrlKey: false,
|
|
355
|
+
pointerType: "mouse",
|
|
307
356
|
});
|
|
357
|
+
const row = screen.getByRole("menuitem", { name: "Send message" });
|
|
358
|
+
expect(row).toHaveAttribute("data-href", "/account/inbox/thread");
|
|
359
|
+
fireEvent.click(row);
|
|
360
|
+
expect(mockPush).toHaveBeenCalledWith("/account/inbox/thread");
|
|
361
|
+
expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument();
|
|
362
|
+
expect(screen.queryByTestId("new-message-form")).not.toBeInTheDocument();
|
|
308
363
|
});
|
|
309
364
|
});
|
|
310
365
|
|
|
311
|
-
// ── Schedule
|
|
312
|
-
|
|
313
|
-
describe("Schedule service — the member's meeting types, booked as the caller (AC-4)", () => {
|
|
314
|
-
it("lists exactly the types member.meetingTypes returns", async () => {
|
|
315
|
-
await renderInbox();
|
|
316
|
-
const popup = await openPopup("Schedule service");
|
|
317
|
-
await within(popup).findByTestId("new-schedule-type-consult");
|
|
318
|
-
expect(within(popup).getAllByRole("radio").map((r) => r.getAttribute("value"))).toEqual([
|
|
319
|
-
"consult",
|
|
320
|
-
"review",
|
|
321
|
-
]);
|
|
322
|
-
expect(within(popup).getByText("Consultation")).toBeInTheDocument();
|
|
323
|
-
expect(within(popup).getByText("Design review")).toBeInTheDocument();
|
|
324
|
-
expectNoIdentityFields(popup);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
it("picking a type reads its slots once: that slug, 14 days, the browser's time zone", async () => {
|
|
328
|
-
await renderInbox();
|
|
329
|
-
const popup = await openPopup("Schedule service");
|
|
330
|
-
fireEvent.click(await within(popup).findByTestId("new-schedule-type-consult"));
|
|
331
|
-
await within(popup).findByTestId("new-schedule-slot-0");
|
|
332
|
-
expect(mockMemberAvailability).toHaveBeenCalledTimes(1);
|
|
333
|
-
const [query, init] = mockMemberAvailability.mock.calls[0]! as [
|
|
334
|
-
{ slug: string; from: string; to: string; timeZone: string },
|
|
335
|
-
unknown,
|
|
336
|
-
];
|
|
337
|
-
expect(init).toEqual(INIT);
|
|
338
|
-
expect(query.slug).toBe("consult");
|
|
339
|
-
expect(query.timeZone).toBe(BROWSER_TIME_ZONE);
|
|
340
|
-
expect(Date.parse(query.to) - Date.parse(query.from)).toBe(14 * DAY_MS);
|
|
341
|
-
});
|
|
366
|
+
// ── Schedule appointment ─────────────────────────────────────────────────────
|
|
342
367
|
|
|
343
|
-
|
|
368
|
+
describe("Schedule appointment — a link to the member's Appointments page, no popup (#11154)", () => {
|
|
369
|
+
it("navigates to /account/appointments and opens nothing over the Inbox", async () => {
|
|
344
370
|
await renderInbox();
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
expect(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
notes: "Bring the brief",
|
|
357
|
-
},
|
|
358
|
-
INIT,
|
|
359
|
-
);
|
|
360
|
-
await waitFor(() => expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument());
|
|
361
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it("with no type offered says so, and its Send a message switches to Send message", async () => {
|
|
365
|
-
mockMemberMeetingTypes.mockResolvedValue(ok({ items: [] }));
|
|
366
|
-
await renderInbox();
|
|
367
|
-
const popup = await openPopup("Schedule service");
|
|
368
|
-
expect(
|
|
369
|
-
await within(popup).findByText("No times are offered right now. You can send a message instead."),
|
|
370
|
-
).toBeInTheDocument();
|
|
371
|
-
fireEvent.click(within(popup).getByRole("button", { name: "Send a message" }));
|
|
372
|
-
const next = await screen.findByTestId("account-new-popup");
|
|
373
|
-
await waitFor(() =>
|
|
374
|
-
expect(within(next).getByRole("heading", { name: "Send message" })).toBeInTheDocument(),
|
|
375
|
-
);
|
|
376
|
-
expect(within(next).getByLabelText("Subject")).toBeInTheDocument();
|
|
371
|
+
fireEvent.pointerDown(screen.getByTestId("account-new-menu-trigger"), {
|
|
372
|
+
button: 0,
|
|
373
|
+
ctrlKey: false,
|
|
374
|
+
pointerType: "mouse",
|
|
375
|
+
});
|
|
376
|
+
const row = screen.getByRole("menuitem", { name: "Schedule appointment" });
|
|
377
|
+
expect(row).toHaveAttribute("data-href", "/account/appointments");
|
|
378
|
+
fireEvent.click(row);
|
|
379
|
+
expect(mockPush).toHaveBeenCalledWith("/account/appointments");
|
|
380
|
+
expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument();
|
|
381
|
+
expect(screen.queryByRole("menuitem", { name: /service/i })).not.toBeInTheDocument();
|
|
377
382
|
});
|
|
378
383
|
});
|
|
379
384
|
|
|
380
385
|
// ── Refusals ─────────────────────────────────────────────────────────────────
|
|
381
386
|
|
|
382
387
|
describe("a refusal shows a plain message and keeps every typed value (AC-5)", () => {
|
|
383
|
-
it("
|
|
384
|
-
mockMemberSendMessage.mockResolvedValue(refusal(400, "link_not_https"));
|
|
385
|
-
await renderInbox();
|
|
386
|
-
const popup = await openPopup("Send message");
|
|
387
|
-
type(within(popup).getByLabelText("Subject"), "Hello");
|
|
388
|
-
type(within(popup).getByLabelText("Message"), "Line 1\nLine 2");
|
|
389
|
-
type(within(popup).getByLabelText("Link"), "http://example.com");
|
|
390
|
-
fireEvent.click(within(popup).getByTestId("new-message-submit"));
|
|
391
|
-
expect(await within(popup).findByText("A link must start with https://.")).toBeInTheDocument();
|
|
392
|
-
expect(mockMemberSendMessage.mock.calls[0]![0]).toMatchObject({ link: "http://example.com" });
|
|
393
|
-
expect(within(popup).getByLabelText("Subject")).toHaveValue("Hello");
|
|
394
|
-
expect(within(popup).getByLabelText("Message")).toHaveValue("Line 1\nLine 2");
|
|
395
|
-
expect(within(popup).getByLabelText("Link")).toHaveValue("http://example.com");
|
|
396
|
-
expect(screen.getByTestId("account-new-popup")).toBeInTheDocument();
|
|
397
|
-
expect(mockRefresh).not.toHaveBeenCalled();
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
it("Request quote: a bare-domain link is sent as typed, refused, and all four answers kept", async () => {
|
|
388
|
+
it("Request quote: a bare-domain link is sent as typed, refused INLINE under the link, and all four answers kept (#11155)", async () => {
|
|
401
389
|
mockMemberRequestQuote.mockResolvedValue(refusal(400, "link_not_https"));
|
|
402
390
|
await renderInbox();
|
|
403
391
|
const popup = await openPopup("Request quote");
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
"When do you need it?": "Next month",
|
|
407
|
-
"Budget range": "$1k",
|
|
408
|
-
Link: "example.com",
|
|
409
|
-
};
|
|
410
|
-
for (const [label, value] of Object.entries(values)) {
|
|
411
|
-
type(await within(popup).findByLabelText(label), value);
|
|
412
|
-
}
|
|
392
|
+
await fillRequired(popup);
|
|
393
|
+
type(within(popup).getByLabelText("Reference folder or document"), "example.com");
|
|
413
394
|
fireEvent.click(within(popup).getByTestId("new-quote-submit"));
|
|
414
|
-
|
|
395
|
+
const error = await within(popup).findByTestId("new-quote-field-link-error");
|
|
396
|
+
expect(error).toHaveTextContent("A link must start with https://.");
|
|
397
|
+
expect(error).toHaveAttribute("role", "alert");
|
|
398
|
+
const link = within(popup).getByLabelText("Reference folder or document");
|
|
399
|
+
expect(link).toHaveAttribute("aria-invalid", "true");
|
|
400
|
+
expect(link).toHaveAttribute("aria-describedby", error.id);
|
|
401
|
+
// Inline, not the form-level refusal.
|
|
402
|
+
expect(within(popup).queryByTestId("new-popup-error")).toBeNull();
|
|
415
403
|
expect(mockMemberRequestQuote).toHaveBeenCalledWith(
|
|
416
|
-
{ answers: { need: "A logo", timing:
|
|
404
|
+
{ answers: { need: "A logo", timing: FUTURE_DATE, budget: "1k-5k", link: "example.com" } },
|
|
417
405
|
INIT,
|
|
418
406
|
);
|
|
407
|
+
const values: Record<string, string> = {
|
|
408
|
+
"What do you need?": "A logo",
|
|
409
|
+
"When do you need it?": FUTURE_DATE,
|
|
410
|
+
"Reference folder or document": "example.com",
|
|
411
|
+
};
|
|
419
412
|
for (const [label, value] of Object.entries(values)) {
|
|
420
413
|
expect(within(popup).getByLabelText(label)).toHaveValue(value);
|
|
421
414
|
}
|
|
422
415
|
expect(screen.getByTestId("account-new-popup")).toBeInTheDocument();
|
|
423
416
|
expect(mockRefresh).not.toHaveBeenCalled();
|
|
424
417
|
});
|
|
425
|
-
|
|
426
|
-
it("Schedule service: slot_unavailable re-reads the slots and keeps the type and the notes", async () => {
|
|
427
|
-
mockMemberBook.mockResolvedValue(refusal(409, "slot_unavailable"));
|
|
428
|
-
await renderInbox();
|
|
429
|
-
const popup = await openPopup("Schedule service");
|
|
430
|
-
fireEvent.click(await within(popup).findByTestId("new-schedule-type-consult"));
|
|
431
|
-
fireEvent.click(await within(popup).findByTestId("new-schedule-slot-0"));
|
|
432
|
-
type(within(popup).getByLabelText(/Notes/), "Bring the brief");
|
|
433
|
-
fireEvent.click(within(popup).getByTestId("new-schedule-submit"));
|
|
434
|
-
expect(
|
|
435
|
-
await within(popup).findByText("That time was just taken. Pick another."),
|
|
436
|
-
).toBeInTheDocument();
|
|
437
|
-
await waitFor(() => expect(mockMemberAvailability).toHaveBeenCalledTimes(2));
|
|
438
|
-
expect(within(popup).getByTestId("new-schedule-type-consult")).toHaveAttribute(
|
|
439
|
-
"aria-checked",
|
|
440
|
-
"true",
|
|
441
|
-
);
|
|
442
|
-
expect(within(popup).getByLabelText(/Notes/)).toHaveValue("Bring the brief");
|
|
443
|
-
expect(mockRefresh).not.toHaveBeenCalled();
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
it("an unlisted refusal code shows the generic message", async () => {
|
|
447
|
-
mockMemberSendMessage.mockResolvedValue(refusal(503, "tenant_unresolved"));
|
|
448
|
-
await renderInbox();
|
|
449
|
-
const popup = await openPopup("Send message");
|
|
450
|
-
type(within(popup).getByLabelText("Subject"), "Hello");
|
|
451
|
-
type(within(popup).getByLabelText("Message"), "Hi");
|
|
452
|
-
fireEvent.click(within(popup).getByTestId("new-message-submit"));
|
|
453
|
-
expect(await within(popup).findByText("This could not be sent. Try again.")).toBeInTheDocument();
|
|
454
|
-
expect(within(popup).getByLabelText("Subject")).toHaveValue("Hello");
|
|
455
|
-
});
|
|
456
418
|
});
|