@meetelise/chat 1.70.0 → 1.71.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/SchedulerV2/community-picker.d.ts +14 -1
- package/dist/src/WebComponent/SchedulerV2/scheduler-popover.d.ts +29 -0
- package/dist/src/WebComponent/SchedulerV2/schedulerRequests.d.ts +2 -1
- package/dist/src/WebComponent/SchedulerV2/tour-scheduler-v2.d.ts +14 -0
- package/dist/src/WebComponent/SchedulerV2/tourItineraryApi.d.ts +2 -1
- package/dist/src/WebComponent/me-chat.d.ts +2 -0
- package/package.json +1 -1
- package/public/dist/index.js +484 -429
- package/src/WebComponent/SchedulerV2/community-picker.ts +153 -91
- package/src/WebComponent/SchedulerV2/scheduler-popover.ts +108 -0
- package/src/WebComponent/SchedulerV2/schedulerRequests.ts +3 -2
- package/src/WebComponent/SchedulerV2/tour-scheduler-v2.ts +96 -50
- package/src/WebComponent/SchedulerV2/tourItineraryApi.ts +2 -1
- package/src/WebComponent/me-chat.ts +10 -0
- package/src/main/MEChat.ts +1 -0
- package/src/orgLevelNavigation.test.ts +44 -0
- package/src/tourSchedulerV2Booking.test.ts +224 -20
|
@@ -153,6 +153,11 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
153
153
|
@state() private planError: string | null = null;
|
|
154
154
|
@state() private notice: string | null = null;
|
|
155
155
|
@state() private contact: ContactValues = EMPTY_CONTACT;
|
|
156
|
+
/**
|
|
157
|
+
* Bedrooms, move-in and budget, shared by both pickers' filters and the form
|
|
158
|
+
* (which has no budget) for as long as the widget is open.
|
|
159
|
+
*/
|
|
160
|
+
@state() private preferences: CommunityFilters = EMPTY_FILTERS;
|
|
156
161
|
@state() private submitting = false;
|
|
157
162
|
@state() private bookingError: string | null = null;
|
|
158
163
|
@state() private reschedulePrompt: string | null = null;
|
|
@@ -236,14 +241,6 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
236
241
|
this.foregroundColorOnPrimaryBackgroundColor
|
|
237
242
|
);
|
|
238
243
|
}
|
|
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
|
-
}
|
|
247
244
|
}
|
|
248
245
|
|
|
249
246
|
firstUpdated(): void {
|
|
@@ -636,29 +633,30 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
636
633
|
|
|
637
634
|
// --- Booking ---
|
|
638
635
|
|
|
639
|
-
private async submit(
|
|
640
|
-
values: ContactValues,
|
|
641
|
-
cancelExistingTours = false
|
|
642
|
-
): Promise<void> {
|
|
636
|
+
private async submit(cancelExistingTours = false): Promise<void> {
|
|
643
637
|
// What's booked, kept apart from the screen, which stays editable while the request runs.
|
|
644
638
|
const plan = this.plan;
|
|
645
639
|
if (!plan || this.submitting) return;
|
|
646
640
|
const choice = this.choice();
|
|
641
|
+
const values = this.formValues;
|
|
647
642
|
const showDropdown = this.showLeadSourceDropdown();
|
|
648
643
|
const selectedLeadSource = showDropdown ? values.leadSource : null;
|
|
649
644
|
const request = buildBookingRequest({
|
|
650
645
|
choice,
|
|
651
646
|
plan,
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
647
|
+
// Adding stops books into the first booking's conversation, so the form isn't shown.
|
|
648
|
+
contact: this.extending
|
|
649
|
+
? null
|
|
650
|
+
: {
|
|
651
|
+
first_name: values.firstName.trim(),
|
|
652
|
+
last_name: values.lastName.trim(),
|
|
653
|
+
email: values.email.trim(),
|
|
654
|
+
phone_e164: values.phoneE164 ?? "",
|
|
655
|
+
bedrooms:
|
|
656
|
+
values.layout === null ? [] : [layoutToBedrooms(values.layout)],
|
|
657
|
+
move_in: values.moveIn || null,
|
|
658
|
+
notes: values.notes.trim(),
|
|
659
|
+
},
|
|
662
660
|
attribution: buildAttribution({
|
|
663
661
|
orgSlug: this.orgSlug,
|
|
664
662
|
selectedLeadSource,
|
|
@@ -699,7 +697,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
699
697
|
this.rescheduled = cancelExistingTours;
|
|
700
698
|
this.onBooked(response, choice.tourType, plan);
|
|
701
699
|
} catch (e) {
|
|
702
|
-
this.onBookingError(e
|
|
700
|
+
this.onBookingError(e);
|
|
703
701
|
} finally {
|
|
704
702
|
this.submitting = false;
|
|
705
703
|
}
|
|
@@ -812,14 +810,13 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
812
810
|
}
|
|
813
811
|
}
|
|
814
812
|
|
|
815
|
-
private onBookingError(e: unknown
|
|
813
|
+
private onBookingError(e: unknown): void {
|
|
816
814
|
const error =
|
|
817
815
|
e instanceof TourApiError
|
|
818
816
|
? e
|
|
819
817
|
: new TourApiError(0, null, "Something went wrong. Please try again.");
|
|
820
818
|
if (error.code === "EXISTING_TOUR") {
|
|
821
819
|
this.reschedulePrompt = error.message;
|
|
822
|
-
this.contact = values;
|
|
823
820
|
return;
|
|
824
821
|
}
|
|
825
822
|
this.reschedulePrompt = null;
|
|
@@ -893,7 +890,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
893
890
|
plan.stops.some((s) => !s.fixed) &&
|
|
894
891
|
plan.unchainable.length === 0 &&
|
|
895
892
|
this.activeLinkType === null &&
|
|
896
|
-
contactIsValid(this.
|
|
893
|
+
(this.extending || contactIsValid(this.formValues, this.bedroomsRequired))
|
|
897
894
|
);
|
|
898
895
|
}
|
|
899
896
|
|
|
@@ -904,16 +901,57 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
904
901
|
* building's layouts.
|
|
905
902
|
*/
|
|
906
903
|
private get bedroomOptions(): LayoutOption[] {
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
];
|
|
911
|
-
const counts = new Set(toured.flatMap((c) => c?.bedrooms ?? []));
|
|
904
|
+
const counts = new Set(
|
|
905
|
+
this.selectedIds.flatMap((id) => this.communities.get(id)?.bedrooms ?? [])
|
|
906
|
+
);
|
|
912
907
|
return counts.size > 0
|
|
913
908
|
? [...counts].sort((a, b) => a - b).map(bedroomsToLayoutOption)
|
|
914
909
|
: this.layoutOptions;
|
|
915
910
|
}
|
|
916
911
|
|
|
912
|
+
/**
|
|
913
|
+
* The form's bedroom preference, from the shared bedrooms: the one offered
|
|
914
|
+
* option they name, or none when they name no offered option or several.
|
|
915
|
+
*/
|
|
916
|
+
private get preferredLayout(): number | null {
|
|
917
|
+
const named = this.bedroomOptions.filter((option) =>
|
|
918
|
+
this.preferences.bedrooms.includes(layoutToBedrooms(option.value))
|
|
919
|
+
);
|
|
920
|
+
return named.length === 1 ? named[0].value : null;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/** The form's values, with bedrooms and move-in from the shared preferences. */
|
|
924
|
+
private get formValues(): ContactValues {
|
|
925
|
+
return {
|
|
926
|
+
...this.contact,
|
|
927
|
+
layout: this.preferredLayout,
|
|
928
|
+
moveIn: this.preferences.moveIn ?? "",
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
private onContactChange(values: ContactValues): void {
|
|
933
|
+
this.contact = values;
|
|
934
|
+
// Every edit sends the whole form: only a field the prospect changed replaces
|
|
935
|
+
// the shared value, so typing a name keeps bedrooms the form can't show.
|
|
936
|
+
const shown = this.formValues;
|
|
937
|
+
if (values.layout !== shown.layout) {
|
|
938
|
+
this.preferences = {
|
|
939
|
+
...this.preferences,
|
|
940
|
+
bedrooms:
|
|
941
|
+
values.layout === null ? [] : [layoutToBedrooms(values.layout)],
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
if (values.moveIn !== shown.moveIn) {
|
|
945
|
+
this.preferences = { ...this.preferences, moveIn: values.moveIn || null };
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
private onFiltersChange = (
|
|
950
|
+
e: CustomEvent<{ filters: CommunityFilters }>
|
|
951
|
+
): void => {
|
|
952
|
+
this.preferences = e.detail.filters;
|
|
953
|
+
};
|
|
954
|
+
|
|
917
955
|
/** A preference can only be required where there is one to choose. */
|
|
918
956
|
private get bedroomsRequired(): boolean {
|
|
919
957
|
return this.bedroomPreferenceRequired && this.bedroomOptions.length > 0;
|
|
@@ -950,8 +988,10 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
950
988
|
variant="select"
|
|
951
989
|
.load=${this.loadSelectCommunities}
|
|
952
990
|
.initial=${this.group}
|
|
991
|
+
.filters=${this.preferences}
|
|
953
992
|
.maxSelectable=${1}
|
|
954
993
|
.selected=${this.picks}
|
|
994
|
+
@filters-change=${this.onFiltersChange}
|
|
955
995
|
@selection-change=${(
|
|
956
996
|
e: CustomEvent<{ communities: CommunitySummary[] }>
|
|
957
997
|
) => this.onCommunitiesSelected(e.detail.communities, "select")}
|
|
@@ -1020,23 +1060,27 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1020
1060
|
@open-tour-link=${() =>
|
|
1021
1061
|
this.activeLinkType && this.openTourLink(this.activeLinkType)}
|
|
1022
1062
|
></itinerary-editor>
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1063
|
+
${this.extending
|
|
1064
|
+
? ""
|
|
1065
|
+
: html`<contact-form
|
|
1066
|
+
.values=${this.formValues}
|
|
1067
|
+
.layoutOptions=${this.bedroomOptions}
|
|
1068
|
+
?bedroomsRequired=${this.bedroomsRequired}
|
|
1069
|
+
.leadSources=${this.leadSources}
|
|
1070
|
+
?showLeadSourceDropdown=${this.showLeadSourceDropdown()}
|
|
1071
|
+
currentLeadSource=${this.currentLeadSource}
|
|
1072
|
+
.country=${this.country}
|
|
1073
|
+
?mobile=${this.mobile}
|
|
1074
|
+
@contact-change=${(e: CustomEvent<{ values: ContactValues }>) =>
|
|
1075
|
+
this.onContactChange(e.detail.values)}
|
|
1076
|
+
@lead-source-selected=${(
|
|
1077
|
+
e: CustomEvent<{ leadSource: string }>
|
|
1078
|
+
) =>
|
|
1079
|
+
pushGtmEvent("tourLeadSourceSelected", {
|
|
1080
|
+
leadSource: e.detail.leadSource,
|
|
1081
|
+
buildingId: this.buildingId,
|
|
1082
|
+
})}
|
|
1083
|
+
></contact-form>`}
|
|
1040
1084
|
</div>
|
|
1041
1085
|
`)}
|
|
1042
1086
|
<div
|
|
@@ -1055,7 +1099,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1055
1099
|
</div>
|
|
1056
1100
|
<action-confirm-button
|
|
1057
1101
|
id="schedule-bttn"
|
|
1058
|
-
.onClick=${() => this.submit(
|
|
1102
|
+
.onClick=${() => this.submit()}
|
|
1059
1103
|
.isLoading=${this.submitting}
|
|
1060
1104
|
height="50px"
|
|
1061
1105
|
width=${this.mobile ? "100%" : "145px"}
|
|
@@ -1091,7 +1135,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1091
1135
|
></action-confirm-button>
|
|
1092
1136
|
<action-confirm-button
|
|
1093
1137
|
id="reschedule-button"
|
|
1094
|
-
.onClick=${() => this.submit(
|
|
1138
|
+
.onClick=${() => this.submit(true)}
|
|
1095
1139
|
.isLoading=${this.submitting}
|
|
1096
1140
|
height="50px"
|
|
1097
1141
|
width="145px"
|
|
@@ -1120,8 +1164,10 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1120
1164
|
variant="extend"
|
|
1121
1165
|
.load=${this.loadExtendCommunities}
|
|
1122
1166
|
.initial=${this.extendInitial}
|
|
1167
|
+
.filters=${this.preferences}
|
|
1123
1168
|
.maxSelectable=${this.stopsRemaining()}
|
|
1124
1169
|
.selected=${this.picks}
|
|
1170
|
+
@filters-change=${this.onFiltersChange}
|
|
1125
1171
|
@selection-change=${this.onPicksChange}
|
|
1126
1172
|
></community-picker>`
|
|
1127
1173
|
: ""}
|
|
@@ -150,7 +150,8 @@ export interface BookingAttribution {
|
|
|
150
150
|
export interface BookingRequest {
|
|
151
151
|
tour_type: TourTypeId;
|
|
152
152
|
stops: BookingStopRequest[];
|
|
153
|
-
|
|
153
|
+
/** Left out when adding stops to a booking, which books into its conversation. */
|
|
154
|
+
contact?: BookingContact;
|
|
154
155
|
lead_sources: BookingAttribution;
|
|
155
156
|
conversation_tracking_id: string | null;
|
|
156
157
|
cancel_existing_tours: boolean;
|
|
@@ -309,8 +309,16 @@ export class MEChat extends LitElement {
|
|
|
309
309
|
|
|
310
310
|
launcherRef: Ref<Launcher> = createRef();
|
|
311
311
|
|
|
312
|
+
private dniNumber: string | null = null;
|
|
313
|
+
|
|
312
314
|
firstUpdated = async (): Promise<void> => this.setupWebchat();
|
|
313
315
|
|
|
316
|
+
reinsertDNIIntoWebsite(): void {
|
|
317
|
+
if (this.dniNumber) {
|
|
318
|
+
insertDNIIntoWebsite(this.dniNumber, this.orgSlug, this.buildingSlug);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
314
322
|
private setupWebchat = async (): Promise<void> => {
|
|
315
323
|
if (!this.orgSlug) return;
|
|
316
324
|
if (!this.centralConvo && !this.buildingSlug) return;
|
|
@@ -575,6 +583,7 @@ export class MEChat extends LitElement {
|
|
|
575
583
|
}
|
|
576
584
|
}
|
|
577
585
|
if (featureFlagInsertDNIWebsite && phoneNumberForSource?.number) {
|
|
586
|
+
this.dniNumber = phoneNumberForSource.number;
|
|
578
587
|
const totalReplacements = insertDNIIntoWebsite(
|
|
579
588
|
phoneNumberForSource.number,
|
|
580
589
|
this.orgSlug,
|
|
@@ -601,6 +610,7 @@ export class MEChat extends LitElement {
|
|
|
601
610
|
if (devTestPhoneNumber) {
|
|
602
611
|
// eslint-disable-next-line no-console
|
|
603
612
|
console.info("Using dev test phone number: ", devTestPhoneNumber);
|
|
613
|
+
this.dniNumber = devTestPhoneNumber;
|
|
604
614
|
insertDNIIntoWebsite(devTestPhoneNumber, this.orgSlug, this.buildingSlug);
|
|
605
615
|
}
|
|
606
616
|
|
package/src/main/MEChat.ts
CHANGED
|
@@ -127,6 +127,13 @@ const fakeBackend = (options: FakeBackendOptions = {}): FakeRequest[] => {
|
|
|
127
127
|
}
|
|
128
128
|
return json(200, session);
|
|
129
129
|
}
|
|
130
|
+
// Today's scheduler, when it opens, asks for its availabilities.
|
|
131
|
+
if (url.includes("/tour/availabilities")) {
|
|
132
|
+
return json(200, {
|
|
133
|
+
availability: {},
|
|
134
|
+
rankOrderedSupportedTourTypes: [],
|
|
135
|
+
});
|
|
136
|
+
}
|
|
130
137
|
if (url.includes("chat-ui-feature-flag")) return json(200, false);
|
|
131
138
|
return json(200, null);
|
|
132
139
|
});
|
|
@@ -722,6 +729,43 @@ it("swaps a Studio site's building widget for org-level webchat", async () => {
|
|
|
722
729
|
}
|
|
723
730
|
});
|
|
724
731
|
|
|
732
|
+
it("swaps the number again on a Studio page reached without a reload", async () => {
|
|
733
|
+
fakeBackend();
|
|
734
|
+
localStorage.setItem("eliseai_phone_number_devtest", "3035550123");
|
|
735
|
+
const page = document.createElement("main");
|
|
736
|
+
page.innerHTML = "<p>(855) 383-2298</p>";
|
|
737
|
+
document.body.appendChild(page);
|
|
738
|
+
const buildingContext = {
|
|
739
|
+
source: "elise_studio" as const,
|
|
740
|
+
siteId: STUDIO_SITE,
|
|
741
|
+
organization: "test-org",
|
|
742
|
+
building: "test-building",
|
|
743
|
+
sessionScope: { type: "building" as const, key: "building:test-building" },
|
|
744
|
+
};
|
|
745
|
+
MEChat.start({
|
|
746
|
+
studio: { siteId: STUDIO_SITE, mode: "host_managed_context" },
|
|
747
|
+
});
|
|
748
|
+
try {
|
|
749
|
+
MEChat.updateStudioContext(buildingContext);
|
|
750
|
+
const meChat = await studioWidget();
|
|
751
|
+
expect(page.textContent).to.equal("(303) 555-0123");
|
|
752
|
+
|
|
753
|
+
// Hidden test pages never paint, so run the frame callback right away.
|
|
754
|
+
stub(window, "requestAnimationFrame").callsFake((callback) => {
|
|
755
|
+
callback(0);
|
|
756
|
+
return 0;
|
|
757
|
+
});
|
|
758
|
+
page.innerHTML = "<p>Call (855) 383-2298</p>";
|
|
759
|
+
MEChat.updateStudioContext(buildingContext);
|
|
760
|
+
|
|
761
|
+
expect(document.querySelector("me-chat")).to.equal(meChat);
|
|
762
|
+
expect(page.textContent).to.equal("Call (303) 555-0123");
|
|
763
|
+
} finally {
|
|
764
|
+
page.remove();
|
|
765
|
+
await MEChat.remove();
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
|
|
725
769
|
it("clears a Studio site's org scope without an organization", async () => {
|
|
726
770
|
fakeBackend(inRollout);
|
|
727
771
|
MEChat.start({
|
|
@@ -81,6 +81,7 @@ const fakeBackend = ({
|
|
|
81
81
|
dropFirstBooking = false,
|
|
82
82
|
failPlan = false,
|
|
83
83
|
bedrooms,
|
|
84
|
+
extensionError,
|
|
84
85
|
}: {
|
|
85
86
|
/** The tour types the building offers. */
|
|
86
87
|
tourTypes?: TourTypeId[];
|
|
@@ -90,6 +91,8 @@ const fakeBackend = ({
|
|
|
90
91
|
dropFirstBooking?: boolean;
|
|
91
92
|
/** Fails every plan request, as an outage would. */
|
|
92
93
|
failPlan?: boolean;
|
|
94
|
+
/** Refuses bookings that add stops, unless they replace existing tours. */
|
|
95
|
+
extensionError?: { status: number; code: string; message: string };
|
|
93
96
|
} = {}): {
|
|
94
97
|
bookings: BookingRequest[];
|
|
95
98
|
keys: string[];
|
|
@@ -215,6 +218,13 @@ const fakeBackend = ({
|
|
|
215
218
|
return request.error();
|
|
216
219
|
}
|
|
217
220
|
bookings.push(body);
|
|
221
|
+
const addsStops = (body as BookingRequest).stops.some(
|
|
222
|
+
(stop) => "existing_calendar_event_id" in stop
|
|
223
|
+
);
|
|
224
|
+
if (extensionError && addsStops && !body.cancel_existing_tours) {
|
|
225
|
+
const { status, code, message } = extensionError;
|
|
226
|
+
return json(status, { error: { code, message } });
|
|
227
|
+
}
|
|
218
228
|
return json(200, book(body));
|
|
219
229
|
}
|
|
220
230
|
return json(404, null);
|
|
@@ -299,6 +309,10 @@ const fillContactAndSubmit = async (
|
|
|
299
309
|
composed: true,
|
|
300
310
|
})
|
|
301
311
|
);
|
|
312
|
+
await submitWhenReady(scheduler);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const submitWhenReady = async (scheduler: TourSchedulerV2) => {
|
|
302
316
|
const submit = await waitFor(() => {
|
|
303
317
|
const button = inScheduler<HTMLElement & { disabled: boolean }>(
|
|
304
318
|
scheduler,
|
|
@@ -309,6 +323,32 @@ const fillContactAndSubmit = async (
|
|
|
309
323
|
clickButton(submit);
|
|
310
324
|
};
|
|
311
325
|
|
|
326
|
+
/** Books the anchor, then picks The Linden to add and opens its schedule. */
|
|
327
|
+
const bookAndAddLinden = async (scheduler: TourSchedulerV2) => {
|
|
328
|
+
await fillContactAndSubmit(scheduler);
|
|
329
|
+
const picker = await waitFor(() =>
|
|
330
|
+
inScheduler<CommunityPicker>(
|
|
331
|
+
scheduler,
|
|
332
|
+
"booking-confirmation community-picker"
|
|
333
|
+
)
|
|
334
|
+
);
|
|
335
|
+
await picker.updateComplete;
|
|
336
|
+
const linden = await waitFor(() =>
|
|
337
|
+
Array.from(
|
|
338
|
+
picker.shadowRoot?.querySelectorAll<HTMLButtonElement>(
|
|
339
|
+
"button.floorplan-image-card"
|
|
340
|
+
) ?? []
|
|
341
|
+
).find((card) => card.textContent?.includes("The Linden"))
|
|
342
|
+
);
|
|
343
|
+
linden.click();
|
|
344
|
+
clickButton(await waitFor(() => inScheduler(scheduler, "#continue-bttn")));
|
|
345
|
+
await waitFor(() =>
|
|
346
|
+
inScheduler<ItineraryEditor>(scheduler, "itinerary-editor")?.stops.some(
|
|
347
|
+
(stop) => stop.building_id === LINDEN
|
|
348
|
+
)
|
|
349
|
+
);
|
|
350
|
+
};
|
|
351
|
+
|
|
312
352
|
afterEach(() => {
|
|
313
353
|
restore();
|
|
314
354
|
document.querySelectorAll("tour-scheduler-v2").forEach((el) => el.remove());
|
|
@@ -367,29 +407,17 @@ it("books a tour with the prospect's details, attribution and conversation, and
|
|
|
367
407
|
}
|
|
368
408
|
});
|
|
369
409
|
|
|
370
|
-
it("extends a booking
|
|
410
|
+
it("extends a booking without asking for contact details again, sending the booked tour as an existing stop and only the new community as a new one", async () => {
|
|
371
411
|
const { bookings, communityQueries } = fakeBackend();
|
|
372
412
|
const scheduler = mount();
|
|
373
413
|
|
|
374
|
-
await
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
scheduler,
|
|
378
|
-
"booking-confirmation community-picker"
|
|
379
|
-
)
|
|
380
|
-
);
|
|
381
|
-
await picker.updateComplete;
|
|
382
|
-
picker.shadowRoot
|
|
383
|
-
?.querySelector<HTMLButtonElement>("button.floorplan-image-card")
|
|
384
|
-
?.click();
|
|
385
|
-
clickButton(await waitFor(() => inScheduler(scheduler, "#continue-bttn")));
|
|
386
|
-
|
|
387
|
-
await waitFor(
|
|
388
|
-
() => bookings.length === 1 && inScheduler(scheduler, "itinerary-editor")
|
|
389
|
-
);
|
|
390
|
-
await fillContactAndSubmit(scheduler);
|
|
414
|
+
await bookAndAddLinden(scheduler);
|
|
415
|
+
expect(inScheduler(scheduler, "contact-form")).to.equal(null);
|
|
416
|
+
await submitWhenReady(scheduler);
|
|
391
417
|
await waitFor(() => bookings.length === 2);
|
|
392
418
|
|
|
419
|
+
// The server books an extension into the first booking's conversation.
|
|
420
|
+
expect(bookings[1]).not.to.have.property("contact");
|
|
393
421
|
expect(bookings[1].stops).to.deep.equal([
|
|
394
422
|
{ existing_calendar_event_id: 990 },
|
|
395
423
|
{ building_id: LINDEN, start: at(630) },
|
|
@@ -529,7 +557,7 @@ it("offers the toured communities' bedroom counts where this building has no lay
|
|
|
529
557
|
await fillContactAndSubmit(scheduler, { layout: 20 });
|
|
530
558
|
await waitFor(() => bookings.length === 1);
|
|
531
559
|
|
|
532
|
-
expect(bookings[0].contact
|
|
560
|
+
expect(bookings[0].contact?.bedrooms).to.deep.equal([2]);
|
|
533
561
|
});
|
|
534
562
|
|
|
535
563
|
it("books without a bedroom preference where one is required but there are no layouts to offer", async () => {
|
|
@@ -541,7 +569,7 @@ it("books without a bedroom preference where one is required but there are no la
|
|
|
541
569
|
await fillContactAndSubmit(scheduler, { layout: null });
|
|
542
570
|
await waitFor(() => bookings.length === 1);
|
|
543
571
|
|
|
544
|
-
expect(bookings[0].contact
|
|
572
|
+
expect(bookings[0].contact?.bedrooms).to.deep.equal([]);
|
|
545
573
|
});
|
|
546
574
|
|
|
547
575
|
it("still asks for a bedroom preference where one is required and the building has layouts", async () => {
|
|
@@ -585,3 +613,179 @@ it("still asks for a bedroom preference where one is required and the building h
|
|
|
585
613
|
);
|
|
586
614
|
expect(button?.disabled).to.equal(true);
|
|
587
615
|
});
|
|
616
|
+
|
|
617
|
+
it("asks to reschedule an added stop that clashes with a tour, and resends it without contact details", async () => {
|
|
618
|
+
const { bookings } = fakeBackend({
|
|
619
|
+
extensionError: {
|
|
620
|
+
status: 409,
|
|
621
|
+
code: "EXISTING_TOUR",
|
|
622
|
+
message: "You already have a tour at The Linden.",
|
|
623
|
+
},
|
|
624
|
+
});
|
|
625
|
+
const scheduler = mount();
|
|
626
|
+
|
|
627
|
+
await bookAndAddLinden(scheduler);
|
|
628
|
+
await submitWhenReady(scheduler);
|
|
629
|
+
await waitFor(() =>
|
|
630
|
+
inScheduler(scheduler, ".explanation")?.textContent?.includes(
|
|
631
|
+
"You already have a tour at The Linden."
|
|
632
|
+
)
|
|
633
|
+
);
|
|
634
|
+
clickButton(inScheduler(scheduler, "#reschedule-button"));
|
|
635
|
+
await waitFor(() => bookings.length === 3);
|
|
636
|
+
|
|
637
|
+
expect(bookings[2].cancel_existing_tours).to.equal(true);
|
|
638
|
+
expect(bookings[2]).not.to.have.property("contact");
|
|
639
|
+
await waitFor(() => inScheduler(scheduler, "booking-confirmation"));
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
for (const { code, status, message, shownIn } of [
|
|
643
|
+
{
|
|
644
|
+
code: "SLOT_TAKEN",
|
|
645
|
+
status: 409,
|
|
646
|
+
message: "The 10:30 AM tour at The Linden was just booked.",
|
|
647
|
+
shownIn: ".notice",
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
code: "INVALID_STOPS",
|
|
651
|
+
status: 404,
|
|
652
|
+
message: "Booked tour not found",
|
|
653
|
+
shownIn: "#tour-scheduler-footer .error-message",
|
|
654
|
+
},
|
|
655
|
+
]) {
|
|
656
|
+
it(`explains a ${code} on an added stop and stays on its schedule without the form`, async () => {
|
|
657
|
+
fakeBackend({ extensionError: { status, code, message } });
|
|
658
|
+
const scheduler = mount();
|
|
659
|
+
|
|
660
|
+
await bookAndAddLinden(scheduler);
|
|
661
|
+
await submitWhenReady(scheduler);
|
|
662
|
+
|
|
663
|
+
await waitFor(() =>
|
|
664
|
+
inScheduler(scheduler, shownIn)?.textContent?.includes(message)
|
|
665
|
+
);
|
|
666
|
+
expect(inScheduler(scheduler, "itinerary-editor")).not.to.equal(null);
|
|
667
|
+
expect(inScheduler(scheduler, "contact-form")).to.equal(null);
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
it("carries bedrooms, move-in and budget between the picker's filters, the form and the extension's filters", async () => {
|
|
672
|
+
const { bookings, communityQueries } = fakeBackend({ bedrooms: [1, 2] });
|
|
673
|
+
const scheduler = mount();
|
|
674
|
+
|
|
675
|
+
// The picker's filters: 2 bedrooms, a move-in date and a budget.
|
|
676
|
+
const editor = await waitFor(() =>
|
|
677
|
+
inScheduler<HTMLElement>(scheduler, "itinerary-editor")
|
|
678
|
+
);
|
|
679
|
+
editor.dispatchEvent(
|
|
680
|
+
new CustomEvent("edit-communities", { bubbles: true, composed: true })
|
|
681
|
+
);
|
|
682
|
+
const picker = await waitFor(() =>
|
|
683
|
+
inScheduler<CommunityPicker>(scheduler, "community-picker")
|
|
684
|
+
);
|
|
685
|
+
await picker.updateComplete;
|
|
686
|
+
const inPicker = <T extends Element>(selector: string) =>
|
|
687
|
+
picker.shadowRoot?.querySelector<T>(selector) ?? null;
|
|
688
|
+
const setInput = async (selector: string, value: string) => {
|
|
689
|
+
const input = inPicker<HTMLInputElement>(selector);
|
|
690
|
+
if (!input) throw new Error(`No ${selector}`);
|
|
691
|
+
input.value = value;
|
|
692
|
+
input.dispatchEvent(new Event("change"));
|
|
693
|
+
await picker.updateComplete;
|
|
694
|
+
};
|
|
695
|
+
// Each chip opens its own panel.
|
|
696
|
+
const openFilter = async (id: string) => {
|
|
697
|
+
inPicker<HTMLButtonElement>(`[aria-controls="filter-${id}"]`)?.click();
|
|
698
|
+
await picker.updateComplete;
|
|
699
|
+
};
|
|
700
|
+
await openFilter("bedrooms");
|
|
701
|
+
Array.from(
|
|
702
|
+
picker.shadowRoot?.querySelectorAll<HTMLButtonElement>(
|
|
703
|
+
"#filter-bedrooms button"
|
|
704
|
+
) ?? []
|
|
705
|
+
)
|
|
706
|
+
.find((badge) => badge.textContent?.trim() === "2 bd")
|
|
707
|
+
?.click();
|
|
708
|
+
await picker.updateComplete;
|
|
709
|
+
await openFilter("moveIn");
|
|
710
|
+
await setInput("#move-in", "2026-12-01");
|
|
711
|
+
await openFilter("budget");
|
|
712
|
+
await setInput("#max-budget", "2500");
|
|
713
|
+
const linden = await waitFor(() =>
|
|
714
|
+
Array.from(
|
|
715
|
+
picker.shadowRoot?.querySelectorAll<HTMLButtonElement>(
|
|
716
|
+
"button.floorplan-image-card"
|
|
717
|
+
) ?? []
|
|
718
|
+
).find((card) => card.textContent?.includes("The Linden"))
|
|
719
|
+
);
|
|
720
|
+
linden.click();
|
|
721
|
+
|
|
722
|
+
// The form starts from them.
|
|
723
|
+
const form = await waitFor(() =>
|
|
724
|
+
inScheduler<ContactForm>(scheduler, "contact-form")
|
|
725
|
+
);
|
|
726
|
+
expect({
|
|
727
|
+
layout: form.values.layout,
|
|
728
|
+
moveIn: form.values.moveIn,
|
|
729
|
+
}).to.deep.equal({ layout: 20, moveIn: "2026-12-01" });
|
|
730
|
+
|
|
731
|
+
// Edited on the form, they carry on to the extension's filters, with the budget.
|
|
732
|
+
await fillContactAndSubmit(scheduler, { layout: 10, moveIn: "2027-01-15" });
|
|
733
|
+
await waitFor(() => bookings.length === 1);
|
|
734
|
+
expect(bookings[0].contact?.bedrooms).to.deep.equal([1]);
|
|
735
|
+
expect(bookings[0].contact?.move_in).to.equal("2027-01-15");
|
|
736
|
+
|
|
737
|
+
const extendQuery = await waitFor(() =>
|
|
738
|
+
communityQueries.find((q) => q.has("available_after") && q.has("bedrooms"))
|
|
739
|
+
);
|
|
740
|
+
expect({
|
|
741
|
+
bedrooms: extendQuery.getAll("bedrooms"),
|
|
742
|
+
move_in: extendQuery.get("move_in"),
|
|
743
|
+
max_budget: extendQuery.get("max_budget"),
|
|
744
|
+
}).to.deep.equal({
|
|
745
|
+
bedrooms: ["1"],
|
|
746
|
+
move_in: "2027-01-15",
|
|
747
|
+
max_budget: "2500",
|
|
748
|
+
});
|
|
749
|
+
const selectQuery = communityQueries.find(
|
|
750
|
+
(q) => !q.has("available_after") && q.has("max_budget")
|
|
751
|
+
);
|
|
752
|
+
expect(selectQuery?.getAll("bedrooms")).to.deep.equal(["2"]);
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
it("closes only a filter's panel on Escape, leaving the scheduler open", async () => {
|
|
756
|
+
fakeBackend();
|
|
757
|
+
let closed = false;
|
|
758
|
+
const scheduler = mount();
|
|
759
|
+
scheduler.onCloseClicked = () => (closed = true);
|
|
760
|
+
const editor = await waitFor(() =>
|
|
761
|
+
inScheduler<HTMLElement>(scheduler, "itinerary-editor")
|
|
762
|
+
);
|
|
763
|
+
editor.dispatchEvent(
|
|
764
|
+
new CustomEvent("edit-communities", { bubbles: true, composed: true })
|
|
765
|
+
);
|
|
766
|
+
const picker = await waitFor(() =>
|
|
767
|
+
inScheduler<CommunityPicker>(scheduler, "community-picker")
|
|
768
|
+
);
|
|
769
|
+
await picker.updateComplete;
|
|
770
|
+
const chip = picker.shadowRoot?.querySelector<HTMLButtonElement>(
|
|
771
|
+
'[aria-controls="filter-budget"]'
|
|
772
|
+
);
|
|
773
|
+
chip?.click();
|
|
774
|
+
await picker.updateComplete;
|
|
775
|
+
const input = await waitFor(() =>
|
|
776
|
+
picker.shadowRoot?.querySelector<HTMLInputElement>("#max-budget")
|
|
777
|
+
);
|
|
778
|
+
|
|
779
|
+
input.dispatchEvent(
|
|
780
|
+
new KeyboardEvent("keydown", {
|
|
781
|
+
key: "Escape",
|
|
782
|
+
bubbles: true,
|
|
783
|
+
composed: true,
|
|
784
|
+
})
|
|
785
|
+
);
|
|
786
|
+
await picker.updateComplete;
|
|
787
|
+
|
|
788
|
+
expect(picker.shadowRoot?.querySelector("#max-budget")).to.equal(null);
|
|
789
|
+
expect(chip?.getAttribute("aria-expanded")).to.equal("false");
|
|
790
|
+
expect(closed).to.equal(false);
|
|
791
|
+
});
|