From 40bc9b9a75321b32f81b805b6abad5e9f5bb551d Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 31 Mar 2023 10:31:25 -0400 Subject: [PATCH 1/5] Completed unit tests --- .../service-location/service-location.spec.js | 79 +++++++++++++++++++ .../service-location/service-location.vue | 11 ++- src/store/index.js | 4 +- 3 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index b0a06b16f..1cea19cb9 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -323,6 +323,30 @@ describe("service-location.vue", () => { expect(wrapper.vm.mobileLocationQuestions).toStrictEqual(newMobileLocationQuestions); }); + test("resets appointment type selection when service zip code is updated by service zip modal", () => { + // Arrange + const { wrapper } = setupMocks({}); + wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); + wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn(); + + const newServiceZipCodeQuestion = { + zipCode: "61606", + state: "IL", + }; + + wrapper.vm.selectedAppointmentType = "Inshop"; + + const serviceZipCodeComponent = wrapper.findComponent({ + ref: "serviceZipCodeQuestion", + }); + + // Act + serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion); + + // Assert + expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null); + }); + test("displays military zip message when zip is updated", () => { // Arrange const { wrapper } = setupMocks({}); @@ -437,6 +461,61 @@ describe("service-location.vue", () => { // Assert expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo); }); + + test("resets appointment type selection when service zip code is updated by mobile location modal when Mobile is not selected", () => { + // Arrange + const { wrapper } = setupMocks({}); + wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); + wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn(); + + const newServiceZipCodeQuestion = { + zipCode: "61606", + state: "IL", + }; + + wrapper.vm.selectedAppointmentType = "Dropoff"; + + const serviceZipCodeComponent = wrapper.findComponent({ + ref: "serviceZipCodeQuestion", + }); + + // Act + serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion); + + // Assert + expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null); + }); + + test("does not reset appointment type selection when service zip code is updated by mobile location modal when Mobile is selected", () => { + // Arrange + const { wrapper } = setupMocks({}); + const appointmentTypeMobile = "Mobile"; + wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); + wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn(); + + const mobileLocationQuestions = { + addressQuestions: { + streetAddress: "555 Some Street", + apartmentNumberOrBusinessName: "", + city: "Westerville", + state: "OH", + zipCode: "43081", + }, + isVehicleProtected: "YesAnswer", + }; + + wrapper.vm.selectedAppointmentType = "Mobile"; + + const mobileLocationComponent = wrapper.findComponent({ + ref: "mobileLocationModalQuestions", + }); + + // Act + mobileLocationComponent.vm.$emit("update:modelValue", mobileLocationQuestions); + + // Assert + expect(wrapper.vm.selectedAppointmentType).toStrictEqual(appointmentTypeMobile); + }); }); describe("serviceability logic", () => { diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 69b4f4926..49572dbda 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -169,6 +169,7 @@ export default { set: function (newValue) { if (newValue.zipCode !== this.zipCode) { this.resetMobileLocation(); + this.selectedAppointmentType = null; } this.state = newValue.state; @@ -198,11 +199,12 @@ export default { this.isVehicleProtected = newValue.isVehicleProtected; this.mobileLocationValidationField = "isValid"; + + if ((newValue.zipCode !== this.zipCode) && !this.selectedAppointmentType == "Mobile") { + this.selectedAppointmentType = null; + } }, }, - displayMilitaryZipAlert() { - return this.zipContainsMilitaryBase && this.isServiceableMobile; - }, isServiceableMobile() { if (this.isRecalibrationServiceableMobile !== null) { return this.isGlassServiceableMobile && this.isRecalibrationServiceableMobile; @@ -217,6 +219,9 @@ export default { return this.isGlassServiceableInshop; } }, + displayMilitaryZipAlert() { + return this.zipContainsMilitaryBase && this.isServiceableMobile; + }, displayServiceableMobileOnly() { return this.isServiceableMobile && !this.isServiceableInshop; }, diff --git a/src/store/index.js b/src/store/index.js index 2dbc7b2cc..6da7550a2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -931,10 +931,10 @@ export const actions = { return globalMethods.callMockHttpClient({ method: endpoints.GetServiceabilityDetails.method, //TODO: Remove Mocky Endpoints - endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable + //endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable //endpoint: "https://run.mocky.io/v3/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInshop //endpoint: "https://run.mocky.io/v3/e2eaa097-6ea5-4906-af53-901edaa94939", // ForcedMobile - //endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options + endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options }); // TODO: Restore this when CSR-1104 is 100% complete From b06ee56d27661752574d5c4f6ba6405e2cfc19bf Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 31 Mar 2023 13:41:46 -0400 Subject: [PATCH 2/5] Prettified --- src/layouts/service-location/service-location.spec.js | 8 ++++---- src/layouts/service-location/service-location.vue | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index 1cea19cb9..28a8ca473 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -345,7 +345,7 @@ describe("service-location.vue", () => { // Assert expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null); - }); + }); test("displays military zip message when zip is updated", () => { // Arrange @@ -461,7 +461,7 @@ describe("service-location.vue", () => { // Assert expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo); }); - + test("resets appointment type selection when service zip code is updated by mobile location modal when Mobile is not selected", () => { // Arrange const { wrapper } = setupMocks({}); @@ -485,7 +485,7 @@ describe("service-location.vue", () => { // Assert expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null); }); - + test("does not reset appointment type selection when service zip code is updated by mobile location modal when Mobile is selected", () => { // Arrange const { wrapper } = setupMocks({}); @@ -515,7 +515,7 @@ describe("service-location.vue", () => { // Assert expect(wrapper.vm.selectedAppointmentType).toStrictEqual(appointmentTypeMobile); - }); + }); }); describe("serviceability logic", () => { diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 49572dbda..ac1334fcb 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -200,7 +200,10 @@ export default { this.mobileLocationValidationField = "isValid"; - if ((newValue.zipCode !== this.zipCode) && !this.selectedAppointmentType == "Mobile") { + if ( + newValue.zipCode !== this.zipCode && + !this.selectedAppointmentType == "Mobile" + ) { this.selectedAppointmentType = null; } }, From fb0280fa1820e25a3c651a4f4e09dda54036073a Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Wed, 5 Apr 2023 10:56:34 -0400 Subject: [PATCH 3/5] CSR-1129: create schedule page, put date picker on it --- jest.config.js | 3 +- src/constants/error-messages.js | 1 + .../date-picker/date-picker.vue | 473 +++++++++--------- src/router/index.js | 1 - src/router/router-constants/fmgPage-values.js | 1 + .../router-constants/navigation-scenarios.js | 3 + src/router/router-constants/routing-table.js | 13 + 7 files changed, 260 insertions(+), 235 deletions(-) diff --git a/jest.config.js b/jest.config.js index ceeb6f781..3186939df 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,9 +15,10 @@ module.exports = { "!src/layouts/vehicle-damage/windshield-options/windshield-options.vue", "!src/layouts/reveal/**/*.vue", "!src/ux-components/text-link/**/*.vue", - "!src/common-components/date-picker/**/*.vue", // Temp until unit tests completed + "!src/common-components/date-picker/**/*.vue", // git statuTemp until unit tests completed "!src/layouts/vin-lookup/**/*.vue", //Temporary for Quote page testing "!src/common-components/funnel-header/menu-modal/**/*.vue", + "!src/layouts/schedule/*.vue", // Temp test exclusion while in development // END ], // ! means exclude from coverage. testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js index 3c3f776c1..810929d20 100644 --- a/src/constants/error-messages.js +++ b/src/constants/error-messages.js @@ -26,6 +26,7 @@ const errorMessages = { OPTION_REQUIRED: "Please select an option", VEHICLE_REQUIRED: "Please select a vehicle", MOBILE_LOCATION_REQUIRED: "Please enter your service address", + DATE_REQUIRED: "Please select a date", }; export { errorMessages }; diff --git a/src/digital-components/date-picker/date-picker.vue b/src/digital-components/date-picker/date-picker.vue index e3b5ff5d1..813708b66 100644 --- a/src/digital-components/date-picker/date-picker.vue +++ b/src/digital-components/date-picker/date-picker.vue @@ -1,5 +1,5 @@