Merge pull request #181 from Safelite/feture/DIGITAL/SSR-268-new
SSR-268
This commit is contained in:
commit
8053bcbabe
6 changed files with 78 additions and 14 deletions
|
|
@ -98,6 +98,10 @@ const endpoints = {
|
||||||
url: "/clientauth/api/v1/clientauth/validateClientTag",
|
url: "/clientauth/api/v1/clientauth/validateClientTag",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
|
IsVinbyAddressPermissible:{
|
||||||
|
url:"/vehicle/api/v1/vehicle/is-vin-by-address-permissible",
|
||||||
|
method:"Get",
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { endpoints };
|
export { endpoints };
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const VIN_LOOKUP_METHODS = Object.freeze({
|
const vinLookupMethodSelections = Object.freeze({
|
||||||
manualVin: 'ManualVin',
|
MANUALVIN: 'ManualVin',
|
||||||
licensePlate: 'LicensePlate',
|
LICENSEPLATE: 'LicensePlate',
|
||||||
homeAddress: 'HomeAddress',
|
HOMEADDRESS: 'HomeAddress',
|
||||||
});
|
});
|
||||||
|
|
||||||
export default VIN_LOOKUP_METHODS;
|
export {vinLookupMethodSelections};
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { issPageValues } from '@/router/router-constants/issPage-values';
|
||||||
import { queryStrings } from '@/constants/query-strings';
|
import { queryStrings } from '@/constants/query-strings';
|
||||||
import { GaActions } from "@/constants/analytics";
|
import { GaActions } from "@/constants/analytics";
|
||||||
import VehicleLookup from './vehicle-lookup.vue';
|
import VehicleLookup from './vehicle-lookup.vue';
|
||||||
|
import {vinLookupMethodSelections} from '@/constants/vin-lookup-methods';
|
||||||
|
|
||||||
const vinLookupMethodsMockData = {
|
const vinLookupMethodsMockData = {
|
||||||
QuestionText: 'To find the right part, let’s get your VIN. Or we can look it up for you!',
|
QuestionText: 'To find the right part, let’s get your VIN. Or we can look it up for you!',
|
||||||
|
|
@ -47,6 +48,10 @@ function setupMocks() {
|
||||||
const mockRouter = {
|
const mockRouter = {
|
||||||
navigate: jest.fn(),
|
navigate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockIsVinbyAddressPermissibleToBeFalse={
|
||||||
|
IsVinbyAddressPermissible:false,
|
||||||
|
};
|
||||||
|
|
||||||
const wrapper = mount(VehicleLookup, {
|
const wrapper = mount(VehicleLookup, {
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -95,7 +100,7 @@ function setupMocks() {
|
||||||
],
|
],
|
||||||
mocks: {
|
mocks: {
|
||||||
$route: mockRoute,
|
$route: mockRoute,
|
||||||
$router: mockRouter,
|
$router: mockRouter,
|
||||||
},
|
},
|
||||||
stubs: {
|
stubs: {
|
||||||
SiteHeader: true,
|
SiteHeader: true,
|
||||||
|
|
@ -105,10 +110,29 @@ function setupMocks() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return { mockRoute, mockRouter, wrapper };
|
return { mockRoute, mockRouter, wrapper,mockIsVinbyAddressPermissibleToBeFalse };
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('vehicle-lookup.vue', () => {
|
describe('vehicle-lookup.vue', () => {
|
||||||
|
test('IsVinbyAddressPermissible to be false', () => {
|
||||||
|
const { wrapper,mockIsVinbyAddressPermissibleToBeFalse } = setupMocks();
|
||||||
|
|
||||||
|
const vinLookupMethodsWrapper = wrapper.findComponent({ name: 'vin-lookup-methods' });
|
||||||
|
// Not using initializeComponent() because it doesn't trigger reactivity in test.
|
||||||
|
const Answers = JSON.parse(JSON.stringify(vinLookupMethodsMockData.Answers));
|
||||||
|
if(!mockIsVinbyAddressPermissibleToBeFalse.IsVinbyAddressPermissible){
|
||||||
|
Answers.splice(Answers.indexOf(vinLookupMethodSelections.HOMEADDRESS),1);
|
||||||
|
}
|
||||||
|
vinLookupMethodsWrapper.setData({
|
||||||
|
questionTextFromCms: vinLookupMethodsMockData.QuestionText,
|
||||||
|
answersFromCms: Answers,
|
||||||
|
});
|
||||||
|
|
||||||
|
const lookupByAddressOptionLabel = wrapper.find('[data-test-id="vin-lookup-methods-button-question"] label[for="VinLookupMethods-HomeAddress"]');
|
||||||
|
expect(lookupByAddressOptionLabel.exists()).toBe(false);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
test('"Continue" button is disabled when no VIN Lookup method is selected.', () => {
|
test('"Continue" button is disabled when no VIN Lookup method is selected.', () => {
|
||||||
const { wrapper } = setupMocks();
|
const { wrapper } = setupMocks();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
import { settleAllPromises } from '@/helpers/layout-helper';
|
import { settleAllPromises } from '@/helpers/layout-helper';
|
||||||
import { Form } from 'vee-validate';
|
import { Form } from 'vee-validate';
|
||||||
import BaseFormMixin from '@/mixins/base-form-mixin';
|
import BaseFormMixin from '@/mixins/base-form-mixin';
|
||||||
import VIN_LOOKUP_METHODS from '@/constants/vin-lookup-methods';
|
import {vinLookupMethodSelections} from '@/constants/vin-lookup-methods';
|
||||||
|
|
||||||
// Import Component
|
// Import Component
|
||||||
import SiteFooter from '@/iss-components/site-footer/site-footer.vue';
|
import SiteFooter from '@/iss-components/site-footer/site-footer.vue';
|
||||||
|
|
@ -98,13 +98,13 @@ export default {
|
||||||
},
|
},
|
||||||
forwardButtonAction() {
|
forwardButtonAction() {
|
||||||
switch (this.selectedVinLookupMethod) {
|
switch (this.selectedVinLookupMethod) {
|
||||||
case VIN_LOOKUP_METHODS.manualVin:
|
case vinLookupMethodSelections.MANUALVIN:
|
||||||
this.$router.navigate(this.navigationScenarios.SELECTED_MANUAL_VIN, this.$route);
|
this.$router.navigate(this.navigationScenarios.SELECTED_MANUAL_VIN, this.$route);
|
||||||
break;
|
break;
|
||||||
case VIN_LOOKUP_METHODS.licensePlate:
|
case vinLookupMethodSelections.LICENSEPLATE:
|
||||||
this.$router.navigate(this.navigationScenarios.SELECTED_LICENSE_PLATE, this.$route);
|
this.$router.navigate(this.navigationScenarios.SELECTED_LICENSE_PLATE, this.$route);
|
||||||
break;
|
break;
|
||||||
case VIN_LOOKUP_METHODS.homeAddress:
|
case vinLookupMethodSelections.HOMEADDRESS:
|
||||||
this.$router.navigate(this.navigationScenarios.SELECTED_HOME_ADDRESS, this.$route);
|
this.$router.navigate(this.navigationScenarios.SELECTED_HOME_ADDRESS, this.$route);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
import { defineRule } from 'vee-validate';
|
import { defineRule } from 'vee-validate';
|
||||||
import { required } from '@/helpers/validation-rules';
|
import { required } from '@/helpers/validation-rules';
|
||||||
import { errorMessages } from '@/constants/error-messages';
|
import { errorMessages } from '@/constants/error-messages';
|
||||||
|
import { useMainStore } from "@/store";
|
||||||
|
import {vinLookupMethodSelections} from '@/constants/vin-lookup-methods';
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
|
||||||
// Import Component
|
// Import Component
|
||||||
import ButtonQuestion from '@/digital-components/button-question/button-question.vue';
|
import ButtonQuestion from '@/digital-components/button-question/button-question.vue';
|
||||||
|
|
@ -38,6 +41,7 @@ export default {
|
||||||
required,
|
required,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['update:modelValue'],
|
emits: ['update:modelValue'],
|
||||||
components: {
|
components: {
|
||||||
ButtonQuestion,
|
ButtonQuestion,
|
||||||
|
|
@ -53,14 +57,31 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initializeComponent() {
|
async initializeComponent() {
|
||||||
|
const isVinbyAddressPermissible = await this.getIsVinbyAddressPermissible();
|
||||||
this.questionTextFromCms = this.getCmsContent(this.cmsWidgetName, 'QuestionText');
|
this.questionTextFromCms = this.getCmsContent(this.cmsWidgetName, 'QuestionText');
|
||||||
|
|
||||||
const answers = this.getCmsContent(this.cmsWidgetName, 'Answers');
|
const answers = this.getCmsContent(this.cmsWidgetName, 'Answers');
|
||||||
if (Array.isArray(answers)) {
|
if (Array.isArray(answers)) {
|
||||||
|
if(!isVinbyAddressPermissible){
|
||||||
|
answers.splice(answers.indexOf(vinLookupMethodSelections.HOMEADDRESS),1);
|
||||||
|
}
|
||||||
this.answersFromCms = answers;
|
this.answersFromCms = answers;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async getIsVinbyAddressPermissible(){
|
||||||
|
const isVinbyAddressPermissibleResponse = useMainStore().getIsVinbyAddressPermissible();
|
||||||
|
// Settle promises and get results
|
||||||
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "isVinbyAddressPermissible",
|
||||||
|
promise: isVinbyAddressPermissibleResponse,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
return resultMap.isVinbyAddressPermissible;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,22 @@ export const useMainStore = defineStore({
|
||||||
payload: {},
|
payload: {},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getIsVinbyAddressPermissible(){
|
||||||
|
try{
|
||||||
|
const response = globalMethods.callHttpClient({
|
||||||
|
method:endpoints.IsVinbyAddressPermissible.method,
|
||||||
|
endpoint:`${endpoints.IsVinbyAddressPermissible.url}?state=${this.order.customer.address.state}`,
|
||||||
|
payload: {},
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
} catch (responseError) {
|
||||||
|
return {
|
||||||
|
error: {
|
||||||
|
status: responseError.status,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
async lookupVinByPlate(licensePlate, licenseState) {
|
async lookupVinByPlate(licensePlate, licenseState) {
|
||||||
try {
|
try {
|
||||||
const response = await globalMethods.callHttpClient({
|
const response = await globalMethods.callHttpClient({
|
||||||
|
|
@ -1028,7 +1043,7 @@ export const useMainStore = defineStore({
|
||||||
resetPartsAndDependencies() {
|
resetPartsAndDependencies() {
|
||||||
this.resetGlassPartsState();
|
this.resetGlassPartsState();
|
||||||
this.updateSupportingItems(null);
|
this.updateSupportingItems(null);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
persist: true
|
persist: true
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue