@meetelise/chat 1.76.0 → 1.77.1

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.
@@ -323,6 +323,10 @@ export class CommunityPicker extends LitElement {
323
323
  const next = c.next_available;
324
324
  // Extension times are all on the day already booked.
325
325
  const sameDay = !!next && this.variant === "extend";
326
+ // Only the extend variant measures from a booked stop. The select page
327
+ // measures from the community the widget opened on, which for a group is
328
+ // a placeholder, so its distances mean nothing to the prospect.
329
+ const distance = this.variant === "extend" ? c.distance_mi : null;
326
330
  const price = c.price_from
327
331
  ? `${
328
332
  c.price_from.bedrooms === 0 ? "Studio" : `${c.price_from.bedrooms} BR`
@@ -346,7 +350,7 @@ export class CommunityPicker extends LitElement {
346
350
  /></span>`
347
351
  : ""}
348
352
  <span class="card-body">
349
- ${c.best_match || price || c.distance_mi !== null
353
+ ${c.best_match || price || distance !== null
350
354
  ? html`<span class="card-tags">
351
355
  ${c.best_match
352
356
  ? html`<span class="tag"
@@ -358,9 +362,9 @@ export class CommunityPicker extends LitElement {
358
362
  >${BadgeCheckFilledIcon(14)} ${price}</span
359
363
  >`
360
364
  : ""}
361
- ${c.distance_mi !== null
365
+ ${distance !== null
362
366
  ? html`<span class="distance"
363
- >${c.distance_mi.toFixed(1)} mi</span
367
+ >${distance.toFixed(1)} mi</span
364
368
  >`
365
369
  : ""}
366
370
  </span>`
@@ -150,7 +150,10 @@ export class ItineraryEditor extends LitElement {
150
150
  return this.planned && !this.loading;
151
151
  }
152
152
 
153
+ /** The stop whose "Change date & time" panel is open. */
153
154
  @state() private editingTimeFor: number | null = null;
155
+ /** That panel's calendar is open. */
156
+ @state() private stopDateOpen = false;
154
157
  /** The date field's calendar is open. */
155
158
  @state() private dateOpen = false;
156
159
  @state() private mobile = isMobile();
@@ -310,16 +313,157 @@ export class ItineraryEditor extends LitElement {
310
313
  ></date-picker>`;
311
314
  }
312
315
 
313
- /** One stop's own day: moving it there makes it a separate tour. */
314
- private renderStopDatePicker(stop: PlanStop): TemplateResult {
315
- return html`<div class="calendar-frame">
316
- ${this.renderDatePicker(stop.dates, isoDate(stop.start), (date) =>
317
- emit(this, "stop-date-change", { buildingId: stop.building_id, date })
318
- )}
319
- </div>`;
316
+ /**
317
+ * Closes a calendar when a day is picked, the day already chosen included,
318
+ * which the calendar reports without a date change, and focuses `trigger`.
319
+ * The calendar handles the click first, inside its own shadow root.
320
+ */
321
+ private closeOnDay(close: () => void, trigger: string) {
322
+ return (e: MouseEvent): void => {
323
+ const day = e
324
+ .composedPath()
325
+ .find(
326
+ (n) =>
327
+ n instanceof HTMLButtonElement &&
328
+ n.matches("button.dayNumber:not(:disabled)")
329
+ );
330
+ if (!day) return;
331
+ close();
332
+ this.renderRoot.querySelector<HTMLElement>(trigger)?.focus();
333
+ };
320
334
  }
321
335
 
322
- private renderTimePicker(stop: PlanStop): TemplateResult {
336
+ /**
337
+ * The panel's date field: the stop's own day, which opens the calendar
338
+ * under it. Moving the stop to another day makes it a separate tour.
339
+ */
340
+ private renderStopDateField(stop: PlanStop): TemplateResult {
341
+ const id = stop.building_id;
342
+ const date = isoDate(stop.start);
343
+ const label = formatLongDate(date);
344
+ return html`<p class="field-label" aria-hidden="true">Date</p>
345
+ <scheduler-popover
346
+ class="stop-date-popover"
347
+ ?open=${this.stopDateOpen}
348
+ ?inline=${this.mobile}
349
+ @popover-close=${() => (this.stopDateOpen = false)}
350
+ >
351
+ <button
352
+ id=${`stop-date-trigger-${id}`}
353
+ slot="trigger"
354
+ class="input picker-field"
355
+ aria-expanded=${String(this.stopDateOpen)}
356
+ aria-controls=${`stop-date-panel-${id}`}
357
+ aria-label=${`Date, ${label}`}
358
+ @click=${() => (this.stopDateOpen = !this.stopDateOpen)}
359
+ >
360
+ <span class="value">${label}</span>
361
+ ${CalendarLineIcon(14)}
362
+ </button>
363
+ <div
364
+ id=${`stop-date-panel-${id}`}
365
+ class="stop-calendar-panel"
366
+ @click=${this.closeOnDay(
367
+ () => (this.stopDateOpen = false),
368
+ `#stop-date-trigger-${id}`
369
+ )}
370
+ >
371
+ ${this.stopDateOpen
372
+ ? this.renderDatePicker(stop.dates, date, (picked) =>
373
+ emit(this, "stop-date-change", { buildingId: id, date: picked })
374
+ )
375
+ : ""}
376
+ </div>
377
+ </scheduler-popover>`;
378
+ }
379
+
380
+ /** Closes the stop's panel, and puts focus back on its button. */
381
+ private closeStopPanel(): void {
382
+ const id = this.editingTimeFor;
383
+ this.editingTimeFor = null;
384
+ this.stopDateOpen = false;
385
+ this.renderRoot
386
+ .querySelector<HTMLElement>(`.edit-time[data-building-id="${id}"]`)
387
+ ?.focus();
388
+ }
389
+
390
+ /**
391
+ * The design's "Change date & time" panel, under the stop's pencil (above
392
+ * it when there isn't room, in place on phones): the stop's date when it
393
+ * has another, then its times. Picking a time closes it.
394
+ */
395
+ private renderStopPanel(
396
+ stop: PlanStop,
397
+ canChangeDate: boolean,
398
+ canChangeTime: boolean
399
+ ): TemplateResult {
400
+ const id = stop.building_id;
401
+ const open = this.editingTimeFor === id;
402
+ const name = this.name(id);
403
+ return html`<scheduler-popover
404
+ class="stop-popover"
405
+ fit
406
+ ?open=${open}
407
+ ?inline=${this.mobile}
408
+ @popover-close=${() => {
409
+ // Another stop's pencil opens its own panel before this one hears it.
410
+ if (this.editingTimeFor !== id) return;
411
+ this.editingTimeFor = null;
412
+ this.stopDateOpen = false;
413
+ }}
414
+ >
415
+ <button
416
+ slot="trigger"
417
+ class="icon-button edit-time"
418
+ data-building-id=${id}
419
+ title=${canChangeDate ? "Change date & time" : "Change time"}
420
+ aria-expanded=${String(open)}
421
+ aria-controls=${`stop-panel-${id}`}
422
+ aria-label=${`Change the ${
423
+ canChangeDate ? "date or time" : "time"
424
+ } at ${name}`}
425
+ @click=${() => {
426
+ this.editingTimeFor = open ? null : id;
427
+ this.stopDateOpen = false;
428
+ }}
429
+ >
430
+ ${PencilLineIcon(12)}
431
+ </button>
432
+ <div
433
+ id=${`stop-panel-${id}`}
434
+ class="stop-panel"
435
+ role="group"
436
+ aria-label=${`Date and time at ${name}`}
437
+ >
438
+ ${open && canChangeDate ? this.renderStopDateField(stop) : ""}
439
+ ${
440
+ // While /plan answers, these are the old plan's times, which may
441
+ // be on the stop's old day.
442
+ open && canChangeTime && !this.loading
443
+ ? html`<p
444
+ id=${`stop-time-label-${id}`}
445
+ class="field-label time-label"
446
+ >
447
+ Time (${getTimezoneAbbreviation(stop.timezone)})
448
+ </p>
449
+ <div
450
+ class="stop-times"
451
+ role="group"
452
+ aria-labelledby=${`stop-time-label-${id}`}
453
+ >
454
+ ${this.renderTimePicker(stop, () => this.closeStopPanel())}
455
+ </div>`
456
+ : ""
457
+ }
458
+ </div>
459
+ </scheduler-popover>`;
460
+ }
461
+
462
+ /** A stop's times; `picked` runs once one is picked, the chosen one included. */
463
+ private renderTimePicker(
464
+ stop: PlanStop,
465
+ picked: () => void = () => undefined
466
+ ): TemplateResult {
323
467
  const times = [...new Set([stop.start, ...stop.alternatives])].sort();
324
468
  return html`<time-picker
325
469
  outlined
@@ -328,15 +472,16 @@ export class ItineraryEditor extends LitElement {
328
472
  .options=${times.map(timeOption)}
329
473
  .defaultSelectedTime=${timeOption(stop.start)}
330
474
  @change=${(e: Event) => {
331
- const picked = (e.target as TimePicker).selectedTime;
332
- if (!picked) {
475
+ const time = (e.target as TimePicker).selectedTime;
476
+ if (!time) {
333
477
  // A second click unselects, but every stop needs a time: hand the
334
478
  // picker this stop's time again, which it selects when none is.
335
479
  (e.target as TimePicker).defaultSelectedTime = timeOption(stop.start);
480
+ picked();
336
481
  return;
337
482
  }
338
- const start = `${picked.dateWithTimeZoneOffset.datetime}${picked.dateWithTimeZoneOffset.offset}`;
339
- this.editingTimeFor = null;
483
+ const start = `${time.dateWithTimeZoneOffset.datetime}${time.dateWithTimeZoneOffset.offset}`;
484
+ picked();
340
485
  if (start !== stop.start) {
341
486
  emit(this, "stop-time-change", {
342
487
  buildingId: stop.building_id,
@@ -365,19 +510,6 @@ export class ItineraryEditor extends LitElement {
365
510
  */
366
511
  private renderDateField(): TemplateResult {
367
512
  const label = this.date ? formatLongDate(this.date) : "Select a date";
368
- // The calendar handles the click first, inside its own shadow root.
369
- const closeOnDay = (e: MouseEvent) => {
370
- const day = e
371
- .composedPath()
372
- .find(
373
- (n) =>
374
- n instanceof HTMLButtonElement &&
375
- n.matches("button.dayNumber:not(:disabled)")
376
- );
377
- if (!day) return;
378
- this.dateOpen = false;
379
- this.renderRoot.querySelector<HTMLElement>("#date-trigger")?.focus();
380
- };
381
513
  return html`<h2 id="date-heading" class="section-heading">Date</h2>
382
514
  <scheduler-popover
383
515
  class="date-popover"
@@ -399,7 +531,14 @@ export class ItineraryEditor extends LitElement {
399
531
  >
400
532
  ${CalendarLineIcon(14)}
401
533
  </button>
402
- <div id="date-panel" class="calendar-panel" @click=${closeOnDay}>
534
+ <div
535
+ id="date-panel"
536
+ class="calendar-panel"
537
+ @click=${this.closeOnDay(
538
+ () => (this.dateOpen = false),
539
+ "#date-trigger"
540
+ )}
541
+ >
403
542
  ${this.renderDatePicker()}
404
543
  </div>
405
544
  </scheduler-popover>
@@ -423,7 +562,6 @@ export class ItineraryEditor extends LitElement {
423
562
  const community = this.communities.get(stop.building_id);
424
563
  const ids = this.newStopIds();
425
564
  const newIndex = ids.indexOf(stop.building_id);
426
- const editing = this.editingTimeFor === stop.building_id;
427
565
  const canReorder = !stop.fixed && ids.length > 1;
428
566
  // With no other day or time to pick, they're plain text rather than a picker.
429
567
  const canChangeTime =
@@ -499,35 +637,16 @@ export class ItineraryEditor extends LitElement {
499
637
  ${community?.name ?? ""}
500
638
  </p>
501
639
  <p class="subtitle">${formatAddress(community?.address ?? null)}</p>
502
- ${!canChangeTime && !canChangeDate
503
- ? html`<p class="stop-time">
504
- ${time}
505
- ${stop.fixed ? html`<span class="sr-only">, booked</span>` : ""}
506
- </p>`
507
- : html`<button
508
- class="stop-time edit-time"
509
- aria-expanded=${String(editing)}
510
- aria-label=${`Change the ${
511
- canChangeDate ? "date or time" : "time"
512
- } at ${community?.name ?? ""}`}
513
- @click=${() =>
514
- (this.editingTimeFor = editing ? null : stop.building_id)}
515
- >
516
- ${time} ${PencilLineIcon(12)}
517
- </button>`}
518
- ${editing && canChangeDate ? this.renderStopDatePicker(stop) : ""}
519
- ${
520
- // While /plan answers, these are the old plan's times, which may
521
- // be on the stop's old day.
522
- editing && canChangeTime && !this.loading
523
- ? html`<div class="stop-times">
524
- ${this.renderTimePicker(stop)}
525
- <p class="subtitle">
526
- Times in ${getTimezoneAbbreviation(stop.timezone)}
527
- </p>
528
- </div>`
529
- : ""
530
- }
640
+ <div class="stop-time">
641
+ <span
642
+ >${time}${stop.fixed
643
+ ? html`<span class="sr-only">, booked</span>`
644
+ : ""}</span
645
+ >
646
+ ${canChangeTime || canChangeDate
647
+ ? this.renderStopPanel(stop, canChangeDate, canChangeTime)
648
+ : ""}
649
+ </div>
531
650
  </div>
532
651
  ${stop.fixed
533
652
  ? html`<span class="booked-mark">${CheckCircleLineIcon(18, 1)}</span>`
@@ -722,27 +841,96 @@ export class ItineraryEditor extends LitElement {
722
841
  opacity: 0.85;
723
842
  }
724
843
 
844
+ /* A stop's time, then its pencil; on phones its panel opens under both. */
845
+ .stop-card .stop-time {
846
+ display: flex;
847
+ flex-wrap: wrap;
848
+ gap: 4px;
849
+ }
850
+
725
851
  .edit-time {
726
- background: none;
727
- border: none;
728
- color: inherit;
729
- cursor: pointer;
730
- font: inherit;
731
- font-size: 12px;
852
+ color: var(--tsv2-placeholder);
853
+ height: 16px;
732
854
  padding: 0;
855
+ position: relative;
856
+ width: 16px;
857
+ }
858
+
859
+ /* A 32px target around the 16px pencil. */
860
+ .edit-time::after {
861
+ content: "";
862
+ inset: -8px;
863
+ position: absolute;
864
+ }
865
+
866
+ .edit-time:hover {
867
+ color: var(--tsv2-text);
868
+ }
869
+
870
+ /* The design's 360px panel: 16px in, 6px from the pencil. */
871
+ .stop-popover {
872
+ --scheduler-popover-gap: 6px;
873
+ --scheduler-popover-padding: 16px;
874
+ }
875
+
876
+ /* As tall as the pencil, so the panel's 6px are from the pencil itself. */
877
+ .stop-popover:not([inline]) {
878
+ display: flex;
733
879
  }
734
880
 
735
- .edit-time svg {
736
- color: var(--tsv2-muted);
881
+ .stop-panel {
882
+ width: 326px;
737
883
  }
738
884
 
739
- .stop-card .calendar-frame,
885
+ .stop-panel > .time-label:not(:first-child) {
886
+ margin-top: 16px;
887
+ }
888
+
889
+ /* Four rows of times, scrolling into the panel's bottom padding. */
740
890
  .stop-times {
741
- margin-top: 12px;
891
+ margin-bottom: -16px;
892
+ max-height: 160px;
893
+ overflow-y: auto;
894
+ padding-bottom: 16px;
895
+ scrollbar-width: none;
742
896
  }
743
897
 
744
- .stop-times .subtitle {
745
- margin-top: 6px;
898
+ .stop-times::-webkit-scrollbar {
899
+ display: none;
900
+ }
901
+
902
+ /* The panel's calendar floats 16px under its date field, as wide. */
903
+ .stop-date-popover {
904
+ display: block;
905
+ --scheduler-popover-gap: 16px;
906
+ --scheduler-popover-padding: 12px;
907
+ }
908
+
909
+ .stop-date-popover .picker-field[aria-expanded="true"] {
910
+ border-color: var(--tsv2-accent);
911
+ }
912
+
913
+ .stop-calendar-panel {
914
+ width: 300px;
915
+ }
916
+
917
+ .stop-popover[inline] .stop-panel {
918
+ margin-top: 8px;
919
+ width: 100%;
920
+ }
921
+
922
+ .stop-popover[inline] .stop-times {
923
+ margin-bottom: 0;
924
+ max-height: none;
925
+ padding-bottom: 0;
926
+ }
927
+
928
+ .stop-date-popover[inline] .stop-calendar-panel {
929
+ border: 1px solid var(--tsv2-line);
930
+ border-radius: 8px;
931
+ margin-top: 8px;
932
+ padding: 12px;
933
+ width: auto;
746
934
  }
747
935
 
748
936
  .booked-mark {
@@ -1,5 +1,27 @@
1
- import { css, html, LitElement, TemplateResult } from "lit";
2
- import { customElement, property } from "lit/decorators.js";
1
+ import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
2
+ import { customElement, property, state } from "lit/decorators.js";
3
+ import { classMap } from "lit/directives/class-map.js";
4
+ import { styleMap } from "lit/directives/style-map.js";
5
+
6
+ /** The nearest box that clips `el`, across shadow roots: its scroller, or the window. */
7
+ const clippingBox = (
8
+ el: Element
9
+ ): { top: number; right: number; bottom: number; left: number } => {
10
+ const up = (n: Element): Element | null =>
11
+ n.assignedSlot ??
12
+ n.parentElement ??
13
+ ((n.getRootNode() as ShadowRoot).host || null);
14
+ for (let n = up(el); n; n = up(n)) {
15
+ const { overflowX, overflowY } = getComputedStyle(n);
16
+ if (overflowX !== "visible" || overflowY !== "visible") {
17
+ return n.getBoundingClientRect();
18
+ }
19
+ }
20
+ return { top: 0, right: innerWidth, bottom: innerHeight, left: 0 };
21
+ };
22
+
23
+ /** The room the design leaves between a fitted panel and its scroller's edge. */
24
+ const EDGE = 8;
3
25
 
4
26
  /**
5
27
  * A trigger and the small panel it opens, for the v2 scheduler's secondary
@@ -10,6 +32,10 @@ import { customElement, property } from "lit/decorators.js";
10
32
  * `inline` (phones) it opens in place instead, after its siblings in the
11
33
  * parent's flex row, as the filter row always did there.
12
34
  *
35
+ * With `fit`, the panel stays inside the scroller it opens in, as the
36
+ * design's per-stop panel does: above the trigger when there isn't room
37
+ * under it, and moved left when it would run past the right edge.
38
+ *
13
39
  * The parent owns `open`; the element asks for a close with `popover-close`.
14
40
  * Slot the trigger as `slot="trigger"` and the panel's content in the default
15
41
  * slot, so the trigger's `aria-controls` can name an id in the parent's tree.
@@ -22,6 +48,49 @@ export class SchedulerPopover extends LitElement {
22
48
  @property({ type: Boolean, reflect: true })
23
49
  inline = false;
24
50
 
51
+ /** Keep the panel inside its scroller (see above). Off, it always opens below. */
52
+ @property({ type: Boolean })
53
+ fit = false;
54
+
55
+ /** With `fit`, where the open panel sits; null until it has been measured. */
56
+ @state() private placement: { above: boolean; shift: number } | null = null;
57
+
58
+ /** It opens, or a phone turns into a wider screen with it open. */
59
+ private opening(changed: PropertyValues<this>): boolean {
60
+ return this.open && (changed.has("open") || changed.has("inline"));
61
+ }
62
+
63
+ protected willUpdate(changed: PropertyValues<this>): void {
64
+ if (this.opening(changed)) this.placement = null;
65
+ }
66
+
67
+ protected updated(changed: PropertyValues<this>): void {
68
+ if (this.opening(changed) && this.fit && !this.inline) {
69
+ // After the panel's own elements have rendered, before it is shown.
70
+ requestAnimationFrame(() => this.place());
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Opens the panel above its trigger only when it fits there and not below:
76
+ * what runs past the scroller's foot can be scrolled to, but not its top.
77
+ */
78
+ private place(): void {
79
+ const panel = this.renderRoot.querySelector<HTMLElement>(".panel");
80
+ if (!this.open || !panel) return;
81
+ const box = clippingBox(this);
82
+ const trigger = this.getBoundingClientRect();
83
+ const below = panel.getBoundingClientRect();
84
+ const gap = below.top - trigger.bottom;
85
+ const roomBelow = box.bottom - trigger.bottom;
86
+ const roomAbove = trigger.top - box.top;
87
+ const needed = gap + below.height;
88
+ const above = roomBelow < needed && roomAbove >= needed;
89
+ const overflow = below.right - (box.right - EDGE);
90
+ const shift = Math.max(0, Math.min(overflow, below.left - box.left - EDGE));
91
+ this.placement = { above, shift };
92
+ }
93
+
25
94
  connectedCallback(): void {
26
95
  super.connectedCallback();
27
96
  document.addEventListener("click", this.onDocumentClick);
@@ -69,8 +138,24 @@ export class SchedulerPopover extends LitElement {
69
138
  };
70
139
 
71
140
  render(): TemplateResult {
141
+ const fitted = this.fit && !this.inline;
72
142
  return html`<slot name="trigger"></slot>
73
- <div class="panel" ?hidden=${!this.open}><slot></slot></div>`;
143
+ <div
144
+ class=${classMap({
145
+ panel: true,
146
+ measuring: fitted && !this.placement,
147
+ above: fitted && !!this.placement?.above,
148
+ })}
149
+ style=${styleMap({
150
+ left:
151
+ fitted && this.placement?.shift
152
+ ? `${-this.placement.shift}px`
153
+ : undefined,
154
+ })}
155
+ ?hidden=${!this.open}
156
+ >
157
+ <slot></slot>
158
+ </div>`;
74
159
  }
75
160
 
76
161
  static styles = css`
@@ -91,7 +176,7 @@ export class SchedulerPopover extends LitElement {
91
176
  box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.13);
92
177
  box-sizing: border-box;
93
178
  left: 0;
94
- margin-top: 8px;
179
+ margin-top: var(--scheduler-popover-gap, 8px);
95
180
  padding: var(--scheduler-popover-padding, 11px);
96
181
  position: absolute;
97
182
  top: 100%;
@@ -99,6 +184,17 @@ export class SchedulerPopover extends LitElement {
99
184
  z-index: 20;
100
185
  }
101
186
 
187
+ /* With fit: laid out, unseen, for a frame while it is measured. */
188
+ .panel.measuring {
189
+ visibility: hidden;
190
+ }
191
+
192
+ .panel.above {
193
+ bottom: 100%;
194
+ margin: 0 0 var(--scheduler-popover-gap, 8px);
195
+ top: auto;
196
+ }
197
+
102
198
  :host([inline]) .panel {
103
199
  background: none;
104
200
  border: none;
@@ -722,6 +722,7 @@ export class TourSchedulerV2 extends LitElement {
722
722
  phone_e164: values.phoneE164 ?? "",
723
723
  bedrooms: bedroomsOf(values.layouts),
724
724
  move_in: values.moveIn || null,
725
+ max_budget: this.preferences.maxBudget,
725
726
  notes: values.notes.trim(),
726
727
  },
727
728
  attribution: buildAttribution({
@@ -145,6 +145,8 @@ export interface BookingContact {
145
145
  phone_e164: string;
146
146
  bedrooms: number[];
147
147
  move_in: string | null;
148
+ /** The budget filter the prospect set, saved as their max budget. */
149
+ max_budget: number | null;
148
150
  notes: string;
149
151
  }
150
152
 
@@ -0,0 +1,51 @@
1
+ import { expect } from "@esm-bundle/chai";
2
+ import "../public/dist/index";
3
+ import type { ContactForm } from "./WebComponent/SchedulerV2/contact-form";
4
+
5
+ declare const it: (name: string, callback: () => Promise<void>) => void;
6
+
7
+ // isValidEmail, through the v2 scheduler's contact form, one of its callers:
8
+ // the form flags an email it rejects.
9
+ const flagged = async (email: string): Promise<boolean> => {
10
+ const form = document.createElement("contact-form") as ContactForm;
11
+ form.values = { ...form.values, email };
12
+ document.body.appendChild(form);
13
+ await form.updateComplete;
14
+ const shown = !!form.shadowRoot?.querySelector(".error-message");
15
+ form.remove();
16
+ return shown;
17
+ };
18
+
19
+ it("accepts emails whose top-level domain is two or more letters", async () => {
20
+ for (const email of [
21
+ "jane@example.com",
22
+ "jane@example.co",
23
+ "brittney.ciesa+tc17@onmicrosoft.com",
24
+ "first.last@mail.sub.example.co.uk",
25
+ "jane@example.museum",
26
+ "jane@example.photography",
27
+ "o'brien_99@example-mail.io",
28
+ "jane@例え.テスト",
29
+ "jane@xn--80ak6aa92e.xn--p1ai",
30
+ "JANE@EXAMPLE.COM",
31
+ ]) {
32
+ expect(await flagged(email), email).to.equal(false);
33
+ }
34
+ });
35
+
36
+ it("rejects a one-letter or non-letter top-level domain, and what it rejected before", async () => {
37
+ for (const email of [
38
+ "brittney.ciesa+tc17@onmicrosoft.c",
39
+ "jane@example.c",
40
+ "jane@example.1",
41
+ "jane@example.c0m",
42
+ "jane@example.com.",
43
+ "jane@example",
44
+ "jane.example.com",
45
+ "jane@@example.com",
46
+ "jane doe@example.com",
47
+ "@example.com",
48
+ ]) {
49
+ expect(await flagged(email), email).to.equal(true);
50
+ }
51
+ });