@meetelise/chat 1.56.0 → 1.58.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 +8 -2
- package/dist/src/WebComponent/actions/email-us-window.d.ts +7 -1
- package/dist/src/WebComponent/actions/international-phone-input.d.ts +1 -0
- package/dist/src/WebComponent/brokerReferral.d.ts +3 -1
- package/dist/src/WebComponent/me-chat.d.ts +11 -0
- package/dist/src/main/MEChat.d.ts +12 -1
- package/package.json +1 -1
- package/public/dist/index.js +160 -135
- package/src/WebComponent/Scheduler/tour-scheduler.ts +73 -9
- package/src/WebComponent/actions/email-us-window.ts +63 -9
- package/src/WebComponent/actions/international-phone-input.ts +4 -1
- package/src/WebComponent/brokerReferral.ts +6 -1
- package/src/WebComponent/me-chat.ts +25 -4
- package/src/brokerReferralSubmission.test.ts +93 -6
- package/src/main/MEChat.ts +75 -1
- package/src/orgLevelNavigation.test.ts +114 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect } from "@esm-bundle/chai";
|
|
2
2
|
import { restore, stub, useFakeXMLHttpRequest } from "sinon/pkg/sinon-esm";
|
|
3
|
-
import "../public/dist/index";
|
|
3
|
+
import MEChat from "../public/dist/index";
|
|
4
4
|
import type MyPubnub from "./MyPubnub";
|
|
5
5
|
import type { SimpleChatMessage } from "./MyPubnub";
|
|
6
6
|
import type { PubnubChat } from "./WebComponent/pubnub-chat";
|
|
@@ -623,3 +623,116 @@ it("still opens a per-building widget's tour scheduler from its tour link", asyn
|
|
|
623
623
|
expect(widgetTakesOverClick(buildingTourLink)).to.equal(true);
|
|
624
624
|
[buildingTourLink, ...others].forEach((link) => link.remove());
|
|
625
625
|
});
|
|
626
|
+
|
|
627
|
+
// --- Org mode on an Elise Studio site ---
|
|
628
|
+
|
|
629
|
+
const STUDIO_SITE = "site-1";
|
|
630
|
+
|
|
631
|
+
const studioOrgContext = (declaredBuildingId: number | null) => ({
|
|
632
|
+
source: "elise_studio" as const,
|
|
633
|
+
siteId: STUDIO_SITE,
|
|
634
|
+
organization: "test-org",
|
|
635
|
+
sessionScope: { type: "org" as const, key: "org:test-org" },
|
|
636
|
+
declaredBuildingId,
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
const studioWidget = async (): Promise<MeChatInternals> => {
|
|
640
|
+
for (let i = 0; i < 200; i++) {
|
|
641
|
+
const meChat = document.querySelector("me-chat") as MeChatInternals | null;
|
|
642
|
+
if (meChat && !meChat.isLoading) {
|
|
643
|
+
await meChat.updateComplete;
|
|
644
|
+
return meChat;
|
|
645
|
+
}
|
|
646
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
647
|
+
}
|
|
648
|
+
throw new Error("Studio widget never finished loading");
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
it("runs a Studio site's org scope as org-level webchat, one widget across pages", async () => {
|
|
652
|
+
const requests = fakeBackend(inRollout);
|
|
653
|
+
MEChat.start({
|
|
654
|
+
studio: { siteId: STUDIO_SITE, mode: "host_managed_context" },
|
|
655
|
+
});
|
|
656
|
+
try {
|
|
657
|
+
// The homepage: no building.
|
|
658
|
+
MEChat.updateStudioContext(studioOrgContext(null));
|
|
659
|
+
const meChat = await studioWidget();
|
|
660
|
+
|
|
661
|
+
expect(initBodies(requests)).to.deep.equal([
|
|
662
|
+
{ building_slug: "", org_slug: "test-org", central_convo: true },
|
|
663
|
+
]);
|
|
664
|
+
expect(meChat.buildingSlug).to.equal(GENERAL_BUILDING);
|
|
665
|
+
expect(meChat.myPubnub?.declaredBuildingId).to.equal(null);
|
|
666
|
+
|
|
667
|
+
// A property page: same widget and conversation, with the page's building.
|
|
668
|
+
MEChat.updateStudioContext(studioOrgContext(445038));
|
|
669
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
670
|
+
|
|
671
|
+
expect(document.querySelectorAll("me-chat")).to.have.length(1);
|
|
672
|
+
expect(document.querySelector("me-chat")).to.equal(meChat);
|
|
673
|
+
expect(initBodies(requests)).to.have.length(1);
|
|
674
|
+
const message = await publishedMessage(meChat.myPubnub as MyPubnub);
|
|
675
|
+
expect(message).to.include({ declaredBuildingId: 445038 });
|
|
676
|
+
|
|
677
|
+
// Back to a page with no building.
|
|
678
|
+
MEChat.updateStudioContext(studioOrgContext(null));
|
|
679
|
+
expect(meChat.myPubnub?.declaredBuildingId).to.equal(null);
|
|
680
|
+
} finally {
|
|
681
|
+
await MEChat.remove();
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
it("swaps a Studio site's building widget for org-level webchat", async () => {
|
|
686
|
+
const requests = fakeBackend(inRollout);
|
|
687
|
+
MEChat.start({
|
|
688
|
+
studio: { siteId: STUDIO_SITE, mode: "host_managed_context" },
|
|
689
|
+
});
|
|
690
|
+
try {
|
|
691
|
+
MEChat.updateStudioContext({
|
|
692
|
+
source: "elise_studio",
|
|
693
|
+
siteId: STUDIO_SITE,
|
|
694
|
+
organization: "test-org",
|
|
695
|
+
building: "test-building",
|
|
696
|
+
sessionScope: { type: "building", key: "building:test-building" },
|
|
697
|
+
});
|
|
698
|
+
const buildingWidget = await studioWidget();
|
|
699
|
+
expect(buildingWidget.myPubnub?.centralConvo).to.not.equal(true);
|
|
700
|
+
|
|
701
|
+
MEChat.updateStudioContext(studioOrgContext(445038));
|
|
702
|
+
for (
|
|
703
|
+
let i = 0;
|
|
704
|
+
i < 100 && document.querySelector("me-chat") === buildingWidget;
|
|
705
|
+
i++
|
|
706
|
+
) {
|
|
707
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
708
|
+
}
|
|
709
|
+
const orgWidget = await studioWidget();
|
|
710
|
+
|
|
711
|
+
expect(orgWidget).to.not.equal(buildingWidget);
|
|
712
|
+
expect(document.querySelectorAll("me-chat")).to.have.length(1);
|
|
713
|
+
expect(orgWidget.myPubnub?.centralConvo).to.equal(true);
|
|
714
|
+
expect(orgWidget.myPubnub?.declaredBuildingId).to.equal(445038);
|
|
715
|
+
expect(initBodies(requests).at(-1)).to.deep.equal({
|
|
716
|
+
building_slug: "",
|
|
717
|
+
org_slug: "test-org",
|
|
718
|
+
central_convo: true,
|
|
719
|
+
});
|
|
720
|
+
} finally {
|
|
721
|
+
await MEChat.remove();
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
it("clears a Studio site's org scope without an organization", async () => {
|
|
726
|
+
fakeBackend(inRollout);
|
|
727
|
+
MEChat.start({
|
|
728
|
+
studio: { siteId: STUDIO_SITE, mode: "host_managed_context" },
|
|
729
|
+
});
|
|
730
|
+
try {
|
|
731
|
+
MEChat.updateStudioContext({ ...studioOrgContext(null), organization: "" });
|
|
732
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
733
|
+
|
|
734
|
+
expect(document.querySelector("me-chat")).to.equal(null);
|
|
735
|
+
} finally {
|
|
736
|
+
await MEChat.remove();
|
|
737
|
+
}
|
|
738
|
+
});
|