From e7b062929459eec393b7d4e61a3d3a2807ce08ed Mon Sep 17 00:00:00 2001 From: Minojhini Valaiyapathi Date: Thu, 30 Jul 2026 09:44:09 -0400 Subject: [PATCH 1/9] CASH-2751 - Added service-zip --- src/layouts/scheduling/scheduling.spec.js | 106 +++++++++++ src/layouts/scheduling/scheduling.vue | 219 +++++++++++++++++++--- 2 files changed, 297 insertions(+), 28 deletions(-) diff --git a/src/layouts/scheduling/scheduling.spec.js b/src/layouts/scheduling/scheduling.spec.js index 92c869898..e221944d0 100644 --- a/src/layouts/scheduling/scheduling.spec.js +++ b/src/layouts/scheduling/scheduling.spec.js @@ -179,4 +179,110 @@ describe("scheduling.vue", () => { wrapper.unmount(); }); }); + + describe("service zip", () => { + test("prefills zipSearchCode from store on mount", () => { + const { wrapper } = setupMocks(); + expect(wrapper.vm.zipSearchCode).toBe("43235"); + wrapper.unmount(); + }); + + test("renders serviceZipQuestion with search icon", () => { + const { wrapper } = setupMocks(); + const zipQuestion = wrapper.find("service-zip-question-stub"); + expect(zipQuestion.exists()).toBe(true); + expect(zipQuestion.attributes("includesearchicon")).toBeDefined(); + wrapper.unmount(); + }); + + test("validates zip on search when field is blank", async () => { + const validate = jest.fn().mockResolvedValue({ valid: false }); + const loadSchedulingData = jest.spyOn(scheduling.methods, "loadSchedulingData"); + const { wrapper } = setupMocks(); + Object.defineProperty(wrapper.vm.$refs, "zipCodeSearch", { + configurable: true, + value: { + $refs: { + zipInputTextQuestion: { validate }, + }, + }, + }); + wrapper.vm.zipSearchCode = ""; + + await wrapper.vm.onZipSearch({ preventDefault: jest.fn() }); + + expect(validate).toHaveBeenCalled(); + expect(loadSchedulingData).not.toHaveBeenCalled(); + loadSchedulingData.mockRestore(); + wrapper.unmount(); + }); + + test("reloads providers and timeslots when a valid zip is searched", async () => { + store.dispatch.mockClear(); + store.dispatch.mockImplementation((action) => { + if (action === "getProviders") { + return Promise.resolve({ + data: { + shopProviders: [{ providerNumber: "05018" }], + mobileProviderNumber: "12345", + }, + }); + } + if (action === "saveServiceZipCodeInfo") { + return Promise.resolve(); + } + return Promise.resolve(null); + }); + settleAllPromises.mockResolvedValueOnce({ + inshopTimeSlots: { + providerTimeSlots: [ + { providerNumber: "05018", days: [{ date: "2026-07-22", timeSlots: [] }] }, + ], + }, + mobileTimeSlots: { days: [{ date: "2026-07-22", timeSlots: [] }] }, + }); + + const { wrapper } = setupMocks(); + await wrapper.setData({ isLoadingDates: false }); + Object.defineProperty(wrapper.vm.$refs, "zipCodeSearch", { + configurable: true, + value: { + $refs: { + zipInputTextQuestion: { + validate: jest.fn().mockResolvedValue({ valid: true }), + }, + }, + }, + }); + wrapper.vm.zipSearchCode = "44101"; + wrapper.vm.datePickerEndDate = "2026-08-15"; + wrapper.vm.selectedScheduling = { appointmentType: "Mobile" }; + const initialDatePickerKey = wrapper.vm.datePickerKey; + + await wrapper.vm.onZipSearch({ preventDefault: jest.fn() }); + + const getProvidersDispatch = store.dispatch.mock.calls.find( + ([actionName]) => actionName === "getProviders" + ); + expect(getProvidersDispatch).toEqual([ + "getProviders", + { + payload: { serviceZipCode: "44101" }, + pageNameToLog: undefined, + }, + ]); + const saveZipDispatch = store.dispatch.mock.calls.find( + ([actionName]) => actionName === "saveServiceZipCodeInfo" + ); + expect(saveZipDispatch).toEqual(["saveServiceZipCodeInfo", { zipCode: "44101" }]); + expect(settleAllPromises).toHaveBeenCalled(); + expect(wrapper.vm.datePickerKey).toBe(initialDatePickerKey + 1); + expect(wrapper.vm.selectedDate).toBeNull(); + expect(wrapper.vm.selectedScheduling).toBeNull(); + expect(wrapper.vm.isWaitlistRequested).toBe(false); + expect(wrapper.vm.inshopProvidersAndTimeSlots).toHaveLength(1); + expect(wrapper.vm.mobileProviderAndTimeSlot.providerNumber).toBe("12345"); + wrapper.unmount(); + }); + }); }); diff --git a/src/layouts/scheduling/scheduling.vue b/src/layouts/scheduling/scheduling.vue index bb44ee09a..71d332b5b 100644 --- a/src/layouts/scheduling/scheduling.vue +++ b/src/layouts/scheduling/scheduling.vue @@ -11,7 +11,18 @@ +