Merge pull request #376 from Safelite/feature/CSR-507
CSR-507 | Implement 'vehicleChangeAlert' on vehicle-damage
This commit is contained in:
commit
dd6980fd42
5 changed files with 136 additions and 54 deletions
|
|
@ -9,6 +9,7 @@ import baseMixin from "@/mixins/base-mixin";
|
||||||
import { getCookieDomainValue } from "@/helpers/heritage-integration/cookie-helper";
|
import { getCookieDomainValue } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents } from "@/constants/analytics";
|
import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents } from "@/constants/analytics";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
import { routerParams } from "@/router/router-constants/router-params";
|
||||||
|
|
||||||
// Common methods
|
// Common methods
|
||||||
export function getMountOptions(mockData) {
|
export function getMountOptions(mockData) {
|
||||||
|
|
@ -48,6 +49,7 @@ export function getMountOptions(mockData) {
|
||||||
mocks.GaLabels = GaLabels;
|
mocks.GaLabels = GaLabels;
|
||||||
mocks.GaEvents = GaEvents;
|
mocks.GaEvents = GaEvents;
|
||||||
mocks.queryStrings = queryStrings;
|
mocks.queryStrings = queryStrings;
|
||||||
|
mocks.routerParams = routerParams;
|
||||||
|
|
||||||
// Mock $store and $router when accessing this.$store/$router
|
// Mock $store and $router when accessing this.$store/$router
|
||||||
mocks.$store = mockData.store;
|
mocks.$store = mockData.store;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import { storeMutations } from "@/constants/store-mutations";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { validate } from "vee-validate";
|
import { validate } from "vee-validate";
|
||||||
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
||||||
|
import { routerParams } from "@/router/router-constants/router-params";
|
||||||
|
|
||||||
// Mock our module for promises.
|
// Mock our module for promises.
|
||||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
|
@ -703,6 +704,57 @@ describe("vehicle-damage.vue", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("vehicle-damage.vue", () => {
|
||||||
|
test("when displayVehicleChangeAlert router params is true, the alert: 'vehicleChangeAlert' should be visible", () => {
|
||||||
|
// Arrange & Act
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
mountOptionsMockData: {
|
||||||
|
route: {
|
||||||
|
params: {
|
||||||
|
[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.findComponent({ref: 'vehicleChangeAlert'}).isVisible()).toBe(true);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("vehicle-damage.vue", () => {
|
||||||
|
test("when displayVehicleChangeAlert router params is false, the alert: 'vehicleChangeAlert' should not be visible", () => {
|
||||||
|
// Arrange & Act
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
mountOptionsMockData: {
|
||||||
|
route: {
|
||||||
|
params: {
|
||||||
|
[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.findComponent({ref: 'vehicleChangeAlert'}).isVisible()).toBe(false);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("vehicle-damage.vue", () => {
|
||||||
|
test("when displayVehicleChangeAlert router params is undefined, the alert: 'vehicleChangeAlert' should not be visible", () => {
|
||||||
|
// Arrange & Act
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
mountOptionsMockData: {
|
||||||
|
route: {
|
||||||
|
params: {
|
||||||
|
[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.findComponent({ref: 'vehicleChangeAlert'}).isVisible()).toBe(false);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
// THE FOLLOWING TEST IS NOT NECESSARILY REQUIRED FOR COVERAGE
|
// THE FOLLOWING TEST IS NOT NECESSARILY REQUIRED FOR COVERAGE
|
||||||
// BUT KEEP FOR AN EXAMPLE OF A VALIDATION TEST
|
// BUT KEEP FOR AN EXAMPLE OF A VALIDATION TEST
|
||||||
//
|
//
|
||||||
|
|
@ -734,32 +786,41 @@ describe("vehicle-damage.vue", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({pageHeaderWidgetHeaderText, mountOptionsMockData}) {
|
||||||
pageHeaderWidgetHeaderText = {},
|
var pageHeaderWidgetHeaderTextDefault = {};
|
||||||
mountOptionsMockData = {
|
var mountOptionsMockDataDefault = {
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn(),
|
navigate: jest.fn(),
|
||||||
},
|
},
|
||||||
|
route: {
|
||||||
|
params: {
|
||||||
|
[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false
|
||||||
|
}
|
||||||
|
},
|
||||||
store: {
|
store: {
|
||||||
getters: {
|
getters: {
|
||||||
vehicle: {},
|
vehicle: {},
|
||||||
payment: { insuranceCoverage: { isVerified: false } },
|
payment: {
|
||||||
|
insuranceCoverage: {
|
||||||
|
isVerified: false
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
}) {
|
// Combine parameters with default values
|
||||||
|
pageHeaderWidgetHeaderText = Object.assign(pageHeaderWidgetHeaderTextDefault, pageHeaderWidgetHeaderText);
|
||||||
|
mountOptionsMockData = Object.assign(mountOptionsMockDataDefault, mountOptionsMockData);
|
||||||
//Mock api responses
|
//Mock api responses
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
baseMixin.methods.dispatchStoreAction = jest.fn();
|
||||||
const apiResponses = {
|
const apiResponses = {
|
||||||
cmsContent: {
|
cmsContent: {
|
||||||
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
|
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
|
||||||
VehicleBannerWidget: {
|
VehicleBannerWidget: {
|
||||||
GenericVehicleImage:
|
GenericVehicleImage: "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3",
|
||||||
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3",
|
|
||||||
},
|
},
|
||||||
FunnelHeaderWidget: {
|
FunnelHeaderWidget: {
|
||||||
LogoImage:
|
LogoImage: "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3",
|
||||||
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
damageOptions: {
|
damageOptions: {
|
||||||
|
|
|
||||||
|
|
@ -9,50 +9,57 @@
|
||||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||||
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage=false />
|
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage=false />
|
||||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
||||||
<damageLocationQuestion
|
<alert
|
||||||
ref="damageLocation"
|
ref="vehicleChangeAlert"
|
||||||
cmsWidgetName="DamageLocationQuestion"
|
class="mt-5 mb-0"
|
||||||
v-model="selectedDamageLocations"
|
cmsWidgetName="VehicleChangeAlert"
|
||||||
groupName="DamageLocationQuestion"
|
v-show="shouldDisplayVehicleChangeAlert"
|
||||||
/>
|
alertClass="alert-warning"
|
||||||
<windshieldOptions
|
:isDismissible="false"
|
||||||
ref="windshieldOptions"
|
/>
|
||||||
v-model="selectedWindshieldOptions"
|
<damageLocationQuestion
|
||||||
:hasRepairReplaceConflict="hasRepairReplaceConflict"
|
ref="damageLocation"
|
||||||
:hasSplitSingleConflict="hasSplitSingleConflict"
|
cmsWidgetName="DamageLocationQuestion"
|
||||||
:selectedDamageLocations="selectedDamageLocations"
|
v-model="selectedDamageLocations"
|
||||||
/>
|
groupName="DamageLocationQuestion"
|
||||||
<alert
|
/>
|
||||||
class="my-3"
|
<windshieldOptions
|
||||||
cmsWidgetName="HasReplacementConflict"
|
ref="windshieldOptions"
|
||||||
v-show="hasRepairReplaceConflict"
|
v-model="selectedWindshieldOptions"
|
||||||
alertClass="alert-danger"
|
:hasRepairReplaceConflict="hasRepairReplaceConflict"
|
||||||
:isDismissible="false"
|
:hasSplitSingleConflict="hasSplitSingleConflict"
|
||||||
/>
|
:selectedDamageLocations="selectedDamageLocations"
|
||||||
<sideDoorOptions
|
/>
|
||||||
ref="sideDoorOptions"
|
<alert
|
||||||
cmsWidgetName="SideDoorSideQuestion"
|
class="my-3"
|
||||||
groupName="SideDoorSideQuestion"
|
cmsWidgetName="HasReplacementConflict"
|
||||||
v-model="sideDoorOptionsData"
|
v-show="hasRepairReplaceConflict"
|
||||||
v-show="!hasRepairReplaceConflict"
|
alertClass="alert-danger"
|
||||||
:selectedDamageLocations="selectedDamageLocations"
|
:isDismissible="false"
|
||||||
/>
|
/>
|
||||||
<replaceOptionsQuestion
|
<sideDoorOptions
|
||||||
ref="backGlassOptions"
|
ref="sideDoorOptions"
|
||||||
cmsWidgetName="RearReplaceOptionsQuestion"
|
cmsWidgetName="SideDoorSideQuestion"
|
||||||
:isAvailable="isRearWindowDamageLocation && !hasRepairReplaceConflict"
|
groupName="SideDoorSideQuestion"
|
||||||
v-model="selectedRearReplaceOptions"
|
v-model="sideDoorOptionsData"
|
||||||
groupName="BackGlassReplaceOptionsQuestion"
|
v-show="!hasRepairReplaceConflict"
|
||||||
validationRules="replace-options-required"
|
:selectedDamageLocations="selectedDamageLocations"
|
||||||
isRequired
|
/>
|
||||||
/>
|
<replaceOptionsQuestion
|
||||||
<funnel-footer
|
ref="backGlassOptions"
|
||||||
cmsWidgetName="FunnelFooterWidget"
|
cmsWidgetName="RearReplaceOptionsQuestion"
|
||||||
:isForwardActionDisabled="!meta.valid"
|
:isAvailable="isRearWindowDamageLocation && !hasRepairReplaceConflict"
|
||||||
:isBackButtonHidden=shouldHideBackButton
|
v-model="selectedRearReplaceOptions"
|
||||||
@back-clicked="backButtonAction"
|
groupName="BackGlassReplaceOptionsQuestion"
|
||||||
@ForwardClicked="forwardButtonAction"
|
validationRules="replace-options-required"
|
||||||
/>
|
/>
|
||||||
|
<funnel-footer
|
||||||
|
cmsWidgetName="FunnelFooterWidget"
|
||||||
|
:isForwardActionDisabled="!meta.valid"
|
||||||
|
:isBackButtonHidden=shouldHideBackButton
|
||||||
|
@back-clicked="backButtonAction"
|
||||||
|
@ForwardClicked="forwardButtonAction"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -417,6 +424,9 @@ export default {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
shouldDisplayVehicleChangeAlert() {
|
||||||
|
return this.$route.params[this.routerParams.DISPLAY_VEHICLE_CHANGE_ALERT];
|
||||||
|
},
|
||||||
shouldHideBackButton(){
|
shouldHideBackButton(){
|
||||||
return this.$store.getters.payment.insuranceCoverage.isVerified;
|
return this.$store.getters.payment.insuranceCoverage.isVerified;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { storeActions } from "@/constants/store-actions.js";
|
||||||
import { storeMutations } from "@/constants/store-mutations.js";
|
import { storeMutations } from "@/constants/store-mutations.js";
|
||||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||||
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||||
|
import { routerParams } from "@/router/router-constants/router-params";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -55,6 +56,9 @@ export default {
|
||||||
vehicleCategories() {
|
vehicleCategories() {
|
||||||
return vehicleCategories;
|
return vehicleCategories;
|
||||||
},
|
},
|
||||||
|
routerParams() {
|
||||||
|
return routerParams;
|
||||||
|
},
|
||||||
queryStrings(){
|
queryStrings(){
|
||||||
return queryStrings;
|
return queryStrings;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
src/router/router-constants/router-params.js
Normal file
5
src/router/router-constants/router-params.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
const routerParams = {
|
||||||
|
DISPLAY_VEHICLE_CHANGE_ALERT: "displayVehicleChangeAlert"
|
||||||
|
};
|
||||||
|
|
||||||
|
export { routerParams };
|
||||||
Loading…
Reference in a new issue