From 85b8789bcaab63d6670b92214ea0933f5b0625e8 Mon Sep 17 00:00:00 2001 From: scottkiener-at-safelite Date: Thu, 28 May 2026 11:14:28 -0400 Subject: [PATCH] CASH-2572 | Update logic and unit tests No dates should display if any of the props are missing --- src/layouts/scheduling/date-picker/date-picker.spec.js | 10 +++++----- src/layouts/scheduling/date-picker/date-picker.vue | 9 +++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/layouts/scheduling/date-picker/date-picker.spec.js b/src/layouts/scheduling/date-picker/date-picker.spec.js index f4ec21c4b..de8eb5845 100644 --- a/src/layouts/scheduling/date-picker/date-picker.spec.js +++ b/src/layouts/scheduling/date-picker/date-picker.spec.js @@ -10,7 +10,7 @@ function mountDesktop(props = {}) { value: 1024, }); return shallowMount(datePicker, { - props: { availableDates: AVAILABLE_DATES, modelValue: null, ...props }, + props: { availableDates: AVAILABLE_DATES, startDate: "2026-01-21", endDate: "2026-01-25", modelValue: null, ...props }, }); } @@ -21,7 +21,7 @@ function mountMobile(props = {}) { value: 375, }); return shallowMount(datePicker, { - props: { availableDates: AVAILABLE_DATES, modelValue: null, ...props }, + props: { availableDates: AVAILABLE_DATES, startDate: "2026-01-21", endDate: "2026-01-25", modelValue: null, ...props }, }); } @@ -145,7 +145,7 @@ describe("date-picker.vue", () => { test("goForward advances windowStart by the window size", async () => { // Use a longer range so forward is possible on desktop (window 5) const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"]; - const wrapper = mountDesktop({ availableDates: manyDates }); + const wrapper = mountDesktop({ availableDates: manyDates, startDate: "2026-01-01", endDate: "2026-01-10" }); expect(wrapper.vm.canGoForward).toBe(true); await wrapper.vm.goForward(); expect(wrapper.vm.windowStart).toBe(5); @@ -154,7 +154,7 @@ describe("date-picker.vue", () => { test("goBack decrements windowStart by the window size", async () => { const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"]; - const wrapper = mountDesktop({ availableDates: manyDates }); + const wrapper = mountDesktop({ availableDates: manyDates, startDate: "2026-01-01", endDate: "2026-01-10" }); await wrapper.vm.goForward(); await wrapper.vm.goBack(); expect(wrapper.vm.windowStart).toBe(0); @@ -181,7 +181,7 @@ describe("date-picker.vue", () => { test("back button becomes enabled after navigating forward", async () => { const manyDates = ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-10"]; - const wrapper = mountDesktop({ availableDates: manyDates }); + const wrapper = mountDesktop({ availableDates: manyDates, startDate: "2026-01-01", endDate: "2026-01-10" }); await wrapper.vm.goForward(); await wrapper.vm.$nextTick(); const backBtn = wrapper.findAll(".date-picker__nav-btn")[0]; diff --git a/src/layouts/scheduling/date-picker/date-picker.vue b/src/layouts/scheduling/date-picker/date-picker.vue index a6d3c0a7c..6b3fb7638 100644 --- a/src/layouts/scheduling/date-picker/date-picker.vue +++ b/src/layouts/scheduling/date-picker/date-picker.vue @@ -124,13 +124,10 @@ export default { allDates() { const availableSet = new Set(this.availableDates); - if (!this.availableDates.length) return []; + if (!this.availableDates.length || !this.startDate || !this.endDate) return []; - const startStr = this.startDate ?? this.availableDates[0]; - const endStr = this.endDate ?? this.availableDates[this.availableDates.length - 1]; - - const first = parseLocalDate(startStr); - const last = parseLocalDate(endStr); + const first = parseLocalDate(this.startDate); + const last = parseLocalDate(this.endDate); const dates = []; const cursor = new Date(first);