@meetelise/chat 1.55.2 → 1.55.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.55.2",
3
+ "version": "1.55.3",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -4047,10 +4047,10 @@ xmlns="http://www.w3.org/2000/svg"
4047
4047
  margin: 2px 0;
4048
4048
  }
4049
4049
  }
4050
- `;class $s{constructor(e={}){var t,n,i,r,o,a;this.id=null!==(t=e.id)&&void 0!==t?t:"",this.description=null!==(n=e.description)&&void 0!==n?n:"",this.type=null!==(i=e.type)&&void 0!==i?i:"",this.rent=null!==(r=e.rent)&&void 0!==r?r:0,this.rentFrequency=null!==(o=e.rentFrequency)&&void 0!==o?o:"monthly",this.available=null!==(a=e.available)&&void 0!==a&&a,this.reservedUntil=e.reservedUntil?new Date(e.reservedUntil):void 0}}class Ss{constructor(e={}){var t,n,i,r,o;this.description=null!==(t=e.description)&&void 0!==t?t:"",this.type=null!==(n=e.type)&&void 0!==n?n:"",this.minAvailableItem=e.minAvailableItem?new $s(e.minAvailableItem):void 0,this.maxAvailableItem=e.maxAvailableItem?new $s(e.maxAvailableItem):void 0,this.allItems=(null!==(i=e.allItems)&&void 0!==i?i:[]).map(e=>new $s(e)),this.rent=null!==(r=e.rent)&&void 0!==r?r:0,this.priceDescription=null!==(o=e.priceDescription)&&void 0!==o?o:""}get displayName(){return this.description}get itemDescription(){return this.description}}var As,ks;!function(e){e.NEVER="NEVER",e.AS_NEEDED="AS_NEEDED",e.ONE_TIME="ONE_TIME",e.MONTHLY="MONTHLY",e.WEEKLY="WEEKLY",e.BI_WEEKLY="BI_WEEKLY",e.ANNUALLY="ANNUALLY",e.DAILY="DAILY"}(As||(As={})),function(e){e.Rent="Rent",e.Utility="Utility",e.ApplicationFee="ApplicationFee",e.Parking="Parking",e.Insurance="Insurance",e.Storage="Storage",e.PetFee="PetFee",e.PetRent="PetRent",e.PetDeposit="PetDeposit",e.SecurityDeposit="SecurityDeposit",e.MoveInFee="MoveInFee",e.Other="Other"}(ks||(ks={}));class Es{constructor(e={}){var t,n,i,r,o,a,s,l,u,d;this.id=null!==(t=e.id)&&void 0!==t?t:"",this.building_id=e.building_id,this.fee_name=null!==(n=e.fee_name)&&void 0!==n?n:"",this.amount=e.amount,this.amount_display=null!==(i=e.amount_display)&&void 0!==i?i:"",this.limit=null!==(r=e.limit)&&void 0!==r?r:null,this.min_estimate=e.min_estimate,this.max_estimate=e.max_estimate,this.percent_rent=e.percent_rent,this.percent_rent_min=e.percent_rent_min,this.percent_rent_max=e.percent_rent_max,this.frequency=null!==(o=e.frequency)&&void 0!==o?o:As.ONE_TIME,this.category=null!==(a=e.category)&&void 0!==a?a:ks.Other,this.description=e.description,this.additional_info=e.additional_info,this.refundable=null!==(s=e.refundable)&&void 0!==s&&s,this.hidden_reason=e.hidden_reason,this.unit_ids=e.unit_ids,this.layout_ids=e.layout_ids,this.public_facing=null===(l=e.public_facing)||void 0===l||l,this.per_applicant=null!==(u=e.per_applicant)&&void 0!==u&&u,this.required_for_quotes=null!==(d=e.required_for_quotes)&&void 0!==d&&d,this.charge_code=e.charge_code,this.bundle_key=e.bundle_key,this.external_key=e.external_key}get displayFrequency(){return this.frequency.replace(/_/g," ").toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}get isOptional(){return!this.required_for_quotes}}const Ts=class{constructor(){this.params=new URLSearchParams}addSingle(e,t){return t?(this.params.append(e,t),this):this}addArray(e,t){return t?(t.forEach(t=>{t&&this.params.append(`${e}[]`,t)}),this):this}build(){return this.params.toString()?`?${this.params.toString()}`:""}},_s=Va,Os=e=>new Es(e),Ps=e=>new Ss(e),Is=async(e,t)=>{try{const n=(new Ts).addArray("layout_ids",null==t?void 0:t.map(e=>e.toString())),i=await r().get(`${_s}/platformApi/webchat/${e}/marketable-fees?${n.build()}`);if(i.data){const e=Sr(i.data);return{fees:e.fees.map(Os),rentableItems:e.rentableItems.map(Ps),buildingIncentives:e.buildingIncentives}}}catch(t){Jo({logType:Zo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_FEES]",logData:{error:t},error:t})}return{fees:[],rentableItems:[],buildingIncentives:[]}},Ns=-1,Ms=Va,Ds=async({buildingSlug:e,unitId:t,chargeInputs:n,rentableItems:i,leaseTerm:o,moveInDate:a},s)=>{try{const l=await r().post(`${Ms}/platformApi/webchat/${e}/quote/calculate`,Ar({unitId:t,chargeInputs:n,rentableItems:i,leaseTerm:o,moveInDate:a}),{signal:s});if(l.data){return Sr(l.data)}}catch(t){const n=t;"ERR_CANCELED"!==n.code&&Jo({logType:Zo.error,buildingSlug:e,logTitle:"[ERROR_CALCULATING_QUOTE]",logData:{error:t},error:t});const i=(e=>{var t,n,i;const r=null===(n=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.detail;if(422!==(null===(i=e.response)||void 0===i?void 0:i.status)||!Array.isArray(r))return null;const o=r.map(e=>Sr(e));return o.length>0&&o.every(e=>"number"==typeof e.limit)?o:null})(n);return{quote:null,error:i?{type:"feeLimit",violations:i}:{type:"unknown"}}}return{quote:null,error:{type:"unknown"}}},Ls=(e="black")=>B`<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
4050
+ `;class $s{constructor(e={}){var t,n,i,r,o,a;this.id=null!==(t=e.id)&&void 0!==t?t:"",this.description=null!==(n=e.description)&&void 0!==n?n:"",this.type=null!==(i=e.type)&&void 0!==i?i:"",this.rent=null!==(r=e.rent)&&void 0!==r?r:0,this.rentFrequency=null!==(o=e.rentFrequency)&&void 0!==o?o:"monthly",this.available=null!==(a=e.available)&&void 0!==a&&a,this.reservedUntil=e.reservedUntil?new Date(e.reservedUntil):void 0}}class Ss{constructor(e={}){var t,n,i,r,o;this.description=null!==(t=e.description)&&void 0!==t?t:"",this.type=null!==(n=e.type)&&void 0!==n?n:"",this.minAvailableItem=e.minAvailableItem?new $s(e.minAvailableItem):void 0,this.maxAvailableItem=e.maxAvailableItem?new $s(e.maxAvailableItem):void 0,this.allItems=(null!==(i=e.allItems)&&void 0!==i?i:[]).map(e=>new $s(e)),this.rent=null!==(r=e.rent)&&void 0!==r?r:0,this.priceDescription=null!==(o=e.priceDescription)&&void 0!==o?o:""}get displayName(){return this.description}get itemDescription(){return this.description}}var As,ks;!function(e){e.NEVER="NEVER",e.AS_NEEDED="AS_NEEDED",e.ONE_TIME="ONE_TIME",e.MONTHLY="MONTHLY",e.WEEKLY="WEEKLY",e.BI_WEEKLY="BI_WEEKLY",e.ANNUALLY="ANNUALLY",e.DAILY="DAILY"}(As||(As={})),function(e){e.Rent="Rent",e.Utility="Utility",e.ApplicationFee="ApplicationFee",e.Parking="Parking",e.Insurance="Insurance",e.Storage="Storage",e.PetFee="PetFee",e.PetRent="PetRent",e.PetDeposit="PetDeposit",e.SecurityDeposit="SecurityDeposit",e.MoveInFee="MoveInFee",e.Other="Other"}(ks||(ks={}));class Es{constructor(e={}){var t,n,i,r,o,a,s,l,u,d;this.id=null!==(t=e.id)&&void 0!==t?t:"",this.building_id=e.building_id,this.fee_name=null!==(n=e.fee_name)&&void 0!==n?n:"",this.amount=e.amount,this.amount_display=null!==(i=e.amount_display)&&void 0!==i?i:"",this.limit=null!==(r=e.limit)&&void 0!==r?r:null,this.min_estimate=e.min_estimate,this.max_estimate=e.max_estimate,this.percent_rent=e.percent_rent,this.percent_rent_min=e.percent_rent_min,this.percent_rent_max=e.percent_rent_max,this.frequency=null!==(o=e.frequency)&&void 0!==o?o:As.ONE_TIME,this.category=null!==(a=e.category)&&void 0!==a?a:ks.Other,this.description=e.description,this.additional_info=e.additional_info,this.refundable=null!==(s=e.refundable)&&void 0!==s&&s,this.hidden_reason=e.hidden_reason,this.unit_ids=e.unit_ids,this.layout_ids=e.layout_ids,this.public_facing=null===(l=e.public_facing)||void 0===l||l,this.per_applicant=null!==(u=e.per_applicant)&&void 0!==u&&u,this.required_for_quotes=null!==(d=e.required_for_quotes)&&void 0!==d&&d,this.charge_code=e.charge_code,this.bundle_key=e.bundle_key,this.external_key=e.external_key}get displayFrequency(){return this.frequency.replace(/_/g," ").toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}get isOptional(){return!this.required_for_quotes}}const Ts=class{constructor(){this.params=new URLSearchParams}addSingle(e,t){return t?(this.params.append(e,t),this):this}addArray(e,t){return t?(t.forEach(t=>{t&&this.params.append(`${e}[]`,t)}),this):this}build(){return this.params.toString()?`?${this.params.toString()}`:""}},_s=Va,Os=e=>new Es(e),Ps=e=>new Ss(e),Is=async(e,t)=>{try{const n=(new Ts).addArray("layout_ids",null==t?void 0:t.map(e=>e.toString())),i=await r().get(`${_s}/platformApi/webchat/${e}/marketable-fees?${n.build()}`);if(i.data){const e=Sr(i.data);return{fees:e.fees.map(Os),rentableItems:e.rentableItems.map(Ps),buildingIncentives:e.buildingIncentives}}}catch(t){Jo({logType:Zo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_FEES]",logData:{error:t},error:t})}return{fees:[],rentableItems:[],buildingIncentives:[]}},Ns=-1,Ms=Va,Ds=async({buildingSlug:e,unitId:t,chargeInputs:n,rentableItems:i,leaseTerm:o,moveInDate:a},s)=>{try{const l=await r().post(`${Ms}/platformApi/webchat/${e}/quote/calculate`,Ar({unitId:t,chargeInputs:n,rentableItems:i,...Number.isFinite(o)?{leaseTerm:o}:{},moveInDate:a}),{signal:s});if(l.data){return Sr(l.data)}}catch(t){const n=t;"ERR_CANCELED"!==n.code&&Jo({logType:Zo.error,buildingSlug:e,logTitle:"[ERROR_CALCULATING_QUOTE]",logData:{error:t},error:t});const i=(e=>{var t,n,i;const r=null===(n=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.detail;if(422!==(null===(i=e.response)||void 0===i?void 0:i.status)||!Array.isArray(r))return null;const o=r.map(e=>Sr(e));return o.length>0&&o.every(e=>"number"==typeof e.limit)?o:null})(n);return{quote:null,error:i?{type:"feeLimit",violations:i}:{type:"unknown"}}}return{quote:null,error:{type:"unknown"}}},Ls=(e="black")=>B`<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
4051
4051
  <line x1="1.70782" y1="13.2254" x2="13.2376" y2="1.69554" stroke="${e}" stroke-width="2.13401"/>
4052
4052
  <path d="M2.00929 1.99996L13.3328 13.3421" stroke="${e}" stroke-width="2.13401"/>
4053
- </svg>`;function Rs(e){return Ji(e,"yyyy-MM-dd")}function Us(){return Rs(Ur())}const Bs=Va,js=async({buildingSlug:e,numBedrooms:t,moveInDateString:n,leaseTerm:i})=>{try{const a=(({numBedrooms:e,moveInDateString:t,leaseTerm:n})=>{const i=new Ts;return i.addArray("num_bedrooms",null==e?void 0:e.map(e=>e.toString())).addSingle("move_in_date_earliest",t).addSingle("move_in_date_latest",t).addSingle("lease_term_min",null==n?void 0:n.toString()),i.build()})({numBedrooms:t,moveInDateString:n,leaseTerm:i}),s=await r().get(`${Bs}/platformApi/webchat/${e}/units${a}`);if(s.data){const e=Sr(s.data);return o=e.map(e=>({...e,id:parseInt(e.id.toString().substring(1))})),[...o].sort((e,t)=>e.startingPrice-t.startingPrice||e.id-t.id)}}catch(r){Jo({logType:Zo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_UNITS]",logData:{error:r,params:{numBedrooms:t,moveInDateString:n,leaseTerm:i}},error:r})}var o;return[]},Fs=[ks.PetFee,ks.PetRent,ks.PetDeposit];function Hs(e){return`Up to ${e} ${1===e?"pet":"pets"} allowed`}const Gs=({color:e="#347FF7",size:t=24}={})=>B`
4053
+ </svg>`;function Rs(e){return Ji(e,"yyyy-MM-dd")}function Us(){return Rs(Ur())}const Bs=Va,js=async({buildingSlug:e,numBedrooms:t,moveInDateString:n,leaseTerm:i})=>{try{const a=(({numBedrooms:e,moveInDateString:t,leaseTerm:n})=>{const i=new Ts;return i.addArray("num_bedrooms",null==e?void 0:e.map(e=>e.toString())).addSingle("move_in_date_earliest",t).addSingle("move_in_date_latest",t).addSingle("lease_term_min",Number.isFinite(n)?null==n?void 0:n.toString():void 0),i.build()})({numBedrooms:t,moveInDateString:n,leaseTerm:i}),s=await r().get(`${Bs}/platformApi/webchat/${e}/units${a}`);if(s.data){const e=Sr(s.data);return o=e.map(e=>({...e,id:parseInt(e.id.toString().substring(1))})),[...o].sort((e,t)=>e.startingPrice-t.startingPrice||e.id-t.id)}}catch(r){Jo({logType:Zo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_UNITS]",logData:{error:r,params:{numBedrooms:t,moveInDateString:n,leaseTerm:i}},error:r})}var o;return[]},Fs=[ks.PetFee,ks.PetRent,ks.PetDeposit];function Hs(e){return`Up to ${e} ${1===e?"pet":"pets"} allowed`}const Gs=({color:e="#347FF7",size:t=24}={})=>B`
4054
4054
  <svg aria-hidden="true" focusable="false" width="${t}" height="${t}" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
4055
4055
  <g id="Frame" clip-path="url(#clip0_18718_332018)">
4056
4056
  <path id="Vector" d="M3 12.5C3 13.6819 3.23279 14.8522 3.68508 15.9442C4.13738 17.0361 4.80031 18.0282 5.63604 18.864C6.47177 19.6997 7.46392 20.3626 8.55585 20.8149C9.64778 21.2672 10.8181 21.5 12 21.5C13.1819 21.5 14.3522 21.2672 15.4442 20.8149C16.5361 20.3626 17.5282 19.6997 18.364 18.864C19.1997 18.0282 19.8626 17.0361 20.3149 15.9442C20.7672 14.8522 21 13.6819 21 12.5C21 11.3181 20.7672 10.1478 20.3149 9.05585C19.8626 7.96392 19.1997 6.97177 18.364 6.13604C17.5282 5.30031 16.5361 4.63738 15.4442 4.18508C14.3522 3.73279 13.1819 3.5 12 3.5C10.8181 3.5 9.64778 3.73279 8.55585 4.18508C7.46392 4.63738 6.47177 5.30031 5.63604 6.13604C4.80031 6.97177 4.13738 7.96392 3.68508 9.05585C3.23279 10.1478 3 11.3181 3 12.5Z" stroke="${e}" stroke-linecap="round" stroke-linejoin="round"/>
@@ -4413,7 +4413,7 @@ xmlns="http://www.w3.org/2000/svg"
4413
4413
  </p>
4414
4414
  </div>
4415
4415
  </div>
4416
- `}};Ks.styles=Vs,Ys([ue({type:Object})],Ks.prototype,"unit",void 0),Ys([ue()],Ks.prototype,"onUnitSelect",void 0),Ys([ue({type:Boolean})],Ks.prototype,"selected",void 0),Ks=Ys([se("floorplan-image-card")],Ks);var Xs=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Zs=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.layoutOptions=[],this.selectedLayoutIds=[Ns],this.units=[],this.isLoading=!1,this.isLoadingLayouts=!1,this.onSelectLayout=null,this.onUnitSelect=null,this.onMoveInDateChange=null,this.onLeaseTermChange=null,this.moveInDate=Ur(),this.leaseTerm=12,this.selectedUnit=null,this.handleUnitSelect=e=>{var t;this.selectedUnit=e,null===(t=this.onUnitSelect)||void 0===t||t.call(this,e)},this.handleLayoutChange=e=>{var t;let n;e===Ns?n=[Ns]:this.selectedLayoutIds.includes(Ns)?n=[e]:this.selectedLayoutIds.includes(e)?(n=this.selectedLayoutIds.filter(t=>t!==e),0===n.length&&(n=[Ns])):n=[...this.selectedLayoutIds,e],this.selectedLayoutIds=n,null===(t=this.onSelectLayout)||void 0===t||t.call(this,this.selectedLayoutIds)},this.handleMoveInDateChange=e=>{var t;const n=e.target.value,i=Ur();if(n){const[e,t,r]=n.split("-").map(Number),o=new Date(e,t-1,r);if($r(o,i))return;this.moveInDate=o}else this.moveInDate=i;null===(t=this.onMoveInDateChange)||void 0===t||t.call(this,n||Rs(i))},this.handleLeaseTermChange=e=>{var t;this.leaseTerm=parseInt(e.target.value),null===(t=this.onLeaseTermChange)||void 0===t||t.call(this,this.leaseTerm)},this.renderUnitSelection=()=>{var e,t;return this.isLoading?U`
4416
+ `}};Ks.styles=Vs,Ys([ue({type:Object})],Ks.prototype,"unit",void 0),Ys([ue()],Ks.prototype,"onUnitSelect",void 0),Ys([ue({type:Boolean})],Ks.prototype,"selected",void 0),Ks=Ys([se("floorplan-image-card")],Ks);var Xs=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Zs=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.layoutOptions=[],this.selectedLayoutIds=[Ns],this.units=[],this.isLoading=!1,this.isLoadingLayouts=!1,this.onSelectLayout=null,this.onUnitSelect=null,this.onMoveInDateChange=null,this.onLeaseTermChange=null,this.moveInDate=Ur(),this.leaseTerm=12,this.selectedUnit=null,this.handleUnitSelect=e=>{var t;this.selectedUnit=e,null===(t=this.onUnitSelect)||void 0===t||t.call(this,e)},this.handleLayoutChange=e=>{var t;let n;e===Ns?n=[Ns]:this.selectedLayoutIds.includes(Ns)?n=[e]:this.selectedLayoutIds.includes(e)?(n=this.selectedLayoutIds.filter(t=>t!==e),0===n.length&&(n=[Ns])):n=[...this.selectedLayoutIds,e],this.selectedLayoutIds=n,null===(t=this.onSelectLayout)||void 0===t||t.call(this,this.selectedLayoutIds)},this.handleMoveInDateChange=e=>{var t;const n=e.target.value,i=Ur();if(n){const[e,t,r]=n.split("-").map(Number),o=new Date(e,t-1,r);if($r(o,i))return;this.moveInDate=o}else this.moveInDate=i;null===(t=this.onMoveInDateChange)||void 0===t||t.call(this,n||Rs(i))},this.handleLeaseTermChange=e=>{var t;const n=parseInt(e.target.value);!Number.isInteger(n)||n<=0||(this.leaseTerm=n,null===(t=this.onLeaseTermChange)||void 0===t||t.call(this,this.leaseTerm))},this.renderUnitSelection=()=>{var e,t;return this.isLoading?U`
4417
4417
  <div class="unit-selection">
4418
4418
  <div class="image-carousel">
4419
4419
  ${Array.from({length:3},()=>U`<div class="unit-card-skeleton shimmer"></div>`)}
@@ -145,7 +145,11 @@ export class FloorPlanSelector extends LitElement {
145
145
  };
146
146
 
147
147
  handleLeaseTermChange = (e: Event): void => {
148
- this.leaseTerm = parseInt((e.target as HTMLInputElement).value);
148
+ const leaseTerm = parseInt((e.target as HTMLInputElement).value);
149
+ // Clearing the box to retype it reports an empty value (NaN).
150
+ // Keep the last valid lease term instead of reloading units mid-edit.
151
+ if (!Number.isInteger(leaseTerm) || leaseTerm <= 0) return;
152
+ this.leaseTerm = leaseTerm;
149
153
  this.onLeaseTermChange?.(this.leaseTerm);
150
154
  };
151
155
 
@@ -0,0 +1,71 @@
1
+ import { expect } from "@esm-bundle/chai";
2
+ import "../public/dist/index";
3
+ import type { FloorPlanSelector } from "./WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector";
4
+
5
+ describe("floor-plan-selector lease term", () => {
6
+ let selector: FloorPlanSelector;
7
+ let sentLeaseTerms: number[];
8
+
9
+ const getLeaseTermInput = (): HTMLInputElement => {
10
+ const input = selector.shadowRoot?.querySelector<HTMLInputElement>(
11
+ 'input[type="number"]'
12
+ );
13
+ if (!input) throw new Error("Expected lease term input");
14
+ return input;
15
+ };
16
+
17
+ const enterLeaseTerm = async (value: string): Promise<void> => {
18
+ const input = getLeaseTermInput();
19
+ input.value = value;
20
+ input.dispatchEvent(new Event("input"));
21
+ await selector.updateComplete;
22
+ };
23
+
24
+ beforeEach(async () => {
25
+ sentLeaseTerms = [];
26
+ selector = document.createElement(
27
+ "floor-plan-selector"
28
+ ) as FloorPlanSelector;
29
+ selector.onLeaseTermChange = (leaseTerm) => sentLeaseTerms.push(leaseTerm);
30
+ document.body.appendChild(selector);
31
+ await selector.updateComplete;
32
+ });
33
+
34
+ afterEach(() => {
35
+ selector.remove();
36
+ });
37
+
38
+ it("starts on the default lease term", () => {
39
+ expect(getLeaseTermInput().value).to.equal("12");
40
+ });
41
+
42
+ it("sends each lease term the prospect types", async () => {
43
+ await enterLeaseTerm("1");
44
+ await enterLeaseTerm("18");
45
+
46
+ expect(sentLeaseTerms).to.deep.equal([1, 18]);
47
+ });
48
+
49
+ it("keeps the box empty without sending anything while it is retyped", async () => {
50
+ await enterLeaseTerm("");
51
+ // A rerender, for example from new units arriving, must not refill the box.
52
+ selector.requestUpdate();
53
+ await selector.updateComplete;
54
+
55
+ expect(getLeaseTermInput().value).to.equal("");
56
+ expect(sentLeaseTerms).to.deep.equal([]);
57
+
58
+ await enterLeaseTerm("1");
59
+ await enterLeaseTerm("18");
60
+
61
+ expect(getLeaseTermInput().value).to.equal("18");
62
+ expect(sentLeaseTerms).to.deep.equal([1, 18]);
63
+ });
64
+
65
+ it("ignores lease terms below one month", async () => {
66
+ await enterLeaseTerm("0");
67
+ await enterLeaseTerm("-6");
68
+
69
+ expect(sentLeaseTerms).to.deep.equal([]);
70
+ });
71
+ });
@@ -19,7 +19,10 @@ export const buildBuildingUnitsQuery = ({
19
19
  )
20
20
  .addSingle("move_in_date_earliest", moveInDateString)
21
21
  .addSingle("move_in_date_latest", moveInDateString)
22
- .addSingle("lease_term_min", leaseTerm?.toString());
22
+ .addSingle(
23
+ "lease_term_min",
24
+ Number.isFinite(leaseTerm) ? leaseTerm?.toString() : undefined
25
+ );
23
26
 
24
27
  return queryParamBuilder.build();
25
28
  };
@@ -77,7 +77,7 @@ export const calculateQuote = async (
77
77
  unitId,
78
78
  chargeInputs,
79
79
  rentableItems,
80
- leaseTerm,
80
+ ...(Number.isFinite(leaseTerm) ? { leaseTerm } : {}),
81
81
  moveInDate,
82
82
  }),
83
83
  { signal }
@@ -16,6 +16,26 @@ it("requests units for the selected move-in date", () => {
16
16
  expect(queryString).to.include("lease_term_min=12");
17
17
  });
18
18
 
19
+ it("leaves out a lease term that is not a number", () => {
20
+ const queryString = buildBuildingUnitsQuery({
21
+ moveInDateString: "2026-08-01",
22
+ leaseTerm: NaN,
23
+ });
24
+
25
+ expect(queryString).to.include("move_in_date_earliest=2026-08-01");
26
+ expect(queryString).not.to.include("lease_term_min");
27
+ expect(queryString).not.to.include("NaN");
28
+ });
29
+
30
+ it("leaves out the lease term when none is given", () => {
31
+ const queryString = buildBuildingUnitsQuery({
32
+ moveInDateString: "2026-08-01",
33
+ });
34
+
35
+ expect(queryString).to.include("move_in_date_earliest=2026-08-01");
36
+ expect(queryString).not.to.include("lease_term_min");
37
+ });
38
+
19
39
  it("sorts the cheapest units first without mutating the API response", () => {
20
40
  const units = [
21
41
  { id: 3, startingPrice: 2699 },