diff --git a/src/layouts/scheduling/scheduling-zip-search/scheduling-zip-search.spec.js b/src/layouts/scheduling/scheduling-zip-search/scheduling-zip-search.spec.js
new file mode 100644
index 000000000..e75a76a17
--- /dev/null
+++ b/src/layouts/scheduling/scheduling-zip-search/scheduling-zip-search.spec.js
@@ -0,0 +1,110 @@
+import { shallowMount } from "@vue/test-utils";
+import schedulingZipSearch from "./scheduling-zip-search";
+import store from "@/store";
+import {
+ getBillToAccountNumber,
+ getZipCodeData,
+} from "@/layouts/service-location/helpers/service-location-helper/service-location-helper";
+
+jest.mock("@/store", () => ({
+ dispatch: jest.fn().mockResolvedValue(null),
+}));
+
+jest.mock(
+ "@/layouts/service-location/helpers/service-location-helper/service-location-helper",
+ () => ({
+ getZipCodeData: jest.fn().mockResolvedValue({
+ state: "OH",
+ zipCodeCtu: "03357",
+ }),
+ getBillToAccountNumber: jest.fn().mockResolvedValue("87291"),
+ })
+);
+
+function mountComponent(props = {}) {
+ return shallowMount(schedulingZipSearch, {
+ props: {
+ modelValue: "43235",
+ pageNameToLog: "scheduling",
+ ...props,
+ },
+ });
+}
+
+describe("scheduling-zip-search.vue", () => {
+ test("renders serviceZipQuestion with search icon", () => {
+ const wrapper = mountComponent();
+ 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 wrapper = mountComponent({ modelValue: "" });
+ Object.defineProperty(wrapper.vm.$refs, "zipCodeSearch", {
+ configurable: true,
+ value: {
+ $refs: {
+ zipInputTextQuestion: { validate },
+ },
+ },
+ });
+
+ await wrapper.vm.onZipSearch({ preventDefault: jest.fn() });
+
+ expect(validate).toHaveBeenCalled();
+ expect(getZipCodeData).not.toHaveBeenCalled();
+ expect(wrapper.emitted("zip-searched")).toBeUndefined();
+ wrapper.unmount();
+ });
+
+ test("does not search when disabled", async () => {
+ const validate = jest.fn().mockResolvedValue({ valid: true });
+ const wrapper = mountComponent({ disabled: true });
+ Object.defineProperty(wrapper.vm.$refs, "zipCodeSearch", {
+ configurable: true,
+ value: {
+ $refs: {
+ zipInputTextQuestion: { validate },
+ },
+ },
+ });
+
+ await wrapper.vm.onZipSearch({ preventDefault: jest.fn() });
+
+ expect(validate).toHaveBeenCalled();
+ expect(getZipCodeData).not.toHaveBeenCalled();
+ wrapper.unmount();
+ });
+
+ test("saves zip info and emits billToAccountNumber when a valid zip is searched", async () => {
+ store.dispatch.mockClear();
+ const wrapper = mountComponent({ modelValue: "44101" });
+ Object.defineProperty(wrapper.vm.$refs, "zipCodeSearch", {
+ configurable: true,
+ value: {
+ $refs: {
+ zipInputTextQuestion: {
+ validate: jest.fn().mockResolvedValue({ valid: true }),
+ },
+ },
+ },
+ });
+
+ await wrapper.vm.onZipSearch({ preventDefault: jest.fn() });
+
+ expect(getZipCodeData).toHaveBeenCalledWith("44101", "scheduling");
+ expect(getBillToAccountNumber).toHaveBeenCalledWith("03357", "scheduling");
+ expect(store.dispatch).toHaveBeenCalledWith("saveServiceZipCodeInfo", {
+ zipCode: "44101",
+ state: "OH",
+ zipCodeCtu: "03357",
+ });
+ expect(wrapper.emitted("zip-searched")).toEqual([
+ [{ zipCode: "44101", billToAccountNumber: "87291" }],
+ ]);
+ wrapper.unmount();
+ });
+});
diff --git a/src/layouts/scheduling/scheduling-zip-search/scheduling-zip-search.vue b/src/layouts/scheduling/scheduling-zip-search/scheduling-zip-search.vue
new file mode 100644
index 000000000..5d462258d
--- /dev/null
+++ b/src/layouts/scheduling/scheduling-zip-search/scheduling-zip-search.vue
@@ -0,0 +1,181 @@
+
+
+
+
+
+
+
diff --git a/src/layouts/scheduling/scheduling.spec.js b/src/layouts/scheduling/scheduling.spec.js
index e221944d0..aa5cc4a78 100644
--- a/src/layouts/scheduling/scheduling.spec.js
+++ b/src/layouts/scheduling/scheduling.spec.js
@@ -9,7 +9,11 @@ jest.mock("@/store", () => ({
getters: {
order: {
serviceLocation: { zipCode: "43235", appointmentType: null },
- payment: { isInsurance: false, insuranceCoverage: { isVerified: false } },
+ payment: {
+ isInsurance: false,
+ insuranceCoverage: { isVerified: false },
+ billToAccountNumber: "12345",
+ },
referralNumber: "",
damage: { isRepair: false },
lineItems: { glassParts: [] },
@@ -181,43 +185,20 @@ describe("scheduling.vue", () => {
});
describe("service zip", () => {
- test("prefills zipSearchCode from store on mount", () => {
+ test("prefills zipSearchCode and billToAccountNumber from store on mount", () => {
const { wrapper } = setupMocks();
expect(wrapper.vm.zipSearchCode).toBe("43235");
+ expect(wrapper.vm.billToAccountNumber).toBe("12345");
wrapper.unmount();
});
- test("renders serviceZipQuestion with search icon", () => {
+ test("renders schedulingZipSearch", () => {
const { wrapper } = setupMocks();
- const zipQuestion = wrapper.find("service-zip-question-stub");
- expect(zipQuestion.exists()).toBe(true);
- expect(zipQuestion.attributes("includesearchicon")).toBeDefined();
+ expect(wrapper.find("scheduling-zip-search-stub").exists()).toBe(true);
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 () => {
+ test("reloads providers and timeslots when zip-searched is emitted", async () => {
store.dispatch.mockClear();
store.dispatch.mockImplementation((action) => {
if (action === "getProviders") {
@@ -228,9 +209,6 @@ describe("scheduling.vue", () => {
},
});
}
- if (action === "saveServiceZipCodeInfo") {
- return Promise.resolve();
- }
return Promise.resolve(null);
});
settleAllPromises.mockResolvedValueOnce({
@@ -244,22 +222,11 @@ describe("scheduling.vue", () => {
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() });
+ await wrapper.vm.onZipSearched({ zipCode: "44101", billToAccountNumber: "87291" });
const getProvidersDispatch = store.dispatch.mock.calls.find(
([actionName]) => actionName === "getProviders"
@@ -271,10 +238,7 @@ describe("scheduling.vue", () => {
pageNameToLog: undefined,
},
]);
- const saveZipDispatch = store.dispatch.mock.calls.find(
- ([actionName]) => actionName === "saveServiceZipCodeInfo"
- );
- expect(saveZipDispatch).toEqual(["saveServiceZipCodeInfo", { zipCode: "44101" }]);
+ expect(wrapper.vm.billToAccountNumber).toBe("87291");
expect(settleAllPromises).toHaveBeenCalled();
expect(wrapper.vm.datePickerKey).toBe(initialDatePickerKey + 1);
expect(wrapper.vm.selectedDate).toBeNull();
diff --git a/src/layouts/scheduling/scheduling.vue b/src/layouts/scheduling/scheduling.vue
index 71d332b5b..e5235c76d 100644
--- a/src/layouts/scheduling/scheduling.vue
+++ b/src/layouts/scheduling/scheduling.vue
@@ -11,16 +11,11 @@