@meetelise/chat 1.59.4 → 1.60.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.
@@ -159,6 +159,12 @@ export declare class TourScheduler extends LitElement {
159
159
  })[];
160
160
  renderBrokerToggle: () => TemplateResult;
161
161
  renderBrokerSection(): TemplateResult;
162
+ /**
163
+ * Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
164
+ * broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
165
+ * picked before the broker switch was turned on isn't sent.
166
+ */
167
+ showLeadSourceSelect(): boolean;
162
168
  userInfoAndLayoutMenu(): TemplateResult;
163
169
  confirmationMessage(): TemplateResult;
164
170
  /** The broker isn't the one touring: the client gets the confirmation email. */
@@ -81,6 +81,12 @@ export declare class EmailUsWindow extends LitElement {
81
81
  validateFormFields: () => void;
82
82
  onClick: () => Promise<void>;
83
83
  getNumErrors: () => number;
84
+ /**
85
+ * Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
86
+ * broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
87
+ * picked before the broker switch was turned on isn't sent.
88
+ */
89
+ showLeadSourceSelect(): boolean;
84
90
  renderBrokerToggle: () => TemplateResult;
85
91
  renderBrokerSection: () => TemplateResult;
86
92
  render: () => TemplateResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.59.4",
3
+ "version": "1.60.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -3044,7 +3044,7 @@ xmlns="http://www.w3.org/2000/svg"
3044
3044
  </div>
3045
3045
  ${this.renderBrokerToggle()}
3046
3046
  <div class="section-label">Your client</div>
3047
- `}userInfoAndLayoutMenu(){var e;const t=this.brokerIntakeEnabled&&this.isBrokerReferral;return H`<h2 class="journey-header">Your Information</h2>
3047
+ `}showLeadSourceSelect(){return!(this.brokerIntakeEnabled&&this.isBrokerReferral)&&this.leadSources.length>0&&(this.featureFlagShowDropdown===bo.always||this.featureFlagShowDropdown===bo.onAttributionFailure&&0===this.currentLeadSource.length)}userInfoAndLayoutMenu(){var e;const t=this.brokerIntakeEnabled&&this.isBrokerReferral;return H`<h2 class="journey-header">Your Information</h2>
3048
3048
  <div id="yourInformationMenu">
3049
3049
  ${t?this.renderBrokerSection():""}
3050
3050
  <div id="namesWrapper" class="namesWrapper">
@@ -3111,7 +3111,7 @@ xmlns="http://www.w3.org/2000/svg"
3111
3111
  @change=${()=>{var e;const t=(null===(e=this.selectedUnitEl)||void 0===e?void 0:e.value)||"";this.selectedUnitValue=t,t&&Eo("tourUnitSelected",{unit:t,buildingId:this.buildingId})}}
3112
3112
  >
3113
3113
  </me-select>`:""}
3114
- ${this.leadSources.length>0&&(this.featureFlagShowDropdown===bo.always||this.featureFlagShowDropdown===bo.onAttributionFailure&&0===this.currentLeadSource.length)?H` <me-select
3114
+ ${this.showLeadSourceSelect()?H` <me-select
3115
3115
  id="leadSource"
3116
3116
  value="${this.currentLeadSource}"
3117
3117
  placeholder="How did you hear about us?"
@@ -4523,7 +4523,7 @@ xmlns="http://www.w3.org/2000/svg"
4523
4523
  <div class="email-us__vertical-spacer"></div>
4524
4524
  ${this.brokerIntakeEnabled&&!this.isBrokerReferral?H`${this.renderBrokerToggle()}
4525
4525
  <div class="email-us__vertical-spacer"></div>`:""}
4526
- ${this.leadSources.length>0&&(this.featureFlagShowDropdown===bo.always||this.featureFlagShowDropdown===bo.onAttributionFailure&&0===this.currentLeadSource.length)?H`
4526
+ ${this.showLeadSourceSelect()?H`
4527
4527
  <me-select
4528
4528
  id="leadSource"
4529
4529
  placeholder="How did you hear about us?"
@@ -4555,7 +4555,7 @@ xmlns="http://www.w3.org/2000/svg"
4555
4555
 
4556
4556
  ${Vo({buildingName:this.buildingName,phoneNumberInput:this.phoneNumber,emailInput:this.email,orgLegalName:this.orgLegalName,orgSlug:this.orgSlug,country:this.country,buildingState:this.buildingState,clickingButtonText:"send"})}
4557
4557
  </details-window>
4558
- `}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.trapOverlayTab)}disconnectedCallback(){this.removeEventListener("keydown",this.trapOverlayTab),super.disconnectedCallback()}updated(){this.movedFocusInside||nu(this)&&(this.movedFocusInside=!0)}};Au.styles=[p`
4558
+ `}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.trapOverlayTab)}disconnectedCallback(){this.removeEventListener("keydown",this.trapOverlayTab),super.disconnectedCallback()}updated(){this.movedFocusInside||nu(this)&&(this.movedFocusInside=!0)}showLeadSourceSelect(){return!(this.brokerIntakeEnabled&&this.isBrokerReferral)&&this.leadSources.length>0&&(this.featureFlagShowDropdown===bo.always||this.featureFlagShowDropdown===bo.onAttributionFailure&&0===this.currentLeadSource.length)}};Au.styles=[p`
4559
4559
  .email-us__name-input,
4560
4560
  .email-us__contact_input,
4561
4561
  .email-us_message-input {
@@ -1500,6 +1500,22 @@ export class TourScheduler extends LitElement {
1500
1500
  `;
1501
1501
  }
1502
1502
 
1503
+ /**
1504
+ * Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
1505
+ * broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
1506
+ * picked before the broker switch was turned on isn't sent.
1507
+ */
1508
+ showLeadSourceSelect(): boolean {
1509
+ return (
1510
+ !(this.brokerIntakeEnabled && this.isBrokerReferral) &&
1511
+ this.leadSources.length > 0 &&
1512
+ (this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
1513
+ (this.featureFlagShowDropdown ===
1514
+ FeatureFlagsShowDropdown.onAttributionFailure &&
1515
+ this.currentLeadSource.length === 0))
1516
+ );
1517
+ }
1518
+
1503
1519
  userInfoAndLayoutMenu(): TemplateResult {
1504
1520
  const isReferral = this.brokerIntakeEnabled && this.isBrokerReferral;
1505
1521
  return html`<h2 class="journey-header">Your Information</h2>
@@ -1639,11 +1655,7 @@ export class TourScheduler extends LitElement {
1639
1655
  >
1640
1656
  </me-select>`
1641
1657
  : ""}
1642
- ${this.leadSources.length > 0 &&
1643
- (this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
1644
- (this.featureFlagShowDropdown ===
1645
- FeatureFlagsShowDropdown.onAttributionFailure &&
1646
- this.currentLeadSource.length === 0))
1658
+ ${this.showLeadSourceSelect()
1647
1659
  ? html` <me-select
1648
1660
  id="leadSource"
1649
1661
  value="${this.currentLeadSource}"
@@ -566,6 +566,22 @@ export class EmailUsWindow extends LitElement {
566
566
  ].filter((v) => v).length;
567
567
  };
568
568
 
569
+ /**
570
+ * Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
571
+ * broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
572
+ * picked before the broker switch was turned on isn't sent.
573
+ */
574
+ showLeadSourceSelect(): boolean {
575
+ return (
576
+ !(this.brokerIntakeEnabled && this.isBrokerReferral) &&
577
+ this.leadSources.length > 0 &&
578
+ (this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
579
+ (this.featureFlagShowDropdown ===
580
+ FeatureFlagsShowDropdown.onAttributionFailure &&
581
+ this.currentLeadSource.length === 0))
582
+ );
583
+ }
584
+
569
585
  renderBrokerToggle = (): TemplateResult => html`
570
586
  <label class="email-us__broker-toggle">
571
587
  <span>Are you a broker or locator?</span>
@@ -794,11 +810,7 @@ export class EmailUsWindow extends LitElement {
794
810
  ? html`${this.renderBrokerToggle()}
795
811
  <div class="email-us__vertical-spacer"></div>`
796
812
  : ""}
797
- ${this.leadSources.length > 0 &&
798
- (this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
799
- (this.featureFlagShowDropdown ===
800
- FeatureFlagsShowDropdown.onAttributionFailure &&
801
- this.currentLeadSource.length === 0))
813
+ ${this.showLeadSourceSelect()
802
814
  ? html`
803
815
  <me-select
804
816
  id="leadSource"
@@ -568,3 +568,69 @@ it("moves what a broker typed on the tour form into their own details when they
568
568
  ]);
569
569
  expect(tour.brokerEmail).to.equal("");
570
570
  });
571
+
572
+ const leadSourceFields = {
573
+ leadSources: ["Zillow", "Apartments.com"],
574
+ featureFlagShowDropdown: "always",
575
+ };
576
+
577
+ const leadSourceSelect = async (emailUs: EmailUsWindow) => {
578
+ await emailUs.updateComplete;
579
+ return emailUs.shadowRoot?.querySelector("me-select#leadSource") ?? null;
580
+ };
581
+
582
+ it("doesn't ask a broker how they heard about us; anyone else is still asked", async () => {
583
+ const emailUs = createForm({
584
+ brokerIntakeEnabled: true,
585
+ ...leadSourceFields,
586
+ });
587
+ document.body.appendChild(emailUs);
588
+
589
+ expect(await leadSourceSelect(emailUs)).not.to.equal(null);
590
+
591
+ emailUs.isBrokerReferral = true;
592
+ expect(await leadSourceSelect(emailUs)).to.equal(null);
593
+
594
+ // Broker intake off: the switch is ignored, so the question stays.
595
+ emailUs.brokerIntakeEnabled = false;
596
+ expect(await leadSourceSelect(emailUs)).not.to.equal(null);
597
+ emailUs.remove();
598
+ });
599
+
600
+ it("doesn't send a source picked before the broker switch was turned on", async () => {
601
+ const requests = captureRequests();
602
+ const emailUs = createForm({
603
+ brokerIntakeEnabled: true,
604
+ ...leadSourceFields,
605
+ });
606
+ document.body.appendChild(emailUs);
607
+ const select = (await leadSourceSelect(emailUs)) as HTMLElement & {
608
+ value?: string;
609
+ };
610
+ select.value = "Zillow";
611
+
612
+ Object.assign(emailUs, { isBrokerReferral: true, ...brokerFields });
613
+ await emailUs.updateComplete;
614
+ const submission = emailUs.onClick();
615
+ // Answer the request before asserting, so a failure can't leave the submission waiting.
616
+ requests[0]?.respond(200, { "Content-Type": "application/json" }, "{}");
617
+ await submission;
618
+
619
+ expect(requests).to.have.length(1);
620
+ const body = JSON.parse(requests[0].requestBody ?? "{}");
621
+ expect(JSON.stringify(body.lead_sources)).not.to.contain("Zillow");
622
+ emailUs.remove();
623
+ });
624
+
625
+ it("doesn't ask on the tour form either when a broker is referring a client", () => {
626
+ const asked = (fields: Record<string, unknown>) =>
627
+ createTour({ ...leadSourceFields, ...fields }).showLeadSourceSelect();
628
+
629
+ expect(asked({ brokerIntakeEnabled: true })).to.equal(true);
630
+ expect(asked({ brokerIntakeEnabled: true, isBrokerReferral: true })).to.equal(
631
+ false
632
+ );
633
+ expect(
634
+ asked({ brokerIntakeEnabled: false, isBrokerReferral: true })
635
+ ).to.equal(true);
636
+ });