@meetelise/chat 1.73.0 → 1.75.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/dist/src/WebComponent/Scheduler/tour-scheduler.d.ts +6 -0
- package/dist/src/WebComponent/SchedulerV2/booking-confirmation.d.ts +2 -0
- package/dist/src/WebComponent/SchedulerV2/community-picker.d.ts +6 -0
- package/dist/src/WebComponent/SchedulerV2/contact-form.d.ts +8 -3
- package/dist/src/WebComponent/SchedulerV2/itinerary-editor.d.ts +3 -0
- package/dist/src/WebComponent/SchedulerV2/scheduler-popover.d.ts +9 -1
- package/dist/src/WebComponent/SchedulerV2/schedulerRequests.d.ts +2 -0
- package/dist/src/WebComponent/SchedulerV2/tour-scheduler-v2.d.ts +6 -5
- package/dist/src/WebComponent/SchedulerV2/tourItineraryApi.d.ts +12 -0
- package/dist/src/WebComponent/SchedulerV2/tourTimes.d.ts +2 -0
- package/package.json +1 -1
- package/public/dist/index.js +441 -426
- package/src/WebComponent/Scheduler/tour-scheduler.ts +60 -9
- package/src/WebComponent/SchedulerV2/booking-confirmation.ts +13 -8
- package/src/WebComponent/SchedulerV2/community-picker.ts +19 -2
- package/src/WebComponent/SchedulerV2/contact-form.ts +54 -22
- package/src/WebComponent/SchedulerV2/itinerary-editor.ts +40 -17
- package/src/WebComponent/SchedulerV2/scheduler-popover.ts +17 -1
- package/src/WebComponent/SchedulerV2/schedulerRequests.ts +10 -0
- package/src/WebComponent/SchedulerV2/tour-scheduler-v2.ts +82 -15
- package/src/WebComponent/SchedulerV2/tourItineraryApi.ts +12 -0
- package/src/WebComponent/SchedulerV2/tourTimes.ts +12 -0
- package/src/existingTourReschedulePrompt.test.ts +97 -0
- package/src/tourSchedulerV2Booking.test.ts +197 -13
|
@@ -81,6 +81,11 @@ const EMPTY_FILTERS: CommunityFilters = {
|
|
|
81
81
|
maxBudget: null,
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
+
/** The bedroom counts of layouts, once each. */
|
|
85
|
+
const bedroomsOf = (layouts: number[]): number[] => [
|
|
86
|
+
...new Set(layouts.map(layoutToBedrooms)),
|
|
87
|
+
];
|
|
88
|
+
|
|
84
89
|
/** The building config value each tour type is offered under. */
|
|
85
90
|
const TOUR_TYPE_OPTION_VALUE: Record<TourTypeId, string> = {
|
|
86
91
|
"escorted-tour": "WITH_AGENT",
|
|
@@ -150,6 +155,8 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
150
155
|
@state() private date: string | null = null;
|
|
151
156
|
@state() private firstStart: string | null = null;
|
|
152
157
|
@state() private laterStarts: Record<number, string> = {};
|
|
158
|
+
/** Stops the prospect moved to their own day, away from `date`. */
|
|
159
|
+
@state() private stopDates: Record<number, string> = {};
|
|
153
160
|
@state() private plan: PlanResponse | null = null;
|
|
154
161
|
@state() private planLoading = false;
|
|
155
162
|
@state() private planError: string | null = null;
|
|
@@ -349,6 +356,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
349
356
|
this.plan = null;
|
|
350
357
|
this.firstStart = null;
|
|
351
358
|
this.laterStarts = {};
|
|
359
|
+
this.stopDates = {};
|
|
352
360
|
this.linkTourType = null;
|
|
353
361
|
this.notice = null;
|
|
354
362
|
this.bookingError = null;
|
|
@@ -366,6 +374,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
366
374
|
date: this.date ?? toIsoDate(new Date()),
|
|
367
375
|
firstStart: this.firstStart,
|
|
368
376
|
laterStarts: this.laterStarts,
|
|
377
|
+
stopDates: this.stopDates,
|
|
369
378
|
existingEventIds: this.existingEventIds,
|
|
370
379
|
};
|
|
371
380
|
}
|
|
@@ -397,7 +406,11 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
397
406
|
if (!plan.tour_types.includes(choice.tourType)) {
|
|
398
407
|
if (plan.tour_types.length === 0) break;
|
|
399
408
|
this.tourType = plan.tour_types[0];
|
|
409
|
+
this.stopDates = {};
|
|
400
410
|
} else if (
|
|
411
|
+
// bookable_dates are the days every stop chains on together, which
|
|
412
|
+
// the tour's day needn't be once a stop is on its own day.
|
|
413
|
+
Object.keys(choice.stopDates).length === 0 &&
|
|
401
414
|
plan.bookable_dates.length > 0 &&
|
|
402
415
|
!plan.bookable_dates.includes(choice.date)
|
|
403
416
|
) {
|
|
@@ -510,6 +523,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
510
523
|
this.tourType = tourType;
|
|
511
524
|
this.firstStart = null;
|
|
512
525
|
this.laterStarts = {};
|
|
526
|
+
this.stopDates = {};
|
|
513
527
|
void this.runPlan();
|
|
514
528
|
}
|
|
515
529
|
|
|
@@ -519,9 +533,40 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
519
533
|
tourType: this.tourType,
|
|
520
534
|
buildingId: this.buildingId,
|
|
521
535
|
});
|
|
536
|
+
// The whole tour moves, including any stop on its own day.
|
|
522
537
|
this.date = date;
|
|
523
538
|
this.firstStart = null;
|
|
524
539
|
this.laterStarts = {};
|
|
540
|
+
this.stopDates = {};
|
|
541
|
+
void this.runPlan();
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
private stopDatesWithout(buildingId: number): Record<number, string> {
|
|
545
|
+
return Object.fromEntries(
|
|
546
|
+
Object.entries(this.stopDates).filter(([id]) => Number(id) !== buildingId)
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
private onStopDate(buildingId: number, date: string): void {
|
|
551
|
+
const index = this.selectedIds.indexOf(buildingId);
|
|
552
|
+
if (index < 0) return;
|
|
553
|
+
pushGtmEvent("tourStopDateSelected", {
|
|
554
|
+
tourType: this.tourType,
|
|
555
|
+
buildingId: this.buildingId,
|
|
556
|
+
stopNumber: index + 1,
|
|
557
|
+
});
|
|
558
|
+
const others = this.stopDatesWithout(buildingId);
|
|
559
|
+
this.stopDates =
|
|
560
|
+
date === this.date ? others : { ...others, [buildingId]: date };
|
|
561
|
+
// The stop starts afresh on its new day, and the stops after it may move,
|
|
562
|
+
// so their own picks are dropped.
|
|
563
|
+
if (index === 0) this.firstStart = null;
|
|
564
|
+
this.laterStarts = Object.fromEntries(
|
|
565
|
+
this.selectedIds
|
|
566
|
+
.slice(1, index)
|
|
567
|
+
.filter((id) => this.laterStarts[id])
|
|
568
|
+
.map((id) => [id, this.laterStarts[id]])
|
|
569
|
+
);
|
|
525
570
|
void this.runPlan();
|
|
526
571
|
}
|
|
527
572
|
|
|
@@ -582,6 +627,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
582
627
|
if (this.selectedIds[0] === buildingId) this.firstStart = null;
|
|
583
628
|
this.selectedIds = remaining;
|
|
584
629
|
this.laterStarts = {};
|
|
630
|
+
this.stopDates = this.stopDatesWithout(buildingId);
|
|
585
631
|
void this.runPlan();
|
|
586
632
|
}
|
|
587
633
|
|
|
@@ -657,8 +703,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
657
703
|
last_name: values.lastName.trim(),
|
|
658
704
|
email: values.email.trim(),
|
|
659
705
|
phone_e164: values.phoneE164 ?? "",
|
|
660
|
-
bedrooms:
|
|
661
|
-
values.layout === null ? [] : [layoutToBedrooms(values.layout)],
|
|
706
|
+
bedrooms: bedroomsOf(values.layouts),
|
|
662
707
|
move_in: values.moveIn || null,
|
|
663
708
|
notes: values.notes.trim(),
|
|
664
709
|
},
|
|
@@ -744,6 +789,8 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
744
789
|
error: stop.error?.message ?? null,
|
|
745
790
|
distanceFromPrevMi:
|
|
746
791
|
plannedStops.get(stop.building_id)?.distance_from_prev_mi ?? null,
|
|
792
|
+
travelMinutesFromPrev:
|
|
793
|
+
plannedStops.get(stop.building_id)?.travel_minutes_from_prev ?? null,
|
|
747
794
|
};
|
|
748
795
|
});
|
|
749
796
|
const bookedStops = response.stops.filter(
|
|
@@ -843,6 +890,13 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
843
890
|
count: 1,
|
|
844
891
|
mode: "extend",
|
|
845
892
|
});
|
|
893
|
+
// The list was fetched after the last stop, on that stop's day, so the new
|
|
894
|
+
// stop joins it there.
|
|
895
|
+
const lastDay =
|
|
896
|
+
this.stopDates[this.selectedIds[this.selectedIds.length - 1]];
|
|
897
|
+
if (lastDay) {
|
|
898
|
+
this.stopDates = { ...this.stopDates, [community.building_id]: lastDay };
|
|
899
|
+
}
|
|
846
900
|
this.selectedIds = [...this.selectedIds, community.building_id];
|
|
847
901
|
void this.runPlan();
|
|
848
902
|
}
|
|
@@ -970,22 +1024,20 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
970
1024
|
: this.layoutOptions;
|
|
971
1025
|
}
|
|
972
1026
|
|
|
973
|
-
/**
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
);
|
|
981
|
-
return named.length === 1 ? named[0].value : null;
|
|
1027
|
+
/** The form's bedroom preferences: every offered option the shared bedrooms name. */
|
|
1028
|
+
private get preferredLayouts(): number[] {
|
|
1029
|
+
return this.bedroomOptions
|
|
1030
|
+
.map((option) => option.value)
|
|
1031
|
+
.filter((value) =>
|
|
1032
|
+
this.preferences.bedrooms.includes(layoutToBedrooms(value))
|
|
1033
|
+
);
|
|
982
1034
|
}
|
|
983
1035
|
|
|
984
1036
|
/** The form's values, with bedrooms and move-in from the shared preferences. */
|
|
985
1037
|
private get formValues(): ContactValues {
|
|
986
1038
|
return {
|
|
987
1039
|
...this.contact,
|
|
988
|
-
|
|
1040
|
+
layouts: this.preferredLayouts,
|
|
989
1041
|
moveIn: this.preferences.moveIn ?? "",
|
|
990
1042
|
};
|
|
991
1043
|
}
|
|
@@ -995,11 +1047,23 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
995
1047
|
// Every edit sends the whole form: only a field the prospect changed replaces
|
|
996
1048
|
// the shared value, so typing a name keeps bedrooms the form can't show.
|
|
997
1049
|
const shown = this.formValues;
|
|
998
|
-
|
|
1050
|
+
// A chip picks or clears its bedroom count, so bedrooms the form doesn't
|
|
1051
|
+
// offer stay picked, and layouts sharing a count go on and off together.
|
|
1052
|
+
const cleared = bedroomsOf(
|
|
1053
|
+
shown.layouts.filter((layout) => !values.layouts.includes(layout))
|
|
1054
|
+
);
|
|
1055
|
+
const picked = bedroomsOf(
|
|
1056
|
+
values.layouts.filter((layout) => !shown.layouts.includes(layout))
|
|
1057
|
+
);
|
|
1058
|
+
if (cleared.length > 0 || picked.length > 0) {
|
|
999
1059
|
this.preferences = {
|
|
1000
1060
|
...this.preferences,
|
|
1001
|
-
bedrooms:
|
|
1002
|
-
|
|
1061
|
+
bedrooms: [
|
|
1062
|
+
...new Set([
|
|
1063
|
+
...this.preferences.bedrooms.filter((b) => !cleared.includes(b)),
|
|
1064
|
+
...picked,
|
|
1065
|
+
]),
|
|
1066
|
+
].sort((a, b) => a - b),
|
|
1003
1067
|
};
|
|
1004
1068
|
}
|
|
1005
1069
|
if (values.moveIn !== shown.moveIn) {
|
|
@@ -1135,6 +1199,9 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1135
1199
|
@stop-time-change=${(
|
|
1136
1200
|
e: CustomEvent<{ buildingId: number; start: string }>
|
|
1137
1201
|
) => this.onStopTime(e.detail.buildingId, e.detail.start)}
|
|
1202
|
+
@stop-date-change=${(
|
|
1203
|
+
e: CustomEvent<{ buildingId: number; date: string }>
|
|
1204
|
+
) => this.onStopDate(e.detail.buildingId, e.detail.date)}
|
|
1138
1205
|
@stops-reorder=${(e: CustomEvent<{ buildingIds: number[] }>) =>
|
|
1139
1206
|
this.onReorder(e.detail.buildingIds)}
|
|
1140
1207
|
@stop-remove=${(e: CustomEvent<{ buildingId: number }>) =>
|
|
@@ -101,6 +101,8 @@ export interface PlanRequest {
|
|
|
101
101
|
start_time: string | null;
|
|
102
102
|
/** Times picked for later stops, by building id; empty when none are picked. */
|
|
103
103
|
stop_starts: Record<string, string>;
|
|
104
|
+
/** A stop's own day when it isn't `date`, by building id; empty when none is moved. */
|
|
105
|
+
stop_dates: Record<string, string>;
|
|
104
106
|
fixed_first: { calendar_event_id: number } | null;
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -110,7 +112,17 @@ export interface PlanStop {
|
|
|
110
112
|
end: string;
|
|
111
113
|
timezone: string;
|
|
112
114
|
distance_from_prev_mi: number | null;
|
|
115
|
+
/**
|
|
116
|
+
* Whole minutes to drive here from the stop before, already left free in the
|
|
117
|
+
* times. Missing from a server that predates the field.
|
|
118
|
+
*/
|
|
119
|
+
travel_minutes_from_prev?: number | null;
|
|
113
120
|
alternatives: string[];
|
|
121
|
+
/**
|
|
122
|
+
* The days this stop could move to on its own, within the next 30. Empty once
|
|
123
|
+
* a stop is booked, and missing from a server that predates the field.
|
|
124
|
+
*/
|
|
125
|
+
dates?: string[];
|
|
114
126
|
fixed: boolean;
|
|
115
127
|
}
|
|
116
128
|
|
|
@@ -67,6 +67,18 @@ export const formatMonthDay = (date: string): string =>
|
|
|
67
67
|
export const formatLongDate = (date: string): string =>
|
|
68
68
|
format(dateFromIsoDate(date), "EEE, MMM d, yyyy");
|
|
69
69
|
|
|
70
|
+
/** "1.8 mi · 12 min drive" between two stops, or "" when neither is known. */
|
|
71
|
+
export const formatLeg = (
|
|
72
|
+
distanceMi: number | null,
|
|
73
|
+
travelMinutes: number | null | undefined
|
|
74
|
+
): string =>
|
|
75
|
+
[
|
|
76
|
+
distanceMi !== null ? `${distanceMi.toFixed(1)} mi` : null,
|
|
77
|
+
travelMinutes != null ? `${travelMinutes} min drive` : null,
|
|
78
|
+
]
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join(" · ");
|
|
81
|
+
|
|
70
82
|
/** A Date as the "YYYY-MM-DD" the API uses. */
|
|
71
83
|
export const toIsoDate = (date: Date): string => format(date, "yyyy-MM-dd");
|
|
72
84
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { expect } from "@esm-bundle/chai";
|
|
2
|
+
import { render } from "lit";
|
|
3
|
+
import { useFakeXMLHttpRequest } from "sinon/pkg/sinon-esm";
|
|
4
|
+
import "../public/dist/index";
|
|
5
|
+
import type {
|
|
6
|
+
TourScheduler,
|
|
7
|
+
TourType,
|
|
8
|
+
} from "./WebComponent/Scheduler/tour-scheduler";
|
|
9
|
+
|
|
10
|
+
type FakeRequest = XMLHttpRequest & {
|
|
11
|
+
respond: (
|
|
12
|
+
status: number,
|
|
13
|
+
headers?: Record<string, string>,
|
|
14
|
+
body?: string
|
|
15
|
+
) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
window.dataLayer = [];
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/** Submits a tour, answers "already has a tour" with these headers, and reads the prompt. */
|
|
23
|
+
const promptAfterConflict = async (
|
|
24
|
+
headers: Record<string, string>
|
|
25
|
+
): Promise<string> => {
|
|
26
|
+
const fakeXhr = useFakeXMLHttpRequest();
|
|
27
|
+
const requests: FakeRequest[] = [];
|
|
28
|
+
fakeXhr.onCreate = (request: FakeRequest) => requests.push(request);
|
|
29
|
+
const tour = document.createElement("tour-scheduler") as TourScheduler;
|
|
30
|
+
Object.assign(tour, {
|
|
31
|
+
tourType: "guided" as TourType,
|
|
32
|
+
selectedDate: new Date("2030-01-15T00:00:00Z"),
|
|
33
|
+
selectedTime: { datetime: "2030-01-15T10:00:00", offset: "-06:00" },
|
|
34
|
+
phoneNumber: "(312) 555-0100",
|
|
35
|
+
phoneNumberE164: "+13125550100",
|
|
36
|
+
email: "cora@example.com",
|
|
37
|
+
buildingId: 445038,
|
|
38
|
+
buildingSlug: "test-building",
|
|
39
|
+
orgSlug: "test-org",
|
|
40
|
+
firstNameInputValue: "Cora",
|
|
41
|
+
lastNameInputValue: "Client",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const submission = tour.submit();
|
|
46
|
+
requests[0].respond(
|
|
47
|
+
409,
|
|
48
|
+
{ "Content-Type": "application/json", ...headers },
|
|
49
|
+
JSON.stringify({
|
|
50
|
+
detail: "User already has a tour scheduled for this building",
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
await submission;
|
|
54
|
+
} finally {
|
|
55
|
+
// Each call fakes XHR afresh, so put the real one back before the next.
|
|
56
|
+
fakeXhr.restore();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const container = document.createElement("div");
|
|
60
|
+
render(tour.rescheduleExplanation(), container);
|
|
61
|
+
return (container.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
it("names the existing tour's community and time, in the tour's own offset", async () => {
|
|
65
|
+
expect(
|
|
66
|
+
await promptAfterConflict({
|
|
67
|
+
"Existing-Tour-Building-Name": encodeURIComponent("Maple Court – North"),
|
|
68
|
+
"Existing-Tour-Start-Time": "2026-11-17T05:15:00+09:00",
|
|
69
|
+
})
|
|
70
|
+
).to.equal(
|
|
71
|
+
"You already have a tour scheduled at one of our communities, Maple Court – North, on Nov 17 at 5:15am. Would you like to reschedule?"
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("keeps the general prompt when either header is missing or unreadable", async () => {
|
|
76
|
+
const general =
|
|
77
|
+
"You already have a tour scheduled. Would you like to reschedule?";
|
|
78
|
+
|
|
79
|
+
expect(await promptAfterConflict({})).to.equal(general);
|
|
80
|
+
expect(
|
|
81
|
+
await promptAfterConflict({
|
|
82
|
+
"Existing-Tour-Building-Name": "Maple%20Court",
|
|
83
|
+
})
|
|
84
|
+
).to.equal(general);
|
|
85
|
+
expect(
|
|
86
|
+
await promptAfterConflict({
|
|
87
|
+
"Existing-Tour-Building-Name": "Maple%E0%A4%A",
|
|
88
|
+
"Existing-Tour-Start-Time": "2026-11-16T15:15:00-05:00",
|
|
89
|
+
})
|
|
90
|
+
).to.equal(general);
|
|
91
|
+
expect(
|
|
92
|
+
await promptAfterConflict({
|
|
93
|
+
"Existing-Tour-Building-Name": "Maple%20Court",
|
|
94
|
+
"Existing-Tour-Start-Time": "2026-11-16T15:15:00",
|
|
95
|
+
})
|
|
96
|
+
).to.equal(general);
|
|
97
|
+
});
|
|
@@ -42,6 +42,7 @@ const header = (request: FakeRequest, name: string): string | undefined =>
|
|
|
42
42
|
)?.[1];
|
|
43
43
|
|
|
44
44
|
const DATE = "2026-10-30";
|
|
45
|
+
const NEXT_DATE = "2026-10-31";
|
|
45
46
|
const ANCHOR = 12;
|
|
46
47
|
const LINDEN = 40;
|
|
47
48
|
const CEDAR = 7;
|
|
@@ -100,12 +101,14 @@ const fakeBackend = ({
|
|
|
100
101
|
sessionTokens: string[];
|
|
101
102
|
communityQueries: URLSearchParams[];
|
|
102
103
|
plannedTourTypes: TourTypeId[];
|
|
104
|
+
plans: PlanRequest[];
|
|
103
105
|
} => {
|
|
104
106
|
const bookings: BookingRequest[] = [];
|
|
105
107
|
const keys: string[] = [];
|
|
106
108
|
const sessionTokens: string[] = [];
|
|
107
109
|
const communityQueries: URLSearchParams[] = [];
|
|
108
110
|
const plannedTourTypes: TourTypeId[] = [];
|
|
111
|
+
const plans: PlanRequest[] = [];
|
|
109
112
|
let nextEventId = 990;
|
|
110
113
|
let dropped = false;
|
|
111
114
|
const group = (extend: boolean): CommunitiesResponse => ({
|
|
@@ -139,17 +142,25 @@ const fakeBackend = ({
|
|
|
139
142
|
});
|
|
140
143
|
start += 30;
|
|
141
144
|
}
|
|
145
|
+
// Stops on their own day chain from 10:00 that day.
|
|
146
|
+
const ownDayStarts: Record<string, number> = {};
|
|
142
147
|
request.building_ids.forEach((building_id) => {
|
|
148
|
+
const ownDay = request.stop_dates[String(building_id)];
|
|
149
|
+
const stopStart = (minutes: number) =>
|
|
150
|
+
ownDay ? at(minutes).replace(DATE, ownDay) : at(minutes);
|
|
151
|
+
const minutes = ownDay ? ownDayStarts[ownDay] ?? 10 * 60 : start;
|
|
143
152
|
stops.push({
|
|
144
153
|
building_id,
|
|
145
|
-
start:
|
|
146
|
-
end:
|
|
154
|
+
start: stopStart(minutes),
|
|
155
|
+
end: stopStart(minutes + 30),
|
|
147
156
|
timezone: "America/Chicago",
|
|
148
|
-
distance_from_prev_mi: stops.length > 0 ? 1.8 : null,
|
|
149
|
-
alternatives: [
|
|
157
|
+
distance_from_prev_mi: stops.length > 0 && !ownDay ? 1.8 : null,
|
|
158
|
+
alternatives: [stopStart(minutes + 15)],
|
|
159
|
+
dates: [DATE, NEXT_DATE],
|
|
150
160
|
fixed: false,
|
|
151
161
|
});
|
|
152
|
-
|
|
162
|
+
if (ownDay) ownDayStarts[ownDay] = minutes + 30;
|
|
163
|
+
else start += 30;
|
|
153
164
|
});
|
|
154
165
|
// As /plan does: dates and times only for a tour type the building offers.
|
|
155
166
|
const offered = tourTypes.includes(request.tour_type);
|
|
@@ -213,6 +224,7 @@ const fakeBackend = ({
|
|
|
213
224
|
if (body.stop_starts === null) return json(422, null);
|
|
214
225
|
if (failPlan) return json(500, null);
|
|
215
226
|
plannedTourTypes.push(body.tour_type);
|
|
227
|
+
plans.push(body);
|
|
216
228
|
return json(200, plan(body));
|
|
217
229
|
}
|
|
218
230
|
if (pathname === "/platformApi/webchat/tour-itineraries") {
|
|
@@ -234,7 +246,14 @@ const fakeBackend = ({
|
|
|
234
246
|
return json(404, null);
|
|
235
247
|
}, 0);
|
|
236
248
|
};
|
|
237
|
-
return {
|
|
249
|
+
return {
|
|
250
|
+
bookings,
|
|
251
|
+
keys,
|
|
252
|
+
sessionTokens,
|
|
253
|
+
communityQueries,
|
|
254
|
+
plannedTourTypes,
|
|
255
|
+
plans,
|
|
256
|
+
};
|
|
238
257
|
};
|
|
239
258
|
|
|
240
259
|
const waitFor = async <T>(
|
|
@@ -305,7 +324,7 @@ const fillContactAndSubmit = async (
|
|
|
305
324
|
email: "jane@example.com",
|
|
306
325
|
phone: "(312) 555-0142",
|
|
307
326
|
phoneE164: "+13125550142",
|
|
308
|
-
|
|
327
|
+
layouts: [10],
|
|
309
328
|
...overrides,
|
|
310
329
|
},
|
|
311
330
|
},
|
|
@@ -441,6 +460,75 @@ it("extends a booking without asking for contact details again, sending the book
|
|
|
441
460
|
});
|
|
442
461
|
});
|
|
443
462
|
|
|
463
|
+
it("moves an added stop to its own day, keeping the booked tour's day, adds the next stop on that day, and books them at that day's times", async () => {
|
|
464
|
+
const { bookings, plans } = fakeBackend();
|
|
465
|
+
const scheduler = mount();
|
|
466
|
+
|
|
467
|
+
await bookAndAddLinden(scheduler);
|
|
468
|
+
const editor = await waitFor(() =>
|
|
469
|
+
inScheduler<ItineraryEditor>(scheduler, "itinerary-editor")
|
|
470
|
+
);
|
|
471
|
+
// The booked stop never moves, so the tour has no date picker of its own.
|
|
472
|
+
expect(editor.shadowRoot?.querySelector(".date-header")).to.equal(null);
|
|
473
|
+
const edit = await waitFor(() =>
|
|
474
|
+
editor.shadowRoot?.querySelector<HTMLButtonElement>(".edit-time")
|
|
475
|
+
);
|
|
476
|
+
expect(edit.getAttribute("aria-label")).to.equal(
|
|
477
|
+
"Change the date or time at The Linden"
|
|
478
|
+
);
|
|
479
|
+
edit.click();
|
|
480
|
+
const picker = await waitFor(() =>
|
|
481
|
+
editor.shadowRoot?.querySelector<HTMLElement & { selectedDate?: Date }>(
|
|
482
|
+
"date-picker"
|
|
483
|
+
)
|
|
484
|
+
);
|
|
485
|
+
picker.selectedDate = new Date(2026, 9, 31);
|
|
486
|
+
// Until /plan answers, the times shown would be the old day's. The picker
|
|
487
|
+
// asks for the plan at once, and it answers only after these renders.
|
|
488
|
+
await scheduler.updateComplete;
|
|
489
|
+
await editor.updateComplete;
|
|
490
|
+
expect(editor.loading).to.equal(true);
|
|
491
|
+
expect(editor.shadowRoot?.querySelector("time-picker")).to.equal(null);
|
|
492
|
+
await waitFor(() =>
|
|
493
|
+
editor.stops.some((stop) => stop.start === `${NEXT_DATE}T10:00:00-05:00`)
|
|
494
|
+
);
|
|
495
|
+
await waitFor(() => editor.shadowRoot?.querySelector("time-picker"));
|
|
496
|
+
|
|
497
|
+
const moved = plans[plans.length - 1];
|
|
498
|
+
expect(moved.date).to.equal(DATE);
|
|
499
|
+
expect(moved.stop_dates).to.deep.equal({ [String(LINDEN)]: NEXT_DATE });
|
|
500
|
+
expect(moved.fixed_first).to.deep.equal({ calendar_event_id: 990 });
|
|
501
|
+
|
|
502
|
+
// The next stop is offered after The Linden on its new day, so it joins it there.
|
|
503
|
+
await waitFor(() => editor.canAddStop);
|
|
504
|
+
editor.shadowRoot?.querySelector<HTMLButtonElement>(".add-stop")?.click();
|
|
505
|
+
const nearby = await waitFor(() =>
|
|
506
|
+
inScheduler<CommunityPicker>(scheduler, ".add-stop-picker community-picker")
|
|
507
|
+
);
|
|
508
|
+
await nearby.updateComplete;
|
|
509
|
+
const cedar = await waitFor(() =>
|
|
510
|
+
Array.from(
|
|
511
|
+
nearby.shadowRoot?.querySelectorAll<HTMLButtonElement>(
|
|
512
|
+
"button.floorplan-image-card"
|
|
513
|
+
) ?? []
|
|
514
|
+
).find((card) => card.textContent?.includes("Cedar & Main"))
|
|
515
|
+
);
|
|
516
|
+
cedar.click();
|
|
517
|
+
await waitFor(() => editor.stops.some((stop) => stop.building_id === CEDAR));
|
|
518
|
+
expect(plans[plans.length - 1].stop_dates).to.deep.equal({
|
|
519
|
+
[String(LINDEN)]: NEXT_DATE,
|
|
520
|
+
[String(CEDAR)]: NEXT_DATE,
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
await submitWhenReady(scheduler);
|
|
524
|
+
await waitFor(() => bookings.length === 2);
|
|
525
|
+
expect(bookings[1].stops).to.deep.equal([
|
|
526
|
+
{ existing_calendar_event_id: 990 },
|
|
527
|
+
{ building_id: LINDEN, start: `${NEXT_DATE}T10:00:00-05:00` },
|
|
528
|
+
{ building_id: CEDAR, start: `${NEXT_DATE}T10:30:00-05:00` },
|
|
529
|
+
]);
|
|
530
|
+
});
|
|
531
|
+
|
|
444
532
|
it("picks one community at a time: a pick replaces the community and opens its schedule", async () => {
|
|
445
533
|
fakeBackend();
|
|
446
534
|
const scheduler = mount();
|
|
@@ -557,7 +645,7 @@ it("offers the toured communities' bedroom counts where this building has no lay
|
|
|
557
645
|
]);
|
|
558
646
|
expect(form.bedroomsRequired).to.equal(true);
|
|
559
647
|
|
|
560
|
-
await fillContactAndSubmit(scheduler, {
|
|
648
|
+
await fillContactAndSubmit(scheduler, { layouts: [20] });
|
|
561
649
|
await waitFor(() => bookings.length === 1);
|
|
562
650
|
|
|
563
651
|
expect(bookings[0].contact?.bedrooms).to.deep.equal([2]);
|
|
@@ -569,7 +657,7 @@ it("books without a bedroom preference where one is required but there are no la
|
|
|
569
657
|
scheduler.layoutOptions = [];
|
|
570
658
|
scheduler.bedroomPreferenceRequired = true;
|
|
571
659
|
|
|
572
|
-
await fillContactAndSubmit(scheduler, {
|
|
660
|
+
await fillContactAndSubmit(scheduler, { layouts: [] });
|
|
573
661
|
await waitFor(() => bookings.length === 1);
|
|
574
662
|
|
|
575
663
|
expect(bookings[0].contact?.bedrooms).to.deep.equal([]);
|
|
@@ -593,7 +681,7 @@ it("still asks for a bedroom preference where one is required and the building h
|
|
|
593
681
|
email: "jane@example.com",
|
|
594
682
|
phone: "(312) 555-0142",
|
|
595
683
|
phoneE164: "+13125550142",
|
|
596
|
-
|
|
684
|
+
layouts: [],
|
|
597
685
|
},
|
|
598
686
|
},
|
|
599
687
|
bubbles: true,
|
|
@@ -617,6 +705,52 @@ it("still asks for a bedroom preference where one is required and the building h
|
|
|
617
705
|
expect(button?.disabled).to.equal(true);
|
|
618
706
|
});
|
|
619
707
|
|
|
708
|
+
it("picks several bedroom preferences, a layout sharing a count going on and off with it", async () => {
|
|
709
|
+
const { bookings } = fakeBackend();
|
|
710
|
+
const scheduler = mount();
|
|
711
|
+
scheduler.layoutOptions = [
|
|
712
|
+
{ value: 10, label: "One bedroom" },
|
|
713
|
+
{ value: 11, label: "One bedroom + den" },
|
|
714
|
+
{ value: 20, label: "Two bedroom" },
|
|
715
|
+
];
|
|
716
|
+
|
|
717
|
+
const form = await waitFor(() =>
|
|
718
|
+
inScheduler<ContactForm>(scheduler, "contact-form")
|
|
719
|
+
);
|
|
720
|
+
const chip = (label: string) =>
|
|
721
|
+
Array.from(
|
|
722
|
+
form.shadowRoot?.querySelectorAll<HTMLButtonElement>("#layout button") ??
|
|
723
|
+
[]
|
|
724
|
+
).find((b) => b.textContent?.trim() === label);
|
|
725
|
+
const tap = async (label: string) => {
|
|
726
|
+
chip(label)?.click();
|
|
727
|
+
await scheduler.updateComplete;
|
|
728
|
+
await form.updateComplete;
|
|
729
|
+
};
|
|
730
|
+
const pressed = () =>
|
|
731
|
+
Array.from(
|
|
732
|
+
form.shadowRoot?.querySelectorAll<HTMLButtonElement>(
|
|
733
|
+
'#layout button[aria-pressed="true"]'
|
|
734
|
+
) ?? []
|
|
735
|
+
).map((b) => b.textContent?.trim());
|
|
736
|
+
|
|
737
|
+
await tap("One bedroom");
|
|
738
|
+
expect(pressed()).to.deep.equal(["One bedroom", "One bedroom + den"]);
|
|
739
|
+
await tap("Two bedroom");
|
|
740
|
+
expect(pressed()).to.deep.equal([
|
|
741
|
+
"One bedroom",
|
|
742
|
+
"One bedroom + den",
|
|
743
|
+
"Two bedroom",
|
|
744
|
+
]);
|
|
745
|
+
await tap("One bedroom + den");
|
|
746
|
+
expect(pressed()).to.deep.equal(["Two bedroom"]);
|
|
747
|
+
await tap("One bedroom");
|
|
748
|
+
|
|
749
|
+
await fillContactAndSubmit(scheduler, { layouts: form.values.layouts });
|
|
750
|
+
await waitFor(() => bookings.length === 1);
|
|
751
|
+
expect(bookings[0].contact?.bedrooms).to.deep.equal([1, 2]);
|
|
752
|
+
});
|
|
753
|
+
|
|
620
754
|
it("asks to reschedule an added stop that clashes with a tour, and resends it without contact details", async () => {
|
|
621
755
|
const { bookings } = fakeBackend({
|
|
622
756
|
extensionError: {
|
|
@@ -727,12 +861,15 @@ it("carries bedrooms, move-in and budget between the picker's filters, the form
|
|
|
727
861
|
inScheduler<ContactForm>(scheduler, "contact-form")
|
|
728
862
|
);
|
|
729
863
|
expect({
|
|
730
|
-
|
|
864
|
+
layouts: form.values.layouts,
|
|
731
865
|
moveIn: form.values.moveIn,
|
|
732
|
-
}).to.deep.equal({
|
|
866
|
+
}).to.deep.equal({ layouts: [20], moveIn: "2026-12-01" });
|
|
733
867
|
|
|
734
868
|
// Edited on the form, they carry on to the extension's filters, with the budget.
|
|
735
|
-
await fillContactAndSubmit(scheduler, {
|
|
869
|
+
await fillContactAndSubmit(scheduler, {
|
|
870
|
+
layouts: [10],
|
|
871
|
+
moveIn: "2027-01-15",
|
|
872
|
+
});
|
|
736
873
|
await waitFor(() => bookings.length === 1);
|
|
737
874
|
expect(bookings[0].contact?.bedrooms).to.deep.equal([1]);
|
|
738
875
|
expect(bookings[0].contact?.move_in).to.equal("2027-01-15");
|
|
@@ -793,6 +930,53 @@ it("closes only a filter's panel on Escape, leaving the scheduler open", async (
|
|
|
793
930
|
expect(closed).to.equal(false);
|
|
794
931
|
});
|
|
795
932
|
|
|
933
|
+
it("closes a filter's panel when focus moves on, so Escape is not pressed outside it", async () => {
|
|
934
|
+
fakeBackend();
|
|
935
|
+
const scheduler = mount();
|
|
936
|
+
const editor = await waitFor(() =>
|
|
937
|
+
inScheduler<HTMLElement>(scheduler, "itinerary-editor")
|
|
938
|
+
);
|
|
939
|
+
editor.dispatchEvent(
|
|
940
|
+
new CustomEvent("edit-communities", { bubbles: true, composed: true })
|
|
941
|
+
);
|
|
942
|
+
const picker = await waitFor(() =>
|
|
943
|
+
inScheduler<CommunityPicker>(scheduler, "community-picker")
|
|
944
|
+
);
|
|
945
|
+
await picker.updateComplete;
|
|
946
|
+
const chip = (id: string) =>
|
|
947
|
+
picker.shadowRoot?.querySelector<HTMLButtonElement>(
|
|
948
|
+
`[aria-controls="filter-${id}"]`
|
|
949
|
+
);
|
|
950
|
+
chip("bedrooms")?.click();
|
|
951
|
+
await picker.updateComplete;
|
|
952
|
+
const bedroom = await waitFor(() =>
|
|
953
|
+
picker.shadowRoot?.querySelector<HTMLButtonElement>(
|
|
954
|
+
"#filter-bedrooms button"
|
|
955
|
+
)
|
|
956
|
+
);
|
|
957
|
+
|
|
958
|
+
// Picking bedrooms keeps the panel open; tabbing on to the next chip doesn't.
|
|
959
|
+
// (Other test files' pages hold real focus, so the move is dispatched.)
|
|
960
|
+
const moveFocus = (from: HTMLElement, to: HTMLElement | undefined | null) =>
|
|
961
|
+
from.dispatchEvent(
|
|
962
|
+
new FocusEvent("focusout", {
|
|
963
|
+
relatedTarget: to ?? null,
|
|
964
|
+
bubbles: true,
|
|
965
|
+
composed: true,
|
|
966
|
+
})
|
|
967
|
+
);
|
|
968
|
+
bedroom.click();
|
|
969
|
+
const others = picker.shadowRoot?.querySelectorAll<HTMLButtonElement>(
|
|
970
|
+
"#filter-bedrooms button"
|
|
971
|
+
);
|
|
972
|
+
moveFocus(bedroom, others?.[1]);
|
|
973
|
+
await picker.updateComplete;
|
|
974
|
+
expect(chip("bedrooms")?.getAttribute("aria-expanded")).to.equal("true");
|
|
975
|
+
moveFocus(bedroom, chip("moveIn"));
|
|
976
|
+
await picker.updateComplete;
|
|
977
|
+
expect(chip("bedrooms")?.getAttribute("aria-expanded")).to.equal("false");
|
|
978
|
+
});
|
|
979
|
+
|
|
796
980
|
it("adds stops one at a time after a booking, offering each next stop after the one before it", async () => {
|
|
797
981
|
const { bookings, communityQueries } = fakeBackend();
|
|
798
982
|
const scheduler = mount();
|