@meetelise/chat 1.69.2 → 1.70.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.
@@ -42,10 +42,10 @@ type FilterId = "bedrooms" | "moveIn" | "budget";
42
42
  const FILTER_IDS: FilterId[] = ["bedrooms", "moveIn", "budget"];
43
43
 
44
44
  /**
45
- * Lists a central group's top communities so the prospect can pick up to the
46
- * number of stops left. In the "extend" variant it offers more communities
47
- * after a booking. Ranking and every reason come from the server. The cards and
48
- * badges are the fee calculator's. The scheduler holds the picks and shows them,
45
+ * Lists a central group's top communities so the prospect can pick one, or, in
46
+ * the "extend" variant after a booking, up to the number of stops left. Ranking
47
+ * and every reason come from the server. The cards and badges are the fee
48
+ * calculator's. The scheduler holds the picks; after a booking it shows them,
49
49
  * with Continue, in its footer (`renderSelectionTray`).
50
50
  */
51
51
  @customElement("community-picker")
@@ -115,7 +115,10 @@ export class CommunityPicker extends LitElement {
115
115
 
116
116
  private toggle(community: Community): void {
117
117
  if (!community.tourable) return;
118
- if (this.isSelected(community.building_id)) {
118
+ // One to pick: a click picks it, in place of any earlier pick.
119
+ if (this.maxSelectable === 1) {
120
+ this.emitSelection([toCommunitySummary(community)]);
121
+ } else if (this.isSelected(community.building_id)) {
119
122
  this.emitSelection(
120
123
  this.selected.filter((s) => s.building_id !== community.building_id)
121
124
  );
@@ -259,7 +262,10 @@ export class CommunityPicker extends LitElement {
259
262
 
260
263
  private renderCard(c: Community): TemplateResult {
261
264
  const selected = this.isSelected(c.building_id);
262
- const full = !selected && this.selected.length >= this.maxSelectable;
265
+ const full =
266
+ this.maxSelectable > 1 &&
267
+ !selected &&
268
+ this.selected.length >= this.maxSelectable;
263
269
  const next = c.next_available;
264
270
  // Extension times are all on the day already booked.
265
271
  const sameDay = !!next && this.variant === "extend";
@@ -105,12 +105,15 @@ export class ItineraryEditor extends LitElement {
105
105
  @property({ type: Boolean })
106
106
  canEditCommunities = false;
107
107
 
108
- /** The server allows another stop. */
109
108
  @property({ type: Boolean })
110
- canAddStop = false;
109
+ loading = false;
111
110
 
111
+ /**
112
+ * The server has planned these choices. Until it has, as after a failed
113
+ * request, empty lists mean nothing is known yet, not that nothing is offered.
114
+ */
112
115
  @property({ type: Boolean })
113
- loading = false;
116
+ planned = false;
114
117
 
115
118
  @property({ attribute: false })
116
119
  primaryColor = defaultPrimaryColor;
@@ -118,6 +121,10 @@ export class ItineraryEditor extends LitElement {
118
121
  @property({ attribute: false })
119
122
  foregroundColorOnPrimaryBackgroundColor = "white";
120
123
 
124
+ private get offersKnown(): boolean {
125
+ return this.planned && !this.loading;
126
+ }
127
+
121
128
  @state() private editingTimeFor: number | null = null;
122
129
  @state() private dragIndex: number | null = null;
123
130
  @state() private dropIndex: number | null = null;
@@ -197,15 +204,7 @@ export class ItineraryEditor extends LitElement {
197
204
  Change
198
205
  </button>`
199
206
  : ""}
200
- </div>
201
- ${this.canEditCommunities && this.canAddStop
202
- ? html`<button
203
- class="floor-plan-badge add-stop"
204
- @click=${() => emit(this, "edit-communities", {})}
205
- >
206
- + Tour more communities the same day
207
- </button>`
208
- : ""}`;
207
+ </div> `;
209
208
  }
210
209
 
211
210
  private renderTourTypes(): TemplateResult {
@@ -240,7 +239,7 @@ export class ItineraryEditor extends LitElement {
240
239
  </tour-type-option>`;
241
240
  })}
242
241
  </div>
243
- ${this.tourTypes.length === 0 && !this.loading
242
+ ${this.tourTypes.length === 0 && this.offersKnown
244
243
  ? html`<p class="explanation">
245
244
  No tour type is offered at every community you picked.
246
245
  </p>`
@@ -316,7 +315,7 @@ export class ItineraryEditor extends LitElement {
316
315
  ${stop
317
316
  ? html`<div>${this.renderTimePicker(stop)}</div>`
318
317
  : html`<p class="explanation">
319
- ${this.bookableDates.length === 0 && !this.loading
318
+ ${this.bookableDates.length === 0 && this.offersKnown
320
319
  ? "No tour times in the next 30 days."
321
320
  : ""}
322
321
  </p>`}
@@ -456,7 +455,7 @@ export class ItineraryEditor extends LitElement {
456
455
  private renderItineraryDate(): TemplateResult {
457
456
  return html`<h2 class="journey-header date-header">Date</h2>
458
457
  <div id="datePicker">${this.renderDatePicker()}</div>
459
- ${this.bookableDates.length === 0 && !this.loading
458
+ ${this.bookableDates.length === 0 && this.offersKnown
460
459
  ? html`<p class="explanation">
461
460
  These communities have no back-to-back tour times in the next 30
462
461
  days. Try removing one.
@@ -471,15 +470,7 @@ export class ItineraryEditor extends LitElement {
471
470
  <ol class="stops" aria-busy=${String(this.loading)}>
472
471
  ${this.stops.map((stop, i) => this.renderStop(stop, i))}
473
472
  ${this.problems.map((p) => this.renderProblem(p))}
474
- </ol>
475
- ${this.canEditCommunities && this.canAddStop
476
- ? html`<button
477
- class="floor-plan-badge add-stop"
478
- @click=${() => emit(this, "edit-communities", {})}
479
- >
480
- + Add a community
481
- </button>`
482
- : ""}`;
473
+ </ol>`;
483
474
  }
484
475
 
485
476
  render(): TemplateResult {
@@ -525,10 +516,6 @@ export class ItineraryEditor extends LitElement {
525
516
  margin-bottom: 8px;
526
517
  }
527
518
 
528
- .add-stop {
529
- margin-bottom: 20px;
530
- }
531
-
532
519
  #tour-type-menu-outer-container .journey-header:not(:first-child) {
533
520
  margin-top: 4px;
534
521
  }
@@ -57,7 +57,10 @@ import { defaultPrimaryColor } from "../../themes";
57
57
  import type { LayoutOption } from "../../fetchBuildingWebchatView";
58
58
  import { isMobile, onMobileChange } from "../../utils";
59
59
  import { readGoogleReserveReferral } from "../../googleReserve";
60
- import { layoutToBedrooms } from "../../services/fees/utils";
60
+ import {
61
+ bedroomsToLayoutOption,
62
+ layoutToBedrooms,
63
+ } from "../../services/fees/utils";
61
64
  import { focusFirstTabStop, trapTabInside } from "../pubnub-chat";
62
65
  import type LeadSourceClient from "../LeadSourceClient";
63
66
  import type { LeadSourceMultitouchClient } from "../LeadSourceMultitouchClient";
@@ -87,9 +90,8 @@ const TOUR_TYPE_OPTION_VALUE: Record<TourTypeId, string> = {
87
90
 
88
91
  /**
89
92
  * The rebuilt tour scheduler, behind the `webchat_tour_scheduler_v2` rollout.
90
- * It books one community, or up to the server's cap of communities in a
91
- * central group as one same-day itinerary, and offers more communities after a
92
- * booking. The server decides which communities can tour, their order, the
93
+ * It books one community, then offers nearby communities in its central group
94
+ * to add after the booking, up to the server's cap, as one same-day itinerary. The server decides which communities can tour, their order, the
93
95
  * chained times and the cap; this element keeps only the step, the prospect's
94
96
  * choices and the form.
95
97
  */
@@ -234,6 +236,14 @@ export class TourSchedulerV2 extends LitElement {
234
236
  this.foregroundColorOnPrimaryBackgroundColor
235
237
  );
236
238
  }
239
+ // A preference picked for communities since swapped out may no longer be offered.
240
+ const layout = this.contact.layout;
241
+ if (
242
+ layout !== null &&
243
+ !this.bedroomOptions.some((option) => option.value === layout)
244
+ ) {
245
+ this.contact = { ...this.contact, layout: null };
246
+ }
237
247
  }
238
248
 
239
249
  firstUpdated(): void {
@@ -257,6 +267,13 @@ export class TourSchedulerV2 extends LitElement {
257
267
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "-1");
258
268
  this.focus({ preventScroll: true });
259
269
  }
270
+ // A notice explains the times above the form, which the prospect may be
271
+ // scrolled away from: down at the Schedule button, after a failed booking.
272
+ if (changed.has("notice") && this.notice) {
273
+ this.renderRoot
274
+ .querySelector(".notice")
275
+ ?.scrollIntoView({ block: "nearest" });
276
+ }
260
277
  }
261
278
 
262
279
  private async start(): Promise<void> {
@@ -881,11 +898,25 @@ export class TourSchedulerV2 extends LitElement {
881
898
  }
882
899
 
883
900
  /**
884
- * The form offers this widget's building's layouts, so a building with none
885
- * (a group's parent building) has no preference to ask for.
901
+ * What the form offers as a bedroom preference: the bedroom counts listed at
902
+ * the communities on this itinerary. Where the server sent none (a building
903
+ * outside a group, or communities with no listed units), this widget's own
904
+ * building's layouts.
886
905
  */
906
+ private get bedroomOptions(): LayoutOption[] {
907
+ const toured = [
908
+ ...(this.extending ? this.confirmed.map((stop) => stop.community) : []),
909
+ ...this.selectedIds.map((id) => this.communities.get(id)),
910
+ ];
911
+ const counts = new Set(toured.flatMap((c) => c?.bedrooms ?? []));
912
+ return counts.size > 0
913
+ ? [...counts].sort((a, b) => a - b).map(bedroomsToLayoutOption)
914
+ : this.layoutOptions;
915
+ }
916
+
917
+ /** A preference can only be required where there is one to choose. */
887
918
  private get bedroomsRequired(): boolean {
888
- return this.bedroomPreferenceRequired && this.layoutOptions.length > 0;
919
+ return this.bedroomPreferenceRequired && this.bedroomOptions.length > 0;
889
920
  }
890
921
 
891
922
  private disclaimer(): TemplateResult {
@@ -910,16 +941,21 @@ export class TourSchedulerV2 extends LitElement {
910
941
  </div>`;
911
942
  }
912
943
 
944
+ /**
945
+ * The design's first page: one community, which opens its schedule. More
946
+ * communities join the itinerary after the booking, from the confirmation.
947
+ */
913
948
  private renderPicker(): TemplateResult {
914
- return html`${this.container(html`<community-picker
949
+ return this.container(html`<community-picker
915
950
  variant="select"
916
951
  .load=${this.loadSelectCommunities}
917
952
  .initial=${this.group}
918
- .maxSelectable=${MAX_ITINERARY_STOPS}
953
+ .maxSelectable=${1}
919
954
  .selected=${this.picks}
920
- @selection-change=${this.onPicksChange}
921
- ></community-picker>`)}
922
- ${this.renderTray("select")}`;
955
+ @selection-change=${(
956
+ e: CustomEvent<{ communities: CommunitySummary[] }>
957
+ ) => this.onCommunitiesSelected(e.detail.communities, "select")}
958
+ ></community-picker>`);
923
959
  }
924
960
 
925
961
  private onPicksChange = (
@@ -928,21 +964,19 @@ export class TourSchedulerV2 extends LitElement {
928
964
  this.picks = e.detail.communities;
929
965
  };
930
966
 
931
- private renderTray(mode: "select" | "extend"): TemplateResult | string {
967
+ private renderTray(): TemplateResult | string {
932
968
  return renderSelectionTray({
933
969
  selected: this.picks,
934
970
  mobile: this.mobile,
935
971
  onRemove: (buildingId) =>
936
972
  (this.picks = this.picks.filter((c) => c.building_id !== buildingId)),
937
- onContinue: () => this.onCommunitiesSelected(this.picks, mode),
973
+ onContinue: () => this.onCommunitiesSelected(this.picks, "extend"),
938
974
  });
939
975
  }
940
976
 
941
977
  private renderSchedule(): TemplateResult {
942
978
  if (this.reschedulePrompt !== null) return this.renderReschedulePrompt();
943
979
  const plan = this.plan;
944
- const totalStops =
945
- (plan?.stops.length ?? 0) + (plan?.unchainable.length ?? 0);
946
980
  return html`${this.container(html`
947
981
  ${this.planError
948
982
  ? html`<p class="error-message" role="alert">
@@ -966,9 +1000,8 @@ export class TourSchedulerV2 extends LitElement {
966
1000
  .date=${this.date}
967
1001
  ?single=${!this.isMultiStop()}
968
1002
  ?canEditCommunities=${this.group !== null && !this.extending}
969
- ?canAddStop=${this.group !== null &&
970
- totalStops < MAX_ITINERARY_STOPS}
971
1003
  ?loading=${this.planLoading}
1004
+ ?planned=${plan !== null}
972
1005
  .primaryColor=${this.primaryColor}
973
1006
  .foregroundColorOnPrimaryBackgroundColor=${this
974
1007
  .foregroundColorOnPrimaryBackgroundColor}
@@ -989,7 +1022,7 @@ export class TourSchedulerV2 extends LitElement {
989
1022
  ></itinerary-editor>
990
1023
  <contact-form
991
1024
  .values=${this.contact}
992
- .layoutOptions=${this.layoutOptions}
1025
+ .layoutOptions=${this.bedroomOptions}
993
1026
  ?bedroomsRequired=${this.bedroomsRequired}
994
1027
  .leadSources=${this.leadSources}
995
1028
  ?showLeadSourceDropdown=${this.showLeadSourceDropdown()}
@@ -1093,7 +1126,7 @@ export class TourSchedulerV2 extends LitElement {
1093
1126
  ></community-picker>`
1094
1127
  : ""}
1095
1128
  </booking-confirmation>`)}
1096
- ${this.extendInitial ? this.renderTray("extend") : ""}`;
1129
+ ${this.extendInitial ? this.renderTray() : ""}`;
1097
1130
  }
1098
1131
 
1099
1132
  private renderBody(): TemplateResult {
@@ -26,6 +26,11 @@ export interface Community {
26
26
  distance_mi: number | null;
27
27
  /** In US dollars. */
28
28
  price_from: { bedrooms: number; amount: number } | null;
29
+ /**
30
+ * Every bedroom count with a listed unit, ascending (0 is a studio). Missing
31
+ * from a server that predates the field.
32
+ */
33
+ bedrooms?: number[];
29
34
  next_available: { date: string; time: string } | null;
30
35
  best_match: boolean;
31
36
  image_url: string | null;
@@ -40,6 +45,7 @@ export interface CommunitySummary {
40
45
  name: string;
41
46
  address: CommunityAddress | null;
42
47
  timezone: string | null;
48
+ bedrooms?: number[];
43
49
  }
44
50
 
45
51
  export const toCommunitySummary = (c: Community): CommunitySummary => ({
@@ -47,6 +53,7 @@ export const toCommunitySummary = (c: Community): CommunitySummary => ({
47
53
  name: c.name,
48
54
  address: c.address,
49
55
  timezone: c.timezone,
56
+ bedrooms: c.bedrooms,
50
57
  });
51
58
 
52
59
  export const formatAddress = (address: CommunityAddress | null): string =>
@@ -48,6 +48,14 @@ export class InternationalPhoneInput extends LitElement {
48
48
  border-color: #ff0000;
49
49
  }
50
50
 
51
+ /* The number input comes first in the DOM so Tab from the previous
52
+ field lands on it; the country selector follows it in tab order but
53
+ is drawn on the left. */
54
+ .country-select-wrapper,
55
+ .phone-input-divider {
56
+ order: -1;
57
+ }
58
+
51
59
  .country-select-wrapper {
52
60
  align-items: center;
53
61
  box-sizing: border-box;
@@ -265,6 +273,19 @@ export class InternationalPhoneInput extends LitElement {
265
273
  "phone-input-container--invalid": this.invalid,
266
274
  })}
267
275
  >
276
+ <input
277
+ class="webchat-input"
278
+ type="tel"
279
+ inputmode="tel"
280
+ placeholder=${this.placeholder}
281
+ name="phone"
282
+ autocomplete="tel-national"
283
+ maxlength="30"
284
+ .value=${this.value}
285
+ @keydown=${this.handleKeydown}
286
+ @input=${this.handleInput}
287
+ @blur=${this.handleBlur}
288
+ />
268
289
  <div class="country-select-wrapper">
269
290
  <span class="country-select-label" aria-hidden="true"
270
291
  >${this.selectedCountryLabel}</span
@@ -286,19 +307,6 @@ export class InternationalPhoneInput extends LitElement {
286
307
  </select>
287
308
  </div>
288
309
  <span class="phone-input-divider" aria-hidden="true"></span>
289
- <input
290
- class="webchat-input"
291
- type="tel"
292
- inputmode="tel"
293
- placeholder=${this.placeholder}
294
- name="phone"
295
- autocomplete="tel-national"
296
- maxlength="30"
297
- .value=${this.value}
298
- @keydown=${this.handleKeydown}
299
- @input=${this.handleInput}
300
- @blur=${this.handleBlur}
301
- />
302
310
  </div>
303
311
  `;
304
312
  }
@@ -1,4 +1,21 @@
1
+ import type { LayoutOption } from "../../fetchBuildingWebchatView";
2
+
1
3
  export const layoutToBedrooms = (layout: number): number => {
2
4
  if (layout === 0) return 0; // Studio
3
5
  return Math.floor(layout / 10);
4
6
  };
7
+
8
+ const BEDROOM_LABELS = [
9
+ "Studio",
10
+ "One bedroom",
11
+ "Two bedroom",
12
+ "Three bedroom",
13
+ "Four bedroom",
14
+ "Five bedroom",
15
+ ];
16
+
17
+ /** The layout option for a bedroom count, valued and labelled as a building's own layout options are. */
18
+ export const bedroomsToLayoutOption = (bedrooms: number): LayoutOption => ({
19
+ value: bedrooms * 10,
20
+ label: BEDROOM_LABELS[bedrooms] ?? `${bedrooms} bedroom`,
21
+ });
@@ -4,6 +4,7 @@ import "../public/dist/index";
4
4
  import type { TourSchedulerV2 } from "./WebComponent/SchedulerV2/tour-scheduler-v2";
5
5
  import type { ContactForm } from "./WebComponent/SchedulerV2/contact-form";
6
6
  import type { CommunityPicker } from "./WebComponent/SchedulerV2/community-picker";
7
+ import type { ItineraryEditor } from "./WebComponent/SchedulerV2/itinerary-editor";
7
8
  import type {
8
9
  BookingRequest,
9
10
  BookingResponse,
@@ -44,9 +45,14 @@ const DATE = "2026-10-30";
44
45
  const ANCHOR = 12;
45
46
  const LINDEN = 40;
46
47
 
47
- const community = (building_id: number, name: string): Community => ({
48
+ const community = (
49
+ building_id: number,
50
+ name: string,
51
+ bedrooms?: number[]
52
+ ): Community => ({
48
53
  building_id,
49
54
  name,
55
+ bedrooms,
50
56
  address: { line1: "1 Main St", city: "Chicago", state: "IL" },
51
57
  timezone: "America/Chicago",
52
58
  distance_mi: building_id === ANCHOR ? 0 : 1.8,
@@ -73,11 +79,17 @@ const at = (minutes: number) =>
73
79
  const fakeBackend = ({
74
80
  tourTypes = ["escorted-tour"],
75
81
  dropFirstBooking = false,
82
+ failPlan = false,
83
+ bedrooms,
76
84
  }: {
77
85
  /** The tour types the building offers. */
78
86
  tourTypes?: TourTypeId[];
87
+ /** Each community's listed bedroom counts; a server without the field sends none. */
88
+ bedrooms?: number[];
79
89
  /** Drops the first booking's connection, as a timeout would. */
80
90
  dropFirstBooking?: boolean;
91
+ /** Fails every plan request, as an outage would. */
92
+ failPlan?: boolean;
81
93
  } = {}): {
82
94
  bookings: BookingRequest[];
83
95
  keys: string[];
@@ -99,10 +111,10 @@ const fakeBackend = ({
99
111
  is_general_building: false,
100
112
  },
101
113
  communities: extend
102
- ? [community(LINDEN, "The Linden")]
114
+ ? [community(LINDEN, "The Linden", bedrooms)]
103
115
  : [
104
- community(ANCHOR, "Parkside Commons"),
105
- community(LINDEN, "The Linden"),
116
+ community(ANCHOR, "Parkside Commons", bedrooms),
117
+ community(LINDEN, "The Linden", bedrooms),
106
118
  ],
107
119
  });
108
120
  const plan = (request: PlanRequest): PlanResponse => {
@@ -192,6 +204,7 @@ const fakeBackend = ({
192
204
  if (pathname === "/platformApi/webchat/tour-itineraries/plan") {
193
205
  // As the server's request model does: stop_starts may be empty, not null.
194
206
  if (body.stop_starts === null) return json(422, null);
207
+ if (failPlan) return json(500, null);
195
208
  plannedTourTypes.push(body.tour_type);
196
209
  return json(200, plan(body));
197
210
  }
@@ -231,6 +244,7 @@ const mount = (): TourSchedulerV2 => {
231
244
  buildingSlug: "parkside-commons",
232
245
  buildingId: ANCHOR,
233
246
  buildingName: "Parkside Commons",
247
+ layoutOptions: [{ value: 10, label: "One bedroom" }],
234
248
  currentLeadSource: "google",
235
249
  leadSourceClient: {
236
250
  chatId: "webchat_lead_test",
@@ -396,7 +410,7 @@ it("extends a booking by sending the booked tour as an existing stop and only th
396
410
  });
397
411
  });
398
412
 
399
- it("keeps the prospect's picks when they filter after picking", async () => {
413
+ it("picks one community at a time: a pick replaces the community and opens its schedule", async () => {
400
414
  fakeBackend();
401
415
  const scheduler = mount();
402
416
 
@@ -410,33 +424,24 @@ it("keeps the prospect's picks when they filter after picking", async () => {
410
424
  inScheduler<CommunityPicker>(scheduler, "community-picker")
411
425
  );
412
426
  await picker.updateComplete;
413
- const cards = () =>
414
- Array.from(
415
- picker.shadowRoot?.querySelectorAll<HTMLButtonElement>(
416
- "button.floorplan-image-card"
417
- ) ?? []
418
- );
419
- cards()
420
- .find((card) => card.textContent?.includes("The Linden"))
421
- ?.click();
422
- await picker.updateComplete;
427
+ expect(
428
+ picker.shadowRoot?.querySelector(".picker-heading h2")?.textContent?.trim()
429
+ ).to.equal("Select a Community to Tour");
430
+ expect(inScheduler(scheduler, ".tray")).to.equal(null);
423
431
 
424
432
  Array.from(
425
433
  picker.shadowRoot?.querySelectorAll<HTMLButtonElement>(
426
- "#picker-filters .floor-plan-badge"
434
+ "button.floorplan-image-card"
427
435
  ) ?? []
428
436
  )
429
- .find((badge) => badge.textContent?.trim() === "1 bd")
437
+ .find((card) => card.textContent?.includes("The Linden"))
430
438
  ?.click();
431
- // The filter reloads the list, and the scheduler renders again.
432
- await new Promise((resolve) => setTimeout(resolve, 100));
433
- await picker.updateComplete;
434
439
 
435
- await scheduler.updateComplete;
436
- const picked = Array.from(
437
- scheduler.shadowRoot?.querySelectorAll(".tray .floor-plan-badge") ?? []
438
- ).map((chip) => chip.textContent?.trim());
439
- expect(picked).to.deep.equal(["Parkside Commons", "The Linden"]);
440
+ const planned = await waitFor(() => {
441
+ const found = inScheduler<ItineraryEditor>(scheduler, "itinerary-editor");
442
+ return found?.stops.length ? found.stops : null;
443
+ });
444
+ expect(planned.map((stop) => stop.building_id)).to.deep.equal([LINDEN]);
440
445
  });
441
446
 
442
447
  it("retries a failed booking with the same idempotency key, though attribution is stamped anew", async () => {
@@ -483,10 +488,54 @@ it("moves to the server's first tour type when escorted tours aren't offered", a
483
488
  expect(bookings[0].tour_type).to.equal("self-guided-tour");
484
489
  });
485
490
 
486
- it("books without a bedroom preference where one is required but the building has no layouts to offer", async () => {
491
+ it("says only that planning failed when /plan errors, not that nothing is offered", async () => {
492
+ fakeBackend({ failPlan: true });
493
+ const scheduler = mount();
494
+
495
+ await waitFor(() =>
496
+ inScheduler(scheduler, "p.error-message")?.textContent?.includes(
497
+ "Try again"
498
+ )
499
+ );
500
+ const editor = await waitFor(() =>
501
+ inScheduler<HTMLElement>(scheduler, "itinerary-editor")
502
+ );
503
+ await (editor as unknown as { updateComplete: Promise<boolean> })
504
+ .updateComplete;
505
+
506
+ const explanations = [
507
+ ...(editor.shadowRoot?.querySelectorAll(".explanation") ?? []),
508
+ ].map((p) => p.textContent?.trim() ?? "");
509
+ expect(explanations.filter(Boolean)).to.deep.equal([]);
510
+ });
511
+
512
+ it("offers the toured communities' bedroom counts where this building has no layouts of its own", async () => {
513
+ // A group's parent building: no units of its own, and the org requires a preference.
514
+ const { bookings } = fakeBackend({ bedrooms: [0, 2] });
515
+ const scheduler = mount();
516
+ scheduler.layoutOptions = [];
517
+ scheduler.bedroomPreferenceRequired = true;
518
+
519
+ const form = await waitFor(() => {
520
+ const found = inScheduler<ContactForm>(scheduler, "contact-form");
521
+ return found?.layoutOptions.length ? found : null;
522
+ });
523
+ expect(form.layoutOptions).to.deep.equal([
524
+ { value: 0, label: "Studio" },
525
+ { value: 20, label: "Two bedroom" },
526
+ ]);
527
+ expect(form.bedroomsRequired).to.equal(true);
528
+
529
+ await fillContactAndSubmit(scheduler, { layout: 20 });
530
+ await waitFor(() => bookings.length === 1);
531
+
532
+ expect(bookings[0].contact.bedrooms).to.deep.equal([2]);
533
+ });
534
+
535
+ it("books without a bedroom preference where one is required but there are no layouts to offer", async () => {
487
536
  const { bookings } = fakeBackend();
488
537
  const scheduler = mount();
489
- // A group's parent building: the org requires a preference, and there is nothing to pick.
538
+ scheduler.layoutOptions = [];
490
539
  scheduler.bedroomPreferenceRequired = true;
491
540
 
492
541
  await fillContactAndSubmit(scheduler, { layout: null });