From 4b63638b6d13fb9349beeb146061b2eaa065948b Mon Sep 17 00:00:00 2001 From: hiteshkumar87 Date: Fri, 10 Mar 2023 18:36:49 +0530 Subject: [PATCH] SSR-280 added unit test cases and fixed issue related to same YMM- style different --- src/constants/vehicle-lookup-alert-types.js | 1 + .../address-lookup/address-lookup.spec.js | 37 +++++++++++++ src/layouts/address-lookup/address-lookup.vue | 45 ++++++++++++++-- .../license-plate-lookup.spec.js | 24 +++++++++ .../license-plate-lookup.vue | 47 ++++++++++++++-- .../two-identical-ymm-vehicle-alert.vue | 53 +++++++++++++++++++ .../vehicle-not-matched-alert.vue | 9 ++-- .../vin-lookup-alerts.spec.js | 14 +++++ .../vin-lookup-alerts/vin-lookup-alerts.vue | 8 +++ src/layouts/vin-lookup/vin-lookup.vue | 17 +++++- 10 files changed, 238 insertions(+), 17 deletions(-) create mode 100644 src/layouts/vin-lookup/vin-lookup-alerts/two-identical-ymm-vehicle-alert/two-identical-ymm-vehicle-alert.vue diff --git a/src/constants/vehicle-lookup-alert-types.js b/src/constants/vehicle-lookup-alert-types.js index 3bbf686e..f658876e 100644 --- a/src/constants/vehicle-lookup-alert-types.js +++ b/src/constants/vehicle-lookup-alert-types.js @@ -1,6 +1,7 @@ const vehicleLookupAlertTypes = Object.freeze({ NOT_FOUND: 'notFound', NOT_MATCHED: 'notMatched', + TWO_IDENTICAL_YMM_MATCHED:'twoIdenticalYMMMatched' }); export default vehicleLookupAlertTypes; diff --git a/src/layouts/address-lookup/address-lookup.spec.js b/src/layouts/address-lookup/address-lookup.spec.js index ae7658c5..3bc59b99 100644 --- a/src/layouts/address-lookup/address-lookup.spec.js +++ b/src/layouts/address-lookup/address-lookup.spec.js @@ -56,6 +56,43 @@ describe("address-lookup.vue", () => { ); }); + test("if the address matches two identical YMM vehicles, then display Two Identical YMM Vehicle alert", async () => { + // Arrange + const mockRegistrationAddress = { + streetAddress: "1234 Main St", + city: "Columbus", + state: "OH", + zipCode: "43215", + }; + + const { wrapper } = setupMocks({ + vinVehicles: [ + { + vehicle: { + carId: "C00000", + }, + }, + ], + }); + + useMainStore().order.vehicle.carId = "CARID2"; + + await wrapper.setData({ + customerQuestions: { + addressQuestions: mockRegistrationAddress, + }, + isTwoIdenticalYMMVehicleFound:true, + }); + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.findComponent({ ref: "alertMatchedTwoIdenticalYMMVehicle" }).isVisible()).toBe( + true + ); + }); + test("if the looking up VIN by address is not allowed in the state selected display the Vin Lookup By HomeAddress Not Allowed Alert", async () => { // Arrange const mockRegistrationAddress = { diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index ec9f5f39..cac1b274 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -29,6 +29,15 @@ :manualCopy="AlertMatchedDifferentVehicleBody" alertClass="alert-warning" v-bind:isDismissible="false" /> + { ); }); + test("If license plate matches two identical YMM vehicles, display alertMatchedTwoIdenticalYMMVehicle", async () => { + // Arrange + const mockRegistrationLicensePlate = { + licensePlate: "UTN990", + }; + + const { wrapper } = setupMocks({}); + + useMainStore().order.vehicle.carId = "TESTCARID"; + + await wrapper.setData({ + licensePlate: mockRegistrationLicensePlate, + isTwoIdenticalYMMVehicleFound:true, + }); + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.findComponent({ ref: "alertMatchedTwoIdenticalYMMVehicle" }).isVisible()).toBe( + true + ); + }); + test("If no vehicles found, display VinNotFound alert", async () => { // Arrange const mockRegistrationLicensePlate = { diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index d9afacd7..d5d652d2 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -27,6 +27,15 @@ :manualCopy="AlertMatchedDifferentVehicleBody" alertClass="alert-warning" v-bind:isDismissible="false" /> + + + + + \ No newline at end of file diff --git a/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue index 1f000e5f..171f76cb 100644 --- a/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue +++ b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue @@ -28,14 +28,12 @@ export default { body() { let year = ''; let make = ''; - let model = ''; - let style = ''; + let model = ''; if (this.vehicleFromLookup) { year = this.vehicleFromLookup.year; make = this.vehicleFromLookup.make; - model = this.vehicleFromLookup.model; - style = this.vehicleFromLookup.style; + model = this.vehicleFromLookup.model; } return ( @@ -43,8 +41,7 @@ export default { .replaceAll('{custom:damage}', getDamageString()) .replaceAll('{custom:vinlookupYear}', year) .replaceAll('{custom:vinlookupMake}', make) - .replaceAll('{custom:vinlookupModel}', model) - .replaceAll('{custom:vinlookupStyle}', style) + .replaceAll('{custom:vinlookupModel}', model) ); }, }, diff --git a/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.spec.js b/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.spec.js index e62df817..37b339af 100644 --- a/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.spec.js +++ b/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.spec.js @@ -54,4 +54,18 @@ describe('vin-lookup-alerts.vue', () => { expect(vehicleNotFoundAlert).toEqual(null); expect(vehicleNotMatchedAlert).toBeVisible(); }); + test('TwoIdenticalYMMVehicleAlert is displayed on the screen', () => { + getDamageString.mockImplementation(() => 'Mock Damage String'); + mountOptions.props = { + activeAlertType: vehicleLookupAlertTypes.TWO_IDENTICAL_YMM_MATCHED, + }; + mountOptions.global.provide = { + vehicleFromLookup: {}, + }; + + const { queryByRole } = render(VinLookupAlertsComponent, mountOptions); + const twoIdenticalYMMVehicleAlert = queryByRole('alert', { name: 'two-identical-ymm-vehicle-alert' }); + + expect(twoIdenticalYMMVehicleAlert).toBeVisible(); + }); }); diff --git a/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue b/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue index 1e6e488a..781c8688 100644 --- a/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue +++ b/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue @@ -6,6 +6,9 @@ + @@ -15,12 +18,14 @@ import vehicleLookupAlertTypes from '@/constants/vehicle-lookup-alert-types'; import vehicleNotFoundAlert from './vehicle-not-found-alert/vehicle-not-found-alert.vue'; import vehicleNotMatchedAlert from './vehicle-not-matched-alert/vehicle-not-matched-alert.vue'; +import twoIdenticalYMMVehicleAlert from './two-identical-ymm-vehicle-alert/two-identical-ymm-vehicle-alert.vue'; export default { name: 'vin-lookup-alerts', components: { vehicleNotFoundAlert, vehicleNotMatchedAlert, + twoIdenticalYMMVehicleAlert, }, props: { activeAlertType: { @@ -39,6 +44,9 @@ export default { isVehicleNotMatchedVisible() { return this.activeAlertType === vehicleLookupAlertTypes.NOT_MATCHED; }, + isTwoIdenticalYMMVehicleFoundVisible(){ + return this.activeAlertType === vehicleLookupAlertTypes.TWO_IDENTICAL_YMM_MATCHED; + }, wrapperCssClass() { return { 'mb-5': this.activeAlertType !== null, diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 1f3d663d..0f147048 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -86,6 +86,7 @@ export default { needToLookupVehicle: true, vehicleFromLookup: null, vin: null, + forwardButtonCarStyle:"", }; }, provide() { @@ -116,6 +117,11 @@ export default { this.vehicleFromLookup !== null && this.vehicleFromLookup.carId !== this.mainStore.vehicle.carId ); + }, + isTwoIdenticalYMMVehicleFound(){ + const vinYmmFound = `${this.vehicleFromLookup.year} ${this.vehicleFromLookup.make} ${this.vehicleFromLookup.model}`; + const vinYmmExpected = `${this.mainStore.order.vehicle.year} ${this.mainStore.order.vehicle.make} ${this.mainStore.order.vehicle.model}`; + return(vinYmmFound.toLowerCase()==vinYmmExpected.toLowerCase()); } }, methods: { @@ -153,9 +159,16 @@ export default { } if (this.needToLookupVehicle && this.isCarIdDifferentFromTheStore) { - this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_MATCHED; + if(this.isTwoIdenticalYMMVehicleFound){ + this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.TWO_IDENTICAL_YMM_MATCHED; + this.forwardButtonCarStyle = this.vehicleFromLookup.style; + } + else{ + this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_MATCHED; + } + - const vehicleYearMakeModelStyle = `${this.vehicleFromLookup.year} ${this.vehicleFromLookup.make} ${this.vehicleFromLookup.model} ${this.vehicleFromLookup.style}`; + const vehicleYearMakeModelStyle = `${this.vehicleFromLookup.year} ${this.vehicleFromLookup.make} ${this.vehicleFromLookup.model} ${this.forwardButtonCarStyle}`; this.$refs.siteFooter.updateButtonText(`Continue with ${vehicleYearMakeModelStyle}`); this.$refs.siteFooter.removeLoader();