Final eslint baseline PR linting 9 !

This commit is contained in:
DavidAtSafelite 2023-08-28 08:59:37 -04:00
parent f5686b9862
commit 8c6842ca55
89 changed files with 1275 additions and 826 deletions

View file

@ -18,8 +18,8 @@ module.exports = {
'vue/attribute-hyphenation': ['warn', 'never'],
'vue/v-on-event-hyphenation': ['warn', 'never'],
'object-curly-newline': ['error', { consistent: true }],
'function-paren-newline': ['error', 'never'],
'operator-linebreak': ['error', 'before', { overrides: { '=': 'after' }}],
'function-paren-newline': ['error', 'multiline'],
'operator-linebreak': ['error', 'before', { overrides: { '=': 'after' } }],
'implicit-arrow-linebreak': ['off'],
'comma-dangle': ['error', 'never'],
indent: ['error', 4, { SwitchCase: 1 }],

View file

@ -27,6 +27,7 @@ const errorMessages = Object.freeze({
SERVICE_ZIP_FORMAT: 'Please enter a valid service ZIP',
VIN_REQUIRED: 'Please enter your VIN',
VIN_FORMAT:
// eslint-disable-next-line max-len
'Invalid VIN. Please make sure that you entered the correct 17-digit, alpha-numeric number. VINs do not contain the letters I, O, or Q',
OPTION_REQUIRED: 'Please select an option',
VEHICLE_REQUIRED: 'Please select a vehicle',

View file

@ -50,9 +50,11 @@ export default {
};
const { handleChange, meta, errors } =
useField(toRef(props, 'groupName'),
useField(
toRef(props, 'groupName'),
toRef(props, 'validationRules'),
fieldOptions);
fieldOptions
);
return {
handleChange,

View file

@ -62,8 +62,10 @@ describe('buttonQuestion.vue', () => {
describe('selectedValues', () => {
test('is radio => should emit captured value', async () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
setupMocks({ propsData: { groupName: 'group-name' } }));
const wrapper = shallowMount(
buttonQuestion,
setupMocks({ propsData: { groupName: 'group-name' } })
);
await wrapper.setProps({
answers: ['2022', '2021', '2020'],
isMultiSelect: false,
@ -78,8 +80,10 @@ describe('buttonQuestion.vue', () => {
});
test('is checkbox => should emit captured value', async () => {
const wrapper = shallowMount(buttonQuestion,
setupMocks({ propsData: { groupName: 'group-name' } }));
const wrapper = shallowMount(
buttonQuestion,
setupMocks({ propsData: { groupName: 'group-name' } })
);
await wrapper.setProps({
answers: ['2022', '2021', '2020'],
isMultiSelect: false,
@ -104,7 +108,8 @@ describe('buttonQuestion.vue', () => {
describe('buttonLabel', () => {
test('answers have buttonLabel properties => buttonsInfo buttonsLabel properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -116,7 +121,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -128,7 +134,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Text properties, no buttonLabel properties => buttonsInfo buttonsLabel properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -140,7 +147,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -152,7 +160,8 @@ describe('buttonQuestion.vue', () => {
test('answers have buttonLabel and Text properties => buttonsInfo buttonsLabel properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -166,7 +175,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -178,12 +188,14 @@ describe('buttonQuestion.vue', () => {
test('answers is an array of strings => buttonLabel is answer values', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: ['answer 1', 'answer 2']
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -197,7 +209,8 @@ describe('buttonQuestion.vue', () => {
describe('altText', () => {
test('answers have altText properties => buttonsInfo altText properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -209,7 +222,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -221,7 +235,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Name properties, no buttonLabel properties => buttonsInfo altText properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -233,7 +248,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -245,7 +261,8 @@ describe('buttonQuestion.vue', () => {
test('answers have altText and Name properties => buttonsInfo altText properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -259,7 +276,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -271,12 +289,14 @@ describe('buttonQuestion.vue', () => {
test('answers is an array of strings => altText is answer values', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: ['answer 1', 'answer 2']
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -290,7 +310,8 @@ describe('buttonQuestion.vue', () => {
describe('buttonLabelSubCopy', () => {
test('answers have buttonLabelSubCopy properties => buttonsInfo buttonLabelSubCopy properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -302,7 +323,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -314,7 +336,8 @@ describe('buttonQuestion.vue', () => {
test('answers have SubText properties, no buttonLabelSubCopy properties => buttonsInfo buttonLabelSubCopy properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -326,7 +349,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -338,7 +362,8 @@ describe('buttonQuestion.vue', () => {
test('answers have buttonLabelSubCopy and SubText properties => buttonsInfo buttonLabelSubCopy properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -352,7 +377,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -364,12 +390,14 @@ describe('buttonQuestion.vue', () => {
test('answers is an array of strings => there are no buttonLabelSubCopy properties', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: ['answer 1', 'answer 2']
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -383,7 +411,8 @@ describe('buttonQuestion.vue', () => {
describe('buttonImage', () => {
test('answers have buttonImage properties => buttonsInfo buttonImage properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -395,7 +424,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -407,7 +437,8 @@ describe('buttonQuestion.vue', () => {
test('answers have AnswerImageUrl properties, no buttonImage properties => buttonsInfo buttonImage properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -419,7 +450,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -431,7 +463,8 @@ describe('buttonQuestion.vue', () => {
test('answers have buttonImage and AnswerImageUrl properties => buttonsInfo buttonImage properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -445,7 +478,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -457,12 +491,14 @@ describe('buttonQuestion.vue', () => {
test('answers is an array of strings => there are no buttonImage properties', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: ['answer 1', 'answer 2']
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -476,7 +512,8 @@ describe('buttonQuestion.vue', () => {
describe('buttonImageId', () => {
test('answers have buttonImageId properties => buttonsInfo buttonImageId properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -488,7 +525,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -500,7 +538,8 @@ describe('buttonQuestion.vue', () => {
test('answers have ImageId properties, no buttonImageId properties => buttonsInfo buttonImage properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -512,7 +551,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -524,7 +564,8 @@ describe('buttonQuestion.vue', () => {
test('answers have buttonImageId and ImageId properties => buttonsInfo buttonImageId properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: [
@ -538,7 +579,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -550,12 +592,14 @@ describe('buttonQuestion.vue', () => {
test('answers is an array of strings => there are no buttonImageId properties', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: ['answer 1', 'answer 2']
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -568,16 +612,19 @@ describe('buttonQuestion.vue', () => {
describe('groupName', () => {
const answers = [[['answer 1', 'answer 2']], [[{ value: 1 }, { value: 2 }]]];
test.each(answers)('answers have groupName properties with spaces => buttonsInfo groupName properties are correct',
test.each(answers)(
'answers have groupName properties with spaces => buttonsInfo groupName properties are correct',
(answerGroup) => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: answerGroup,
groupName: 'this is my group name'
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -585,18 +632,22 @@ describe('buttonQuestion.vue', () => {
// Assert
expect(buttonsInfo[0].groupName).toEqual('this-is-my-group-name');
expect(buttonsInfo[1].groupName).toEqual('this-is-my-group-name');
});
}
);
test.each(answers)('answers have groupName properties with no spaces => buttonsInfo groupName properties are correct',
test.each(answers)(
'answers have groupName properties with no spaces => buttonsInfo groupName properties are correct',
(answerGroup) => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
answers: answerGroup,
groupName: 'this-is-my-group-name'
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -604,14 +655,16 @@ describe('buttonQuestion.vue', () => {
// Assert
expect(buttonsInfo[0].groupName).toEqual('this-is-my-group-name');
expect(buttonsInfo[1].groupName).toEqual('this-is-my-group-name');
});
}
);
});
describe('value', () => {
describe('useTextForValue is true', () => {
test('answers have value properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
@ -624,7 +677,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -636,7 +690,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Text properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
@ -649,7 +704,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -661,7 +717,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Name properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
@ -674,7 +731,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -686,7 +744,8 @@ describe('buttonQuestion.vue', () => {
test('answers have value and Text properties, no Name properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
@ -701,7 +760,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -713,7 +773,8 @@ describe('buttonQuestion.vue', () => {
test('answers have value and Name properties, no Text properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
@ -728,7 +789,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -740,7 +802,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Text and Name properties, no value properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
@ -755,7 +818,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -767,7 +831,8 @@ describe('buttonQuestion.vue', () => {
test('answers have value, Text, and Name properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
@ -784,7 +849,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -796,13 +862,15 @@ describe('buttonQuestion.vue', () => {
test('answers is an array of strings => buttonInfo value property values are values from array', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: true,
answers: ['answer 1', 'answer 2']
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -816,7 +884,8 @@ describe('buttonQuestion.vue', () => {
describe('useTextForValue is false', () => {
test('answers have value properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
@ -829,7 +898,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -841,7 +911,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Text properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
@ -854,7 +925,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -866,7 +938,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Name properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
@ -879,7 +952,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -891,7 +965,8 @@ describe('buttonQuestion.vue', () => {
test('answers have value and Text properties, no Name properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
@ -906,7 +981,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -918,7 +994,8 @@ describe('buttonQuestion.vue', () => {
test('answers have value and Name properties, no Text properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
@ -933,7 +1010,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -945,7 +1023,8 @@ describe('buttonQuestion.vue', () => {
test('answers have Text and Name properties, no value properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
@ -960,7 +1039,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -972,7 +1052,8 @@ describe('buttonQuestion.vue', () => {
test('answers have value, Text, and Name properties => buttonsInfo value properties are correct', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
@ -989,7 +1070,8 @@ describe('buttonQuestion.vue', () => {
}
]
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;
@ -1001,13 +1083,15 @@ describe('buttonQuestion.vue', () => {
test('answers is an array of strings => buttonInfo value property values are values from array', () => {
// Arrange
const wrapper = shallowMount(buttonQuestion,
const wrapper = shallowMount(
buttonQuestion,
setupMocks({
propsData: {
useTextForValue: false,
answers: ['answer 1', 'answer 2']
}
}));
})
);
// Act
const { buttonsInfo } = wrapper.vm;

View file

@ -84,15 +84,8 @@ export default {
initialValue
};
const { errorMessage,
handleChange,
handleBlur,
validate,
errors,
resetField } =
useField(props.inputId,
props.validationRules,
fieldOptions);
const { errorMessage, handleChange, handleBlur, validate, errors, resetField } =
useField(props.inputId, props.validationRules, fieldOptions);
return {
errorMessage,

View file

@ -131,9 +131,8 @@ export default {
};
// eslint-disable-next-line no-shadow
const { errorMessage, handleBlur, handleChange, meta, validate, errors } = useField(props.inputId,
props.validationRules,
fieldOptions);
const { errorMessage, handleBlur, handleChange, meta, validate, errors } =
useField(props.inputId, props.validationRules, fieldOptions);
return {
errorMessage,

View file

@ -7,44 +7,45 @@ import { GaCategories, GaActions, GaLabels } from '@/constants/analytics';
import headerKeys from '@/constants/header-keys';
export default {
callHttpClient({ method, endpoint, payload, logApiCall = true}) {
callHttpClient({ method, endpoint, payload, logApiCall = true }) {
return new Promise((resolve, reject) => {
const store = useMainStore();
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: 'SelfService' });
const payloadAndAnalyticsData = { ...payload, AppName: 'SelfService' };
const headers = {
[headerKeys.EXPERIMENT]: JSON.stringify(store.experimentSettings)
};
axios({
method: method,
axios({
method,
url: cfDistroUrl + endpoint,
data: payloadAndAnalyticsData,
crossDomain: true,
responseType: 'json',
headers: headers,
headers
})
.then((response) => {
if (logApiCall) {
analyticsMixIn.methods.pushEventToGA(
GaCategories.API_RESPONSE,
GaActions.RESULT,
`${GaLabels.SUCCESS}_${endpoint}`,
true
);
}
return resolve(response);
},
error => {
console.error(error);
.then(
(response) => {
if (logApiCall) {
analyticsMixIn.methods.pushEventToGA(
GaCategories.API_RESPONSE,
GaActions.RESULT,
`${GaLabels.SUCCESS}_${endpoint}`,
true
);
}
return resolve(response);
},
(error) => {
window.console.error(error);
// implement if analytics service is down
if (endpoint.includes('analytics')) {
return resolve({data: ''});
}
// implement if analytics service is down
if (endpoint.includes('analytics')) {
return resolve({ data: '' });
}
return reject(error.response);
}
return reject(error.response);
}
);
});
},
@ -52,19 +53,18 @@ export default {
// used for mocked services
async mockCallHttpClient(method, endpoint) {
return new Promise((resolve, reject) => {
axios({
method: method,
axios({
method,
url: endpoint,
crossDomain: true,
responseType: {}
})
.then((response) => {
return resolve(response);
},
error => {
console.error(error);
return reject(error.response);
}
.then(
(response) => resolve(response),
(error) => {
window.console.error(error);
return reject(error.response);
}
);
});
}

View file

@ -7,10 +7,54 @@ import { getMountOptions } from '@/helpers/unit-test-helper.js';
jest.mock('axios');
jest.mock('@/mixins/analytics-mixin');
/** @ignore */
function setupMocksForHttpClient({
endpoint = null,
isError = false,
additionalData = null
}) {
// Clear node module
axios.mockClear();
getMountOptions();
// Success Response
const response = {
status: 200,
data: {
message: 'Success',
additionalData
}
};
// Error Response
const error = {
response: {
status: 500,
data: {
message: 'Error',
additionalData
}
}
};
// Error interceptor on Axios returns a different object, so we need to mimic that.
if (isError) {
axios.mockRejectedValue(error);
} else {
axios.mockResolvedValue(response);
}
return {
endpoint,
logApiCall: true
};
}
it('Global Methods - Call Http Client - Should Resolve Promise', () => {
// Arrange
const endpoint = 'https://mock.safelite.com';
const httpArgs = setupMocksForHttpClient({ endpoint: endpoint });
const httpArgs = setupMocksForHttpClient({ endpoint });
// Act
globalMethods.callHttpClient(httpArgs).then((response) => {
@ -25,7 +69,7 @@ it('Global Methods - Call Http Client - Should Reject Promise', () => {
// Arrange
const endpoint = 'https://mock.safelite.com';
const httpArgs = setupMocksForHttpClient({
endpoint: endpoint,
endpoint,
isError: true
});
analyticsMixIn.methods.pushEventToGA = jest.fn();
@ -38,46 +82,3 @@ it('Global Methods - Call Http Client - Should Reject Promise', () => {
expect(err.status).toEqual(500);
});
});
function setupMocksForHttpClient({
endpoint = null,
isError = false,
additionalData = null
}) {
// Clear node module
axios.mockClear();
const mountOptions = getMountOptions();
// Success Response
const response = {
status: 200,
data: {
message: 'Success',
additionalData: additionalData
}
};
// Error Response
const error = {
response: {
status: 500,
data: {
message: 'Error',
additionalData: additionalData
}
}
};
// Error interceptor on Axios returns a different object, so we need to mimic that.
if (isError) {
axios.mockRejectedValue(error);
} else {
axios.mockResolvedValue(response);
}
return {
endpoint: endpoint,
logApiCall: true
};
}

View file

@ -4,11 +4,10 @@ const validateISSClientTag = (clientTag) => {
const store = useMainStore();
return store.validateClientTag(clientTag)
.then((response) =>
// Success
response,
// Error
() => null);
.then(
(response) => response,
() => null
);
};
export default validateISSClientTag;

View file

@ -55,8 +55,11 @@ export function getCookieDomainValue() {
Used to create a cookie.
`useDefaultISSCookieAttributes` will set the path and domain to our defaults
*/
function createOrUpdateCookie(key, value = '',
{ useDefaultISSCookieAttributes = true, maxAge, isSecure = true }) {
function createOrUpdateCookie(
key,
value = '',
{ useDefaultISSCookieAttributes = true, maxAge, isSecure = true }
) {
let cookieToAdd = `${key}=${value}; `;
if (useDefaultISSCookieAttributes) {
@ -188,8 +191,10 @@ export function updateSessionIdCookie() {
createOrUpdateCookie(cookieNames.SESSION_ID, getSessionIdValue(), { maxAge: 60 * 30 });
}
export function setCookieProperties(properties,
{ useDefaultISSCookieAttributes = true, maxAge, isSecure }) {
export function setCookieProperties(
properties,
{ useDefaultISSCookieAttributes = true, maxAge, isSecure }
) {
if (typeof properties === 'object') {
Object.keys(properties).forEach((key) => {
createOrUpdateCookie(key, properties[key], {

View file

@ -26,8 +26,10 @@ describe('event-bus.js', () => {
useMainStore().eventBusItem.mockReturnValueOnce(event);
// TODO: Use or remove
const eventValue = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND);
const eventValue = eventBus.readAndPopEventFromBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND
);
expect(useMainStore().eventBusItem).toBeCalledTimes(1);
expect(useMainStore().removeEventFromBus).toBeCalledTimes(1);
@ -37,8 +39,10 @@ describe('event-bus.js', () => {
useMainStore().eventBusItem.mockReturnValueOnce(undefined);
// TODO: Use or remove
const eventValue = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND);
const eventValue = eventBus.readAndPopEventFromBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND
);
expect(useMainStore().eventBusItem).toBeCalledTimes(1);
expect(useMainStore().removeEventFromBus).toBeCalledTimes(0);
@ -47,17 +51,21 @@ describe('event-bus.js', () => {
it('returns event from bus', () => {
useMainStore().eventBusItem.mockReturnValueOnce(event);
const eventValue = eventBus.readEventFromBus(globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND);
const eventValue = eventBus.readEventFromBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND
);
expect(eventValue).toBe(event);
});
it('Reads event from bus, should have event value.', () => {
// Arrange / Act
eventBus.addEventToBus(globalEvents.Categories.GLOBAL_ALERT,
eventBus.addEventToBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND,
event);
event
);
expect(useMainStore().addEventToBus).toHaveBeenCalled();
});

View file

@ -9,10 +9,14 @@ import { required, regex } from '@/helpers/validation-rules';
function defineGlobalNameRules() {
defineRule(globalRules.FIRST_NAME_REQUIRED, required(errorMessages.FIRST_NAME_REQUIRED));
defineRule(globalRules.LAST_NAME_REQUIRED, required(errorMessages.LAST_NAME_REQUIRED));
defineRule(globalRules.POLICYHOLDER_FIRST_NAME_REQUIRED,
required(errorMessages.POLICYHOLDER_FIRST_NAME_REQUIRED));
defineRule(globalRules.POLICYHOLDER_LAST_NAME_REQUIRED,
required(errorMessages.POLICYHOLDER_LAST_NAME_REQUIRED));
defineRule(
globalRules.POLICYHOLDER_FIRST_NAME_REQUIRED,
required(errorMessages.POLICYHOLDER_FIRST_NAME_REQUIRED)
);
defineRule(
globalRules.POLICYHOLDER_LAST_NAME_REQUIRED,
required(errorMessages.POLICYHOLDER_LAST_NAME_REQUIRED)
);
}
/**
@ -20,9 +24,13 @@ function defineGlobalNameRules() {
*/
function defineGlobalEmailRules() {
defineRule(globalRules.EMAIL_ADDRESS_REQUIRED, required(errorMessages.EMAIL_ADDRESS_REQUIRED));
defineRule(globalRules.EMAIL_ADDRESS_FORMAT,
regex(/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/,
errorMessages.EMAIL_ADDRESS_FORMAT));
defineRule(
globalRules.EMAIL_ADDRESS_FORMAT,
regex(
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/,
errorMessages.EMAIL_ADDRESS_FORMAT
)
);
}
/**
@ -30,9 +38,13 @@ function defineGlobalEmailRules() {
*/
function defineGlobalPhoneNumberRules() {
defineRule(globalRules.PHONE_NUMBER_REQUIRED, required(errorMessages.PHONE_NUMBER_REQUIRED));
defineRule(globalRules.PHONE_NUMBER_FORMAT,
regex(/^(\([0-9]{3}\)|[0-9]{3}) *[-.]? *[0-9]{3} *[-.]? *[0-9]{4}$/,
errorMessages.PHONE_NUMBER_FORMAT));
defineRule(
globalRules.PHONE_NUMBER_FORMAT,
regex(
/^(\([0-9]{3}\)|[0-9]{3}) *[-.]? *[0-9]{3} *[-.]? *[0-9]{4}$/,
errorMessages.PHONE_NUMBER_FORMAT
)
);
}
/**

View file

@ -1,4 +1,4 @@
export function settleAllPromises(promiseResultMap) {
const settleAllPromises = (promiseResultMap) => {
// Pull our keys out of the promise 'table'
const promiseNames = Object.entries(promiseResultMap);
@ -22,4 +22,6 @@ export function settleAllPromises(promiseResultMap) {
return resultMap;
});
}
};
export default settleAllPromises;

View file

@ -1,4 +1,4 @@
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
it('layout-helper: Should settle all promises and return mapped promise results', () => {
// Arrange

View file

@ -1,11 +1,13 @@
import { useMainStore } from '@/store';
export async function getServiceabilityDetails(serviceZipCode, lineItems) {
const serviceabilityDetails = await useMainStore().getServiceabilityDetails({
serviceZipCode,
lineItems
},
false);
const serviceabilityDetails = await useMainStore().getServiceabilityDetails(
{
serviceZipCode,
lineItems
},
false
);
return Promise.resolve(serviceabilityDetails);
}

View file

@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import { RouterLinkStub } from '@vue/test-utils';
import { createTestingPinia } from '@pinia/testing';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
@ -59,7 +60,9 @@ export function getMountOptions(mockData) {
// Heritage integration common methods
export const cookies = {
[cookieNames.ISS_SESSION_INFO]: '{"ReferralNumber":"1566818","ReferralDate":"2022-03-15T10:56:24.597","ReferralCorrelationId":"404d2b04-f86e-45c3-b373-127b6217b060","ShouldResetState":false}',
[cookieNames.ISS_SESSION_INFO]:
// eslint-disable-next-line max-len
'{"ReferralNumber":"1566818","ReferralDate":"2022-03-15T10:56:24.597","ReferralCorrelationId":"404d2b04-f86e-45c3-b373-127b6217b060","ShouldResetState":false}',
UNIQUE_SESSION_ID: '33756020-b58e-4ec7-b8b8-3f1576719c40',
anotherCookie: '{}',
someOtherCookie: '{}',

View file

@ -311,7 +311,8 @@ describe('address-questions.vue', () => {
describe('alerts', () => {
const places = [null, { address_components: null }, undefined, {}];
test.each(places)('selected place/place properties is null => display verification alert',
test.each(places)(
'selected place/place properties is null => display verification alert',
async (place) => {
// Arrange
const { wrapper } = setupMocks({});
@ -336,7 +337,8 @@ describe('address-questions.vue', () => {
const noMatchAlert = wrapper.findComponent({ ref: 'alertNoMatchWarning' });
expect(noMatchAlert.exists()).toBe(false);
});
}
);
test('user enters address that yields no autocomplete results => show noMatch alert', async () => {
// Arrange

View file

@ -208,9 +208,11 @@ export default {
});
// Standard place_changed event handling
const autocompleteListener = window.google.maps.event.addListener(autocomplete,
const autocompleteListener = window.google.maps.event.addListener(
autocomplete,
'place_changed',
fillInAddress);
fillInAddress
);
addressField1.addEventListener('focus', () => {
// Wrapping the addressField1 element in the Google Address Autocomplete object
@ -265,14 +267,16 @@ export default {
const firstResult = item.textContent;
const geocoder = new window.google.maps.Geocoder();
geocoder.geocode({
address: firstResult
},
(results, status) => {
if (status === window.google.maps.GeocoderStatus.OK) {
fillInAddress(results[0]);
geocoder.geocode(
{
address: firstResult
},
(results, status) => {
if (status === window.google.maps.GeocoderStatus.OK) {
fillInAddress(results[0]);
}
}
});
);
} else {
// No addresses found for the input
self.matchFound = false;

View file

@ -48,7 +48,8 @@ export default {
// Display modal
this.isModalVisible = true;
// Force page reload on back button
window.addEventListener('pageshow',
window.addEventListener(
'pageshow',
(evt) => {
if (evt.persisted) {
setTimeout(() => {
@ -56,7 +57,8 @@ export default {
}, 10);
}
},
false);
false
);
},
hideModal() {
this.isModalVisible = false;

View file

@ -65,8 +65,10 @@ export default ({
this.$nextTick(this.setupHeader);
// Check if alert event is on the bus
const alertEvent = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND);
const alertEvent = eventBus.readAndPopEventFromBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND
);
// If alert event is on the bus, then display the alert
if (alertEvent !== undefined) {
this.displayGlobalAlert = true;

View file

@ -57,8 +57,10 @@ export default {
return this.getCmsContent(this.cmsWidgetName, this.contentProperty ?? 'SubHeaderText');
},
subText() {
let subTextFromCms = this.getCmsContent(this.cmsWidgetName,
this.subContentProperty ?? 'SecondaryText');
let subTextFromCms = this.getCmsContent(
this.cmsWidgetName,
this.subContentProperty ?? 'SecondaryText'
);
if (this.stripRteStyle) {
subTextFromCms = stripRteStyle(subTextFromCms);

View file

@ -2,7 +2,7 @@
import addressLookup from '@/layouts/address-lookup/address-lookup.vue';
// Supporting Files
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store';
@ -14,9 +14,7 @@ jest.mock('@/helpers/damage-helper', () => ({
}));
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
/** @ignore */
function setupMocks({
@ -47,7 +45,8 @@ function setupMocks({
}
}));
const wrapper = shallowMount(addressLookup,
const wrapper = shallowMount(
addressLookup,
getMountOptions({
route: route || undefined,
router: {
@ -71,7 +70,8 @@ function setupMocks({
}
}
}));
})
);
const apiResponses = {
vinLookupResponse: {
@ -348,11 +348,13 @@ describe('address-lookup.vue', () => {
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
undefined,
{},
{},
carsFound);
carsFound
);
});
// eslint-disable-next-line max-len
@ -393,11 +395,14 @@ describe('address-lookup.vue', () => {
await wrapper.vm.navigateForward(carsFound);
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
undefined,
{},
{ displayVehicleChangeAlert: true });
});
{ displayVehicleChangeAlert: true }
);
}
);
test('single car was found and matches entered vehicle => navigateForwardWithSingleCarMatch', async () => {
// Arrange

View file

@ -87,7 +87,7 @@ import { Form } from 'vee-validate';
// Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import routerParams from '@/router/router-constants/router-params';
import { getDamageString, isGlassAvailableForCarId } from '@/helpers/damage-helper';
@ -142,8 +142,10 @@ export default {
},
computed: {
AlertMatchedDifferentVehicleHeader() {
return this.getCmsContent('AlertMatchedDifferentVehicleWidget',
'HeadlineText').replaceAll('{custom:damage}', getDamageString());
return this.getCmsContent(
'AlertMatchedDifferentVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
},
AlertMatchedDifferentVehicleBody() {
const vinYmmFound =
@ -158,8 +160,10 @@ export default {
.replaceAll('{custom:vinYmmExpected}', vinYmmExpected);
},
AlertMatchedTwoIdenticalYMMVehicleHeader() {
return this.getCmsContent('AlertMatchedTwoIdenticalYMMVehicleWidget',
'HeadlineText').replaceAll('{custom:damage}', getDamageString());
return this.getCmsContent(
'AlertMatchedTwoIdenticalYMMVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
},
AlertMatchedTwoIdenticalYMMVehicleBody() {
const vinYmmsFound =
@ -208,10 +212,12 @@ export default {
},
attachCustomEvents() {
this.prependActionToMethod(this, this.forwardButtonAction, () => {
this.pushEventToGA(this.$route.query[this.queryStrings.ISS_PAGE],
this.pushEventToGA(
this.$route.query[this.queryStrings.ISS_PAGE],
this.GaActions.SUBMITTED,
this.GaLabels.ADDRESS_LOOKUP,
true);
true
);
});
},
@ -292,22 +298,24 @@ export default {
}
// Save vehicle, customer, service and registration information
await useMainStore().saveRegistrationAddressLookup({
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo:
Object.keys(vehicleInfoToCommit).length === 0
? null
: vehicleInfoToCommit,
registrationInfo: {
firstName: this.customerQuestions.firstName,
lastName: this.customerQuestions.lastName,
address: this.customerQuestions.addressQuestions.streetAddress,
city: this.customerQuestions.addressQuestions.city,
state: this.customerQuestions.addressQuestions.state,
zipCode: this.customerQuestions.addressQuestions.zipCode
}
},
false);
await useMainStore().saveRegistrationAddressLookup(
{
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo:
Object.keys(vehicleInfoToCommit).length === 0
? null
: vehicleInfoToCommit,
registrationInfo: {
firstName: this.customerQuestions.firstName,
lastName: this.customerQuestions.lastName,
address: this.customerQuestions.addressQuestions.streetAddress,
city: this.customerQuestions.addressQuestions.city,
state: this.customerQuestions.addressQuestions.state,
zipCode: this.customerQuestions.addressQuestions.zipCode
}
},
false
);
return this.navigateForward(carsFound);
},
@ -322,18 +330,22 @@ export default {
this.isCarIdDifferent
&& !this.isSelectedGlassAvailableForVehicle
) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$router.navigate(
this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
);
} else if (matchingCars.length === 1) {
await this.navigateForwardWithSingleCarMatch();
} else {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
this.$route,
{},
{},
carsFound);
carsFound
);
}
},
resetWarningsAndErrors() {

View file

@ -58,8 +58,10 @@ export default {
emits: ['update: modelValue'],
computed: {
differentVehicleAlertHeader() {
return this.getCmsContent('AlertMatchedDifferentVehicleWidget', 'HeadlineText').replaceAll('{custom:damage}',
getDamageString());
return this.getCmsContent(
'AlertMatchedDifferentVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
},
differentVehicleAlertBody() {
const vinYmmFound =
@ -73,11 +75,14 @@ export default {
.replaceAll('{custom:vinYmmExpected}', vinYmmExpected);
},
AlertMatchedTwoIdenticalYMMVehicleHeader() {
return this.getCmsContent('AlertMatchedTwoIdenticalYMMVehicleWidget',
'HeadlineText').replaceAll('{custom:damage}', getDamageString());
return this.getCmsContent(
'AlertMatchedTwoIdenticalYMMVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
},
AlertMatchedTwoIdenticalYMMVehicleBody() {
const vinYmmsFound =
// eslint-disable-next-line max-len
`${this.selectedVehicle?.vehicle.year} ${this.selectedVehicle?.vehicle.make} ${this.selectedVehicle?.vehicle.model} ${this.selectedVehicle?.vehicle.style}`;
const vinYmmsExpected =
`${this.vehicleSelected?.year} ${this.vehicleSelected?.make} ${this.vehicleSelected?.model} ${this.vehicleSelected?.style}`;

View file

@ -1,5 +1,5 @@
import addressVehicles from '@/layouts/address-vehicles/address-vehicles.vue';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store';
@ -21,9 +21,7 @@ jest.mock('@/helpers/cms-content-helper', () => ({
}));
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
function setupMocks({
route = null,
@ -209,7 +207,8 @@ describe('address-vehicles.vue', () => {
// Assert
expect(wrapper.vm.$router.navigate).toBeCalledTimes(1);
});
}
);
test('carId is not different on navigateForward (car was found) => Should handle navigating forward with car match', async () => {
// Arrange
@ -233,10 +232,12 @@ describe('address-vehicles.vue', () => {
useMainStore().order.vehicle.carId = 'CR00000395';
// Act
addressVehicles.beforeRouteEnter.call(wrapper.vm,
addressVehicles.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'address-vehicles' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();

View file

@ -65,7 +65,7 @@
<script>
// Import Supporting Files
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { useMainStore } from '@/store';
import issPageValues from '@/router/router-constants/issPage-values';
import errorMessages from '@/constants/error-messages';
@ -148,8 +148,10 @@ export default {
return this.VehiclesForQuestions.length;
},
AlertFoundMultipleVehiclesHeader() {
return this.getCmsContent('FoundMultipleVehicles',
'HeadlineText').replaceAll('{custom:vehicleCount}', this.vehicleCount);
return this.getCmsContent(
'FoundMultipleVehicles',
'HeadlineText'
).replaceAll('{custom:vehicleCount}', this.vehicleCount);
},
isTwoIdenticalYMMVehicleFound() {
const vinYmmFound =
@ -242,14 +244,16 @@ export default {
return;
}
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vinLookup.data.carId);
await useMainStore().saveVin({
vehicleInfo: Object.assign(this.selectedVehicle.vehicle, {
vin: this.selectedVehicle.vin
}),
isSelectedGlassAvailableForVehicle:
this.isSelectedGlassAvailableForVehicle
},
false);
await useMainStore().saveVin(
{
vehicleInfo: Object.assign(this.selectedVehicle.vehicle, {
vin: this.selectedVehicle.vin
}),
isSelectedGlassAvailableForVehicle:
this.isSelectedGlassAvailableForVehicle
},
false
);
await this.navigateForward();
},
@ -257,10 +261,12 @@ export default {
// If the vehicle selected on this page is different from the one originally entered and the selected glass is not available
// for that vehicle, then navigate back to "vehicle-damage" and display vehicle changed alert on that page.
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$router.navigate(
this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
);
} else {
await this.navigateForwardWithSingleCarMatch();
}

View file

@ -16,7 +16,7 @@ import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue'
// Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import issPageValues from '@/router/router-constants/issPage-values.js';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { useMainStore } from '@/store';
export default {

View file

@ -74,7 +74,7 @@ import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { Form } from 'vee-validate';
import globalRules from '@/constants/global-rules';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { useMainStore } from '@/store';
export default {
@ -134,11 +134,13 @@ export default {
return this.navigateForward();
},
navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route,
{},
{},
this.bailoutPageModel);
this.bailoutPageModel
);
},
getBailoutPageModelFromStore() {
return {

View file

@ -21,7 +21,7 @@
<script>
// Import Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
// Import Component
import baseFormMixin from '@/mixins/base-form-mixin';
@ -101,17 +101,21 @@ export default {
glass.answerKey = `${glass.glassLocation}-${glass.glassName}`;
// reset selectedAnswers for this glass
this.selectedAnswers[glass.answerKey] = [];
const updatedGlass = this.setupInitialData(glass,
const updatedGlass = this.setupInitialData(
glass,
index,
alreadyAnsweredQuestions);
alreadyAnsweredQuestions
);
// Set up watch for each set of glass questions
this.$watch(`selectedAnswers.${glass.answerKey}`,
this.$watch(
`selectedAnswers.${glass.answerKey}`,
(newValue) => {
if (newValue && Object.keys(newValue).length > 0) {
this.handleAnswerUpdates(newValue, glass.answerKey);
}
},
{ deep: true });
{ deep: true }
);
return updatedGlass;
});
},

View file

@ -205,8 +205,10 @@ export default {
notesForTechnician: this.notesForTechnician
};
useMainStore().updateContactInfo(contactInfo);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
}
}
};

View file

@ -7,12 +7,10 @@ import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { createTestingPinia } from '@pinia/testing';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
import { getRandomString, getRandomInt } from '@/helpers/data-generation.js';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
jest.mock('@/helpers/cms-content-helper', () => ({
fetchCmsContentForPage: jest.fn(),

View file

@ -113,7 +113,7 @@ import loadingModal from '@/iss-components/loading-modal/loading-modal.vue';
// Import Supporting Files
import { fetchCmsContentForPage, setupModalLinks, processIfStatements } from '@/helpers/cms-content-helper.js';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { getDamageString } from '@/helpers/damage-helper.js';
import { useMainStore } from '@/store/index.js';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin.js';
@ -192,12 +192,16 @@ export default {
},
computed: {
verifiedITACAlertHeader() {
return this.getCmsContent('VerifiedITACAlert',
'HeadlineText');
return this.getCmsContent(
'VerifiedITACAlert',
'HeadlineText'
);
},
verifiedITACAlertBody() {
return this.getCmsContent('VerifiedITACAlert',
'BodyText')?.replaceAll('{custom:costSavings}', this.costSavings);
return this.getCmsContent(
'VerifiedITACAlert',
'BodyText'
)?.replaceAll('{custom:costSavings}', this.costSavings);
},
coverageStatementSubHeader() {
return this.getSubheaderTextFromCms('SiteSubHeaderWidget');
@ -331,22 +335,32 @@ export default {
},
async navigateForward() {
if (this.unverified || this.verifiedDeductible) {
this.$router.navigate(navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD,
this.$route
);
} else if (this.verifiedITAC || this.verifiedNoComp) {
if (this.selectedProvider === 'Safelite') {
this.$router.navigate(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
this.$route);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
this.$route
);
} else if (useMainStore().issConfig.enableTPAFlow) {
this.$router.navigate(navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED,
this.$route);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED,
this.$route
);
} else {
this.$router.navigate(navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED,
this.$route);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED,
this.$route
);
}
} else {
this.$router.navigate(navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE,
this.$route);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE,
this.$route
);
}
},
openModalAction(modalName) {

View file

@ -2,14 +2,12 @@
import entryPage from '@/layouts/entry-page/entry-page.vue';
import { shallowMount } from '@vue/test-utils';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -26,8 +24,10 @@ function setupMocks(queryString) {
route: { queryString }
});
const wrapper = shallowMount(entryPage,
mountOptions);
const wrapper = shallowMount(
entryPage,
mountOptions
);
const apiResponses = {};

View file

@ -36,8 +36,10 @@ export default {
methods:
{
navigateForward() {
this.$router.navigate(this.navigationScenarios.MOVE_FORWARD_ENTRY_PAGE,
this.$route);
this.$router.navigate(
this.navigationScenarios.MOVE_FORWARD_ENTRY_PAGE,
this.$route
);
},
parseQueryParms() {
// Dump the query string parameters into an array. Remove casing on the key for easy compare.

View file

@ -2,7 +2,7 @@
import licensePlateLookup from '@/layouts/license-plate-lookup/license-plate-lookup.vue';
// Supporting Files
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store';
@ -14,9 +14,7 @@ jest.mock('@/helpers/damage-helper', () => ({
}));
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -57,7 +55,8 @@ function setupMocks({
}
}));
const wrapper = shallowMount(licensePlateLookup,
const wrapper = shallowMount(
licensePlateLookup,
getMountOptions({
route: route || undefined,
router: {
@ -75,7 +74,8 @@ function setupMocks({
}
}
}));
})
);
const apiResponses = {
serviceZipValidationResponse: {
@ -183,10 +183,12 @@ describe('license-plate-lookup.vue', () => {
}
});
// Act
licensePlateLookup.beforeRouteEnter.call(wrapper.vm,
licensePlateLookup.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'license-plate-lookup' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
await wrapper.vm.backButtonAction();
// Assert
@ -242,11 +244,14 @@ describe('license-plate-lookup.vue', () => {
await wrapper.vm.navigateForward(carsFound);
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
undefined,
{},
{ displayVehicleChangeAlert: true });
});
{ displayVehicleChangeAlert: true }
);
}
);
});
describe('miscellaneous', () => {
@ -256,10 +261,12 @@ describe('license-plate-lookup.vue', () => {
useMainStore().order.vehicle.carId = 'CR00000395';
// Act
licensePlateLookup.beforeRouteEnter.call(wrapper.vm,
licensePlateLookup.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'license-plate-lookup' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();

View file

@ -78,7 +78,7 @@
<script>
// Import Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { useMainStore } from '@/store';
import errorMessages from '@/constants/error-messages';
import { required } from '@/helpers/validation-rules';
@ -154,8 +154,10 @@ export default {
},
computed: {
AlertMatchedDifferentVehicleHeader() {
return this.getCmsContent('AlertMatchedDifferentVehicleWidget',
'HeadlineText').replaceAll('{custom:damage}', getDamageString());
return this.getCmsContent(
'AlertMatchedDifferentVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
},
AlertMatchedDifferentVehicleBody() {
const vinYmmFound =
@ -170,8 +172,10 @@ export default {
.replaceAll('{custom:vinYmmExpected}', vinYmmExpected);
},
AlertMatchedTwoIdenticalYMMVehicleHeader() {
return this.getCmsContent('AlertMatchedTwoIdenticalYMMVehicleWidget',
'HeadlineText').replaceAll('{custom:damage}', getDamageString());
return this.getCmsContent(
'AlertMatchedTwoIdenticalYMMVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
},
AlertMatchedTwoIdenticalYMMVehicleBody() {
const vinYmmsFound =
@ -225,10 +229,12 @@ export default {
},
attachCustomEvents() {
this.prependActionToMethod(this, this.forwardButtonAction, () => {
this.pushEventToGA(this.$route.query[this.queryStrings.ISS_PAGE],
this.pushEventToGA(
this.$route.query[this.queryStrings.ISS_PAGE],
this.GaActions.SUBMITTED,
this.GaLabels.LICENSE_PLATE_LOOKUP,
true);
true
);
});
},
// NOTE: If form is not valid, this method is not called when 'Continue' button is clicked
@ -287,15 +293,17 @@ export default {
}
// Save vehicle, license plate, and registration information
await useMainStore().saveRegistrationLicensePlateLookup({
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, { vin: vinLookupResponse.data.vin }),
registrationInfo: {
licensePlate: this.licensePlate,
state: this.licenseState
}
},
false);
await useMainStore().saveRegistrationLicensePlateLookup(
{
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, { vin: vinLookupResponse.data.vin }),
registrationInfo: {
licensePlate: this.licensePlate,
state: this.licenseState
}
},
false
);
return this.navigateForward();
},
@ -304,10 +312,12 @@ export default {
// not available for that vehicle then navigate back to "vehicle-damage"
// display vehicle changed alert on that page.
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$router.navigate(
this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
);
} else {
await this.navigateForwardWithSingleCarMatch();
}

View file

@ -22,7 +22,7 @@
<script>
// Import Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import globalRules from '@/constants/global-rules';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import { useMainStore } from '@/store';
@ -70,8 +70,10 @@ export default {
},
computed: {
AlertFewMoreQuestionsHeader() {
return this.getCmsContent('AdditionalPartsQuestionsAlert',
'HeadlineText');
return this.getCmsContent(
'AdditionalPartsQuestionsAlert',
'HeadlineText'
);
},
AlertFewMoreQuestionsCopy() {
return this.getCmsContent('AdditionalPartsQuestionsAlert', 'BodyText');
@ -105,18 +107,24 @@ export default {
glass.answerKey = `${glass.glassLocation}-${glass.glassName}`;
// reset selectedAnswers for this glass
this.selectedAnswers[glass.answerKey] = [];
const updatedGlass = this.setupInitialData(glass,
const updatedGlass = this.setupInitialData(
glass,
index,
alreadyAnsweredQuestions);
alreadyAnsweredQuestions
);
// Set up watch for each set of glass questions
this.$watch(`selectedAnswers.${glass.answerKey}`,
this.$watch(
`selectedAnswers.${glass.answerKey}`,
(newValue) => {
if (newValue && Object.keys(newValue).length > 0) {
this.handleAnswerUpdates(newValue,
glass.answerKey);
this.handleAnswerUpdates(
newValue,
glass.answerKey
);
}
},
{ deep: true });
{ deep: true }
);
return updatedGlass;
});
},

View file

@ -26,7 +26,7 @@ import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 BaseFormMixin from '@/mixins/base-form-mixin.js';
@ -63,8 +63,10 @@ export default {
return this.navigateForward();
},
navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
}
}
};

View file

@ -91,6 +91,7 @@ const baseStoreGettersPageData = () => ({
{
questionSequence: 1,
questionText:
// eslint-disable-next-line max-len
'Is your vehicle equipped with the Panoramic Sunroof which can be identified by having a glass panel over the rear seats?',
answers: [
{
@ -122,12 +123,14 @@ const baseStoreGettersDamage = () => ({
answeredQuestions: [
{
questionText:
// eslint-disable-next-line max-len
'Is your vehicle equipped with the Panoramic Sunroof which can be identified by having a glass panel over the rear seats?',
selectedAnswerText: 'Yes',
questionNum: 1
},
{
questionText:
// eslint-disable-next-line max-len
'Is your vehicle equipped with a heated windshield that melts snow and ice from underneath the windshield wiper blades?',
selectedAnswerText: 'Yes',
questionNum: 2

View file

@ -24,7 +24,7 @@ import questionsPageLayout from '@/iss-components/questions-page-layout/question
// Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { useMainStore } from '@/store';
import issPageValues from '@/router/router-constants/issPage-values';
import { Form } from 'vee-validate';
@ -96,13 +96,15 @@ export default {
const updatedGlass = this.setupInitialData(glass, index, alreadyAnsweredQuestions);
// Set up watch for each set of glass questions
this.$watch(`selectedAnswers.${glass.answerKey}`,
this.$watch(
`selectedAnswers.${glass.answerKey}`,
(newValue) => {
if (newValue && Object.keys(newValue).length > 0) {
this.handleAnswerUpdates(newValue, glass.answerKey);
}
},
{ deep: true });
{ deep: true }
);
return updatedGlass;
});

View file

@ -27,7 +27,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';

View file

@ -3,15 +3,13 @@ import policyHolderDetails from '@/layouts/policy-holder-details/policy-holder-d
// Supporting files
// Supporting files
import { shallowMount } from '@vue/test-utils';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store';
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -20,7 +18,8 @@ jest.mock('@/helpers/cms-content-helper', () => ({
/** @ignore */
function setupMocks() {
const wrapper = shallowMount(policyHolderDetails,
const wrapper = shallowMount(
policyHolderDetails,
getMountOptions({
router: {
navigate: jest.fn()
@ -32,7 +31,8 @@ function setupMocks() {
}
}
}
}));
})
);
const policies = [{
vehicles: [
{
@ -165,10 +165,12 @@ describe('navigation', () => {
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED,
undefined,
{},
{},
mockvehicles);
mockvehicles
);
});
});

View file

@ -59,7 +59,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 globalRules from '@/constants/global-rules';
import BaseFormMixin from '@/mixins/base-form-mixin.js';
@ -131,14 +131,18 @@ export default {
navigateForward() {
if (this.vehiclesCount > 0) {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED,
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED,
this.$route,
{},
{},
this.vehiclesFound);
this.vehiclesFound
);
} else {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
this.$route
);
}
},

View file

@ -1,5 +1,5 @@
import policyVehicles from '@/layouts/policy-vehicles/policy-vehicles.vue';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper';
import { useMainStore } from '@/store';
@ -23,9 +23,7 @@ jest.mock('@/helpers/cms-content-helper', () => ({
}));
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
const mockMixin = {
methods: {
@ -90,7 +88,9 @@ describe('policy-vehicles.vue', () => {
describe('forwardButtonAction', () => {
// eslint-disable-next-line max-len
test('Selected VIN matches vehicle listed in system => update vehicle and navigate forward with CLICKED_FORWARD_LISTED_VEHICLE scenario.',
test(
// eslint-disable-next-line max-len
'Selected VIN matches vehicle listed in system => update vehicle and navigate forward with CLICKED_FORWARD_LISTED_VEHICLE scenario.',
async () => {
// Arrange
const { wrapper } = setupMocks({});
@ -127,13 +127,17 @@ describe('policy-vehicles.vue', () => {
// Assert
expect(wrapper.vm.bailout).toBeFalsy();
expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE,
undefined,
{},
{});
});
{}
);
}
);
test('Error in lookupVehicleByVin call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario.',
test(
'Error in lookupVehicleByVin call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario.',
async () => {
// Arrange
const { wrapper } = setupMocks({});
@ -152,11 +156,14 @@ describe('policy-vehicles.vue', () => {
// Assert
expect(wrapper.vm.bailout).toBeTruthy();
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
undefined,
{},
{});
});
{}
);
}
);
test('vehicle not listed => navigate forward with CLICKED_FORWARD_NON_LISTED_VEHICLE scenario.', async () => {
// Arrange
@ -170,10 +177,12 @@ describe('policy-vehicles.vue', () => {
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE,
undefined,
{},
{});
{}
);
});
});

View file

@ -184,21 +184,27 @@ export default {
},
navigateForward() {
if (this.bailout) {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route,
{},
{});
{}
);
} else if (this.selectedVehicleVin === vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
this.$router
.navigate(this.navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE,
.navigate(
this.navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE,
this.$route,
{},
{});
{}
);
} else {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE,
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE,
this.$route,
{},
{});
{}
);
}
},
async lookupVehicleByVin(vin) {

View file

@ -107,7 +107,8 @@ describe('provider-pref-radio.vue', () => {
const fileredResults = results.filter((result) => result.includes(' -'));
expect(fileredResults.length).toBe(0);
});
it('Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when buttonBodyCopy has 6 total dashes, but one is empty ',
it(
'Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when buttonBodyCopy has 6 total dashes, but one is empty ',
async () => {
// Arrange
const moddedProps = mockProps;
@ -123,5 +124,6 @@ describe('provider-pref-radio.vue', () => {
// Assert
expect(results.length).toBe(5);
});
}
);
});

View file

@ -1,16 +1,14 @@
import ProviderPreference from '@/layouts/provider-preference/provider-preference.vue';
import { shallowMount } from '@vue/test-utils';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store';
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -27,8 +25,10 @@ function setupMocks(mockApiResponses) {
route: 'provider-preference'
});
const wrapper = shallowMount(ProviderPreference,
mountOptions);
const wrapper = shallowMount(
ProviderPreference,
mountOptions
);
useMainStore().getCoveragePolicyInfo = jest.fn().mockImplementation(() => Promise.resolve({
data: {}

View file

@ -52,7 +52,7 @@
<script>
// Import Supporting Files
import { fetchCmsContentForPage, setupModalLinks } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import errorMessages from '@/constants/error-messages';
import buttonQuestion from '@/digital-components/button-question/button-question.vue';
import issPageValues from '@/router/router-constants/issPage-values';

View file

@ -1,13 +1,11 @@
import { shallowMount } from '@vue/test-utils';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import shopPreferenceModal from '@/layouts/provider-preference/shop-preference-modal/shop-preference-modal.vue';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -25,8 +23,10 @@ function setupMocks(propsData) {
mountOptions.propsData = propsData;
const wrapper = shallowMount(shopPreferenceModal,
mountOptions);
const wrapper = shallowMount(
shopPreferenceModal,
mountOptions
);
const apiResponses = {};

View file

@ -1,14 +1,12 @@
import { shallowMount } from '@vue/test-utils';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store';
import steeringModal from '@/layouts/provider-preference/steering-modal/steering-modal.vue';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -24,8 +22,10 @@ function setupMocks() {
}
});
const wrapper = shallowMount(steeringModal,
mountOptions);
const wrapper = shallowMount(
steeringModal,
mountOptions
);
const apiResponses = {};

View file

@ -1,13 +1,11 @@
import { shallowMount } from '@vue/test-utils';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import tpaRecalModal from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-modal.vue';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -23,8 +21,10 @@ function setupMocks() {
}
});
const wrapper = shallowMount(tpaRecalModal,
mountOptions);
const wrapper = shallowMount(
tpaRecalModal,
mountOptions
);
const apiResponses = {};

View file

@ -26,7 +26,7 @@ import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';
@ -68,8 +68,10 @@ export default {
forwardButtonAction() {
},
navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
}
}
};

View file

@ -28,7 +28,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';

View file

@ -9,12 +9,14 @@ jest.mock('@/helpers/cms-content-helper', () => ({
/** @ignore */
function setupMocks() {
const wrapper = shallowMount(serviceLocation,
const wrapper = shallowMount(
serviceLocation,
getMountOptions({
router: {
navigate: jest.fn()
}
}));
})
);
return { wrapper };
}
@ -30,10 +32,12 @@ const mockGetServiceabilityDetails = () => {
return Promise.resolve(serviceabilityDetails);
};
jest.mock('@/helpers/service-location-helper',
jest.mock(
'@/helpers/service-location-helper',
() => ({
getServiceabilityDetails: jest.fn((mockServiceZipCode) => mockGetServiceabilityDetails(mockServiceZipCode))
}));
})
);
const mockMixin = {
methods: {

View file

@ -58,7 +58,7 @@
<script>
// Import Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { required } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages';
import buttonQuestion from '@/digital-components/button-question/button-question.vue';
@ -118,8 +118,10 @@ export default {
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
vm.setData(resultMap.zipCodeData,
resultMap.serviceabilityDetails);
vm.setData(
resultMap.zipCodeData,
resultMap.serviceabilityDetails
);
});
},
setup() {

View file

@ -53,11 +53,13 @@ const mockGetZipCodeData = (mockServiceZipCode) => {
};
};
jest.mock('@/helpers/service-location-helper',
jest.mock(
'@/helpers/service-location-helper',
() => ({
getServiceabilityDetails: jest.fn((mockServiceZipCode) => mockGetServiceabilityDetails(mockServiceZipCode)),
getZipCodeData: jest.fn((mockServiceZipCode) => mockGetZipCodeData(mockServiceZipCode))
}));
})
);
const linkWidgetName = 'linkWidgetName';
const modalWidgetName = 'modalWidgetName';

View file

@ -107,7 +107,8 @@ describe('service-package-radio.vue', () => {
const fileredResults = results.filter((result) => result.includes(' -'));
expect(fileredResults.length).toBe(0);
});
it('Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when buttonBodyCopy has 6 total dashes, but one is empty ',
it(
'Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when buttonBodyCopy has 6 total dashes, but one is empty ',
async () => {
// Arrange
const moddedProps = mockProps;
@ -123,5 +124,6 @@ describe('service-package-radio.vue', () => {
// Assert
expect(results.length).toBe(5);
});
}
);
});

View file

@ -58,7 +58,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
import contentGroupModal from '@/iss-components/content-group-modal/content-group-modal.vue';
import loadingModal from '@/iss-components/loading-modal/loading-modal.vue';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { useMainStore } from '@/store';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { Form } from 'vee-validate';

View file

@ -26,7 +26,7 @@ import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';
@ -71,8 +71,10 @@ export default {
},
navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
}
}
};

View file

@ -26,7 +26,7 @@ import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 BaseFormMixin from '@/mixins/base-form-mixin.js';
@ -65,8 +65,10 @@ export default {
return this.navigateForward();
},
navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
}
}
};

View file

@ -27,7 +27,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files
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 BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';
@ -77,8 +77,10 @@ export default {
},
navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
}
}
};

View file

@ -68,9 +68,11 @@ describe('damage-location-question.vue', () => {
});
// Act
damageLocationQuestion.methods.initializeComponent.call(wrapper.vm,
damageLocationQuestion.methods.initializeComponent.call(
wrapper.vm,
damageOptions,
'car-group');
'car-group'
);
// Assert
expect(wrapper.vm.damageOptions).toStrictEqual({

View file

@ -71,9 +71,11 @@ describe('replace-options-question.vue', () => {
});
// Act
replaceOptionsQuestion.methods.initializeComponent.call(wrapper.vm,
replaceOptionsQuestion.methods.initializeComponent.call(
wrapper.vm,
replaceOptions,
'car-group');
'car-group'
);
// Assert
expect(wrapper.vm.replaceOptions).toStrictEqual(['Windshield', 'FrontDoor']);
@ -103,7 +105,8 @@ describe('replace-options-question.vue', () => {
wrapper.vm.$options.methods.updateSelectedValues.call(wrapper.vm);
expect(wrapper.vm.selectedValues).toEqual([]);
});
}
);
});
describe('replace-options-question.vue', () => {
@ -115,10 +118,12 @@ describe('replace-options-question.vue', () => {
});
// Act
wrapper.vm.$options.methods.initializeComponent.call(wrapper.vm,
wrapper.vm.$options.methods.initializeComponent.call(
wrapper.vm,
cmsContent,
replaceOptions,
'car-group');
'car-group'
);
wrapper.vm.$options.watch.isAvailable.call(wrapper.vm, true);
// Assert

View file

@ -125,13 +125,15 @@ describe('replace-options-question.vue', () => {
} = setupMocks({});
// Act
sideDoorOptions.methods.initializeComponent.call(wrapper.vm,
sideDoorOptions.methods.initializeComponent.call(
wrapper.vm,
cmsContent,
driverSideReplaceOptions,
passengerSideReplaceOptions,
driverSideOptions,
passengerSideOptions,
'car-group');
'car-group'
);
// Assert
expect(wrapper.vm.answersToDisplay).toStrictEqual([]);

View file

@ -87,9 +87,11 @@ export default {
return this.selectedValues.selectedDoorSides;
},
set(newValue) {
this.selectedValues = this.getSideDoorReplacementOptions(newValue,
this.selectedValues = this.getSideDoorReplacementOptions(
newValue,
this.selectedValues.selectedDriverSideReplaceOptions,
this.selectedValues.selectedPassengerSideReplaceOptions);
this.selectedValues.selectedPassengerSideReplaceOptions
);
}
},
selectedDriverSideReplaceOptionsValues: {
@ -97,9 +99,11 @@ export default {
return this.selectedValues.selectedDriverSideReplaceOptions;
},
set(newValue) {
this.selectedValues = this.getSideDoorReplacementOptions(this.selectedValues.selectedDoorSides,
this.selectedValues = this.getSideDoorReplacementOptions(
this.selectedValues.selectedDoorSides,
newValue,
this.selectedValues.selectedPassengerSideReplaceOptions);
this.selectedValues.selectedPassengerSideReplaceOptions
);
}
},
selectedPassengerSideReplaceOptionsValues: {
@ -107,9 +111,11 @@ export default {
return this.selectedValues.selectedPassengerSideReplaceOptions;
},
set(newValue) {
this.selectedValues = this.getSideDoorReplacementOptions(this.selectedValues.selectedDoorSides,
this.selectedValues = this.getSideDoorReplacementOptions(
this.selectedValues.selectedDoorSides,
this.selectedValues.selectedDriverSideReplaceOptions,
newValue);
newValue
);
}
},
answersToDisplay() {
@ -148,9 +154,11 @@ export default {
this.$refs.driverSideOptions.initializeComponent(driverSideOptions);
this.$refs.passengerSideOptions.initializeComponent(passengerSideOptions);
},
getSideDoorReplacementOptions(selectedDoorSides,
getSideDoorReplacementOptions(
selectedDoorSides,
selectedDriverSideReplaceOptions,
selectedPassengerSideReplaceOptions) {
selectedPassengerSideReplaceOptions
) {
return {
selectedDoorSides,
selectedDriverSideReplaceOptions,

View file

@ -85,7 +85,7 @@ import alert from '@/ux-components/alert/alert.vue';
// Supporting files
import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { Form, defineRule } from 'vee-validate';
import { required } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages';
@ -138,8 +138,10 @@ export default {
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
vm.$refs.damageLocation.initializeComponent(resultMap.damageOptions);
vm.$refs.sideDoorOptions.initializeComponent(resultMap.damageOptions.driverSideOptions.availableReplacementOptions,
resultMap.damageOptions.passengerSideOptions.availableReplacementOptions);
vm.$refs.sideDoorOptions.initializeComponent(
resultMap.damageOptions.driverSideOptions.availableReplacementOptions,
resultMap.damageOptions.passengerSideOptions.availableReplacementOptions
);
vm.$refs.windshieldOptions.initializeComponent(resultMap.damageOptions.windshieldOptions.availableReplacementOptions);
vm.$refs.backGlassOptions.initializeComponent(resultMap.damageOptions.backGlassOptions.availableReplacementOptions);
});
@ -362,23 +364,31 @@ export default {
},
async forwardButtonAction() {
await this.mainStore.saveVehicleDamage(this.isWindshieldRepair,
await this.mainStore.saveVehicleDamage(
this.isWindshieldRepair,
this.selectedGlassToReplace(),
this.selectedWindshieldOptions.selectedWindshieldChipCount);
this.selectedWindshieldOptions.selectedWindshieldChipCount
);
return this.navigateForward();
},
navigateForward() {
if (this.mainStore.damage.isRepair) {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
this.$route
);
} else if (this.mainStore.order.vehicle.vin) {
// If vin already exists, navigate directly to vin-lookup
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
this.$route
);
} else {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
this.$route
);
}
},

View file

@ -52,20 +52,28 @@ import errorMessages from '@/constants/error-messages';
import damageLocationsSelected from '@/constants/damage-locations-selected.js';
// DEFINE VALIDATION RULES
defineRule('windshield-damage-type-required',
required(errorMessages.WINDSHIELD_DAMAGE_TYPE_REQUIRED));
defineRule('windshield-chip-count-required',
required(errorMessages.WINDSHIELD_CHIP_COUNT_REQUIRED));
defineRule('windshield-replace-options-required',
required(errorMessages.WINDSHIELD_REPLACE_OPTIONS_REQUIRED));
defineRule(
'windshield-damage-type-required',
required(errorMessages.WINDSHIELD_DAMAGE_TYPE_REQUIRED)
);
defineRule(
'windshield-chip-count-required',
required(errorMessages.WINDSHIELD_CHIP_COUNT_REQUIRED)
);
defineRule(
'windshield-replace-options-required',
required(errorMessages.WINDSHIELD_REPLACE_OPTIONS_REQUIRED)
);
defineRule('check-for-repair-and-replace',
defineRule(
'check-for-repair-and-replace',
(selectedWindshieldDamageType, selectedDamageLocations) => (
selectedWindshieldDamageType.toString() !== damageLocationsSelected.REPAIR
|| (!selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD)
&& !selectedDamageLocations[0]?.includes(damageLocationsSelected.WINDSHIELD))
|| selectedDamageLocations[0].length === 1
));
)
);
defineRule('repair-only', (value) => value.toString() === damageLocationsSelected.REPAIR);
defineRule('prevent-split-and-single-together', (value) => {
if (
@ -126,9 +134,11 @@ export default {
return this.selectedValues.selectedWindshieldChipCount;
},
set(newValue) {
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValue,
this.selectedValues = this.getWindshieldOptions(
this.selectedWindshieldDamageTypeValue,
newValue,
null);
null
);
}
},
selectedWindshieldReplaceOptionsValues: {
@ -136,9 +146,11 @@ export default {
return this.selectedValues.selectedWindshieldReplaceOptions;
},
set(newValue) {
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValue,
this.selectedValues = this.getWindshieldOptions(
this.selectedWindshieldDamageTypeValue,
null,
newValue);
newValue
);
}
},
isWindshieldDamageLocation() {
@ -197,9 +209,11 @@ export default {
this.windshieldAvailableReplacementOptions = windshieldAvailableReplacementOptions;
this.$refs.replaceOptionsQuestion.initializeComponent(windshieldAvailableReplacementOptions);
},
getWindshieldOptions(selectedWindshieldDamageType,
getWindshieldOptions(
selectedWindshieldDamageType,
selectedWindshieldChipCount,
selectedWindshieldReplaceOptions) {
selectedWindshieldReplaceOptions
) {
// ONLY UPDATE THE NEW VALUE IF IT IS TRUTHY (NOT NULL)
return {
selectedWindshieldDamageType: selectedWindshieldDamageType || this.selectedValues.selectedWindshieldDamageType,

View file

@ -40,7 +40,7 @@
<script>
// Import Supporting Files
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 BaseFormMixin from '@/mixins/base-form-mixin';
import vinLookupMethodSelections from '@/constants/vin-lookup-methods';

View file

@ -14,7 +14,7 @@
// Import Other Supporting Files
import { useMainStore } from '@/store';
import vinLookupMethodSelections from '@/constants/vin-lookup-methods';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import globalRules from '@/constants/global-rules';
// Import Component

View file

@ -185,7 +185,8 @@ describe('glass-part-question.vue', () => {
['Driver', 'Quarter', 'Green Tint', []]
];
test.each(partsForSelectedTintTestCases)('partsForSelectedTint returns correct parts',
test.each(partsForSelectedTintTestCases)(
'partsForSelectedTint returns correct parts',
async (glassLocation, glassName, selectedTint, expectedResults) => {
// Arrange
const pageData = { partsOrQuestions: [
@ -223,5 +224,6 @@ describe('glass-part-question.vue', () => {
// Assert
expect(expectedResults).toEqual(wrapper.vm.partsForSelectedTint);
});
}
);
});

View file

@ -91,8 +91,10 @@ export default {
return validationRuleName;
},
colorQuestionText() {
return getCustomTransformValue(this.glassColorQuestion,
`${this.glassLocation} ${this.glassName}`);
return getCustomTransformValue(
this.glassColorQuestion,
`${this.glassLocation} ${this.glassName}`
);
},
tintSelectionOptions() {

View file

@ -3,7 +3,7 @@ import vehicleParts from '@/layouts/vehicle-parts/vehicle-parts.vue';
import glassPartQuestion from '@/layouts/vehicle-parts/glass-part-question/glass-part-question.vue';
// Supporting Files
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
@ -14,9 +14,7 @@ import navigationScenarios from '@/router/router-constants/navigation-scenarios'
import applicationConfig from '@/constants/application-config';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -126,10 +124,12 @@ describe('vehicle-parts.vue', () => {
});
// Act
vehicleParts.beforeRouteEnter.call(wrapper.vm,
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
wrapper.vm.setCmsContent = jest.fn();
// Assert
@ -159,10 +159,12 @@ describe('vehicle-parts.vue', () => {
});
// Act
vehicleParts.beforeRouteEnter.call(wrapper.vm,
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
await nextTick();
@ -191,10 +193,12 @@ describe('vehicle-parts.vue', () => {
});
// Act
vehicleParts.beforeRouteEnter.call(wrapper.vm,
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
await nextTick();
@ -227,16 +231,20 @@ describe('vehicle-parts.vue', () => {
});
// Act
vehicleParts.beforeRouteEnter.call(wrapper.vm,
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
wrapper.vm.navigateBack();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route
);
});
test('User did not have part questions > navigateBack triggers a router.navigate change with correct scenario', async () => {
@ -255,16 +263,20 @@ describe('vehicle-parts.vue', () => {
});
// Act
vehicleParts.beforeRouteEnter.call(wrapper.vm,
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
wrapper.vm.navigateBack();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route
);
});
test('ForwardButtonAction triggers a router.navigate change if there are child part questions', async () => {
@ -330,21 +342,25 @@ describe('vehicle-parts.vue', () => {
});
// Act
vehicleParts.beforeRouteEnter.call(wrapper.vm,
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith('CLICKED_FORWARD_WITH_MOLDING_QUESTIONS',
.toHaveBeenCalledWith(
'CLICKED_FORWARD_WITH_MOLDING_QUESTIONS',
{ query: { issPage: 'vehicle-parts' } },
{},
{},
expect.anything());
expect.anything()
);
});
test('ForwardButtonAction triggers a router.navigate change if there are capability questions', async () => {
@ -396,19 +412,23 @@ describe('vehicle-parts.vue', () => {
});
// Act
vehicleParts.beforeRouteEnter.call(wrapper.vm,
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } },
undefined,
(c) => c(wrapper.vm));
(c) => c(wrapper.vm)
);
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith('CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS',
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
'CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS',
{ query: { issPage: 'vehicle-parts' } },
{},
{},
expect.anything());
expect.anything()
);
});
});

View file

@ -72,7 +72,7 @@ import alert from '@/ux-components/alert/alert.vue';
// Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import issPageValues from '@/router/router-constants/issPage-values';
import { Form } from 'vee-validate';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';

View file

@ -86,7 +86,7 @@ import { useMainStore } from '@/store';
// Supporting files
import baseFormMixin from '@/mixins/base-form-mixin.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { Form, defineRule } from 'vee-validate';
import { required } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages';
@ -190,8 +190,10 @@ export default {
navigateForward() {
this.mainStore.setVehicle().then(() => {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
});
},
async updateYearValues() {

View file

@ -306,10 +306,12 @@ describe('vin-lookup.vue', () => {
await flushPromises();
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
expect(mockRouter.navigate).toHaveBeenCalledWith(
navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
mockRoute,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
);
});
});
@ -336,11 +338,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
.toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
mockRoute,
{},
{},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions });
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
});
});
@ -366,11 +370,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
.toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
mockRoute,
{},
{},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions });
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
});
});
@ -396,11 +402,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
.toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
mockRoute,
{},
{},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions });
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
});
});
@ -429,11 +437,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
.toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
mockRoute,
{},
{},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions });
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
});
});
@ -460,8 +470,10 @@ describe('vin-lookup.vue', () => {
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
mockRoute);
.toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
mockRoute
);
});
});
@ -486,8 +498,10 @@ describe('vin-lookup.vue', () => {
await flushPromises();
await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
mockRoute);
expect(mockRouter.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
mockRoute
);
});
});
});

View file

@ -48,7 +48,7 @@ import { computed } from 'vue';
import vehicleLookupAlertTypes from '@/constants/vehicle-lookup-alert-types';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { isGlassAvailableForCarId } from '@/helpers/damage-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import routerParams from '@/router/router-constants/router-params';
import { useMainStore } from '@/store';
@ -183,8 +183,10 @@ export default {
}
if (this.bailout) {
return this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route);
return this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route
);
}
// Add vin bcs the response from the service doesn't contain vin
this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { vin: this.vin });
@ -218,10 +220,12 @@ export default {
if (this.isCarIdDifferentFromTheStore && !isSelectedGlassAvailableForVehicle) {
this.mainStore.updateVehicle(this.vehicleFromLookup);
this.mainStore.resetDamageState();
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$router.navigate(
this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
);
// navigate() doesn't stop the processing flow
return null;

View file

@ -3,7 +3,7 @@ import welcomePage from '@/layouts/welcome-page/welcome-page.vue';
// Supporting files
// Supporting files
import { shallowMount } from '@vue/test-utils';
import { settleAllPromises } from '@/helpers/layout-helper.js';
import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import baseMixin from '@/mixins/base-mixin.js';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
@ -12,9 +12,7 @@ import { useMainStore } from '@/store';
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
// Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({
@ -180,11 +178,13 @@ describe('navigation', () => {
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
undefined,
{},
{},
mockvehicles);
mockvehicles
);
});
test('if policy is found, but no vehicles, navigate to vehicle-selection page', async () => {
// Arrange
@ -206,8 +206,10 @@ describe('navigation', () => {
await wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES,
undefined);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES,
undefined
);
});
test('if policy is not found, navigate to policy-holder-details page', async () => {
// Arrange
@ -224,7 +226,9 @@ describe('navigation', () => {
await wrapper.vm.navigateForward();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
undefined);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
undefined
);
});
});

View file

@ -176,7 +176,7 @@ import textBlock from '@/digital-components/text-block/text-block.vue';
// Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { Form, defineRule } from 'vee-validate';
import { required, regex } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages';
@ -192,8 +192,10 @@ defineRule('loss-state-required', required(errorMessages.LOSS_STATE_REQUIRED));
defineRule('loss-city-required', required(errorMessages.LOSS_CITY_REQUIRED));
defineRule('damage-option-required', required(errorMessages.DAMAGE_OPTION_REQUIRED));
defineRule('policy-zip-required', required(errorMessages.POLICY_ZIP_REQUIRED));
defineRule('policy-zip-format',
regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.POLICY_ZIP_FORMAT));
defineRule(
'policy-zip-format',
regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.POLICY_ZIP_FORMAT)
);
export default {
name: 'welcome-page',
@ -343,21 +345,27 @@ export default {
if (policy) {
if (this.vehiclesFound) {
// if policy lookup is successful and vehicles are found, navigate to policy-vehicles page
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
this.$route,
{},
{},
this.vehiclesFound);
this.vehiclesFound
);
} else {
// if policy lookup is successful, but no vehicles are associated with the policy
// navigate to vehicle-selection page (manual entry)
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_NO_VEHICLES,
this.$route
);
}
} else {
// if policy lookup is unsuccessful, navigate to policy-holder-details page
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
this.$route);
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED,
this.$route
);
}
},

View file

@ -124,7 +124,8 @@ export default {
[`variationId_${googleDimensionIndex}`]: exp.variationId,
[`experimentName_${googleDimensionIndex}`]: exp.universeName,
[`variationName_${googleDimensionIndex}`]: exp.variationName,
[`customDimension_${googleDimensionIndex}`]: `${exp.universeId}_${exp.variationId}_${exp.universeName}_${exp.variationName}`
[`customDimension_${googleDimensionIndex}`]:
`${exp.universeId}_${exp.variationId}_${exp.universeName}_${exp.variationName}`
};
// Push to the data layer with the Google Custom Dimension Index.
@ -157,16 +158,20 @@ export default {
if (response?.data) {
if (response?.data.sessionKey && skey === 0) {
setCookieProperties({ [cookieNames.SESSION_KEY]: response?.data.sessionKey },
setCookieProperties(
{ [cookieNames.SESSION_KEY]: response?.data.sessionKey },
{
useDefaultFunnelCookieAttributes: false
});
}
);
}
if (response?.data.sessionId && sid === '00000000-0000-0000-0000-000000000000') {
setCookieProperties({ [cookieNames.SESSION_ID]: response?.data.sessionId },
setCookieProperties(
{ [cookieNames.SESSION_ID]: response?.data.sessionId },
{
maxAge: 60 * 30 // 30 minutes
});
}
);
}
}
},

View file

@ -64,11 +64,13 @@ describe('analyticsMixin.js', () => {
});
// Act
analyticsMixin.methods.pushEventToGA('category',
analyticsMixin.methods.pushEventToGA(
'category',
'action',
'1111122222333333',
false,
ValueToLogTypes.LAST_5);
ValueToLogTypes.LAST_5
);
// Assert
expect(expectedDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
@ -89,11 +91,13 @@ describe('analyticsMixin.js', () => {
});
// Act
analyticsMixin.methods.pushEventToGA('category',
analyticsMixin.methods.pushEventToGA(
'category',
'action',
'111',
false,
ValueToLogTypes.LAST_5);
ValueToLogTypes.LAST_5
);
// Assert
expect(expectedDataLayer).toEqual(expect.arrayContaining(window.dataLayer));

View file

@ -100,7 +100,8 @@ export default {
));
// set the answerString to use for answerSelected
if (chosenAns.nextQuestionSequence) {
answerString = `${answeredQuestion.questionNum}|nextQuestion|${chosenAns.nextQuestionSequence}|${chosenAns.answerText}`;
answerString =
`${answeredQuestion.questionNum}|nextQuestion|${chosenAns.nextQuestionSequence}|${chosenAns.answerText}`;
} else {
answerString = `${answeredQuestion.questionNum}|answer|${chosenAns.answerResult}|${chosenAns.answerText}`;
}
@ -276,16 +277,12 @@ export default {
// update questions that lead to duplicated question
if (matchedAnswer.nextQuestionSequence) {
a.originalNextQuestionSequence
= a.nextQuestionSequence;
a.nextQuestionSequence
= matchedAnswer.nextQuestionSequence;
a.originalNextQuestionSequence = a.nextQuestionSequence;
a.nextQuestionSequence = matchedAnswer.nextQuestionSequence;
} else {
a.originalNextQuestionSequence
= a.nextQuestionSequence;
a.originalNextQuestionSequence = a.nextQuestionSequence;
a.nextQuestionSequence = null;
a.originalAnswerResult
= a.originalAnswerResult || a.answerResult;
a.originalAnswerResult = a.originalAnswerResult || a.answerResult;
a.answerResult = matchedAnswer.answerResult;
}
}
@ -359,22 +356,26 @@ export default {
} else if (hasGlassLocationWithMultipleParts && this.currentPageComesBeforePage(currentPage, issPageValues.VEHICLE_PARTS)) {
// if multiple parts on any glass
// go to vehicle-parts page and pass the partsData
self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
self.$router.navigate(
self.navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
self.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
} else if (
hasChildPartQuestions
&& this.currentPageComesBeforePage(currentPage, issPageValues.MOLDING_QUESTIONS)
) {
// if any childpart questions
// go to molding-questions page and pass the partsData
self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
self.$router.navigate(
self.navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
self.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
} else if (
hasCapabilityQuestions
&& this.currentPageComesBeforePage(currentPage, issPageValues.CAPABILITY_QUESTIONS)
@ -386,7 +387,9 @@ export default {
// eslint-disable-next-line no-restricted-syntax
for (const partOrQuestion of partsOrQuestions) {
if (this.hasCapabilityQuestions([partOrQuestion])) {
const capabilityQuestionsForGlassLocation = (await useMainStore().getCapabilityQuestions(useMainStore().vehicle.carId, partOrQuestion.parts[0].partNumber)).data;
const capabilityQuestionsForGlassLocation =
(await useMainStore()
.getCapabilityQuestions(useMainStore().vehicle.carId, partOrQuestion.parts[0].partNumber)).data;
capabilityQuestionsForGlassLocation.forEach((question) => {
question.answers = question.answers.map((answer) => ({
@ -399,11 +402,13 @@ export default {
}
}
self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
self.$router.navigate(
self.navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
self.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
} else {
// if single parts only
const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions);

View file

@ -334,7 +334,8 @@ describe('vehicle-questions-mixin', () => {
[issPageValues.PART_QUESTIONS, issPageValues.CAPABILITY_QUESTIONS, true],
[issPageValues.MOLDING_QUESTIONS, issPageValues.CAPABILITY_QUESTIONS, true]
];
test.each(testCases)('%s comes before %s is %s',
test.each(testCases)(
'%s comes before %s is %s',
(currentPage, nextPage, expectedResult) => {
// Arrange
const { wrapper } = setupMocks({});
@ -344,7 +345,8 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(result).toEqual(expectedResult);
});
}
);
});
describe('currentPageComesAfterPage', () => {
@ -432,9 +434,11 @@ describe('vehicle-questions-mixin', () => {
const { wrapper } = setupMocks({});
// Act
const returnedGlass = await wrapper.vm.setupInitialData(glass,
const returnedGlass = await wrapper.vm.setupInitialData(
glass,
i,
alreadyAnsweredQuestions);
alreadyAnsweredQuestions
);
// Assert
expect(returnedGlass.answerData).toMatchObject({ answerResult: 'WKT D1106 C' });
@ -580,6 +584,7 @@ describe('vehicle-questions-mixin', () => {
{
questionSequence: 1,
questionText:
// eslint-disable-next-line max-len
'Is your vehicle equipped with the Panoramic Sunroof which can be identified by having a glass panel over the rear seats?',
answers: [
{
@ -598,6 +603,7 @@ describe('vehicle-questions-mixin', () => {
{
questionSequence: 2,
questionText:
// eslint-disable-next-line max-len
'Is your vehicle equipped with a heated windshield that melts snow and ice from underneath the windshield wiper blades?',
answers: [
{
@ -1118,114 +1124,118 @@ describe('vehicle-questions-mixin', () => {
});
describe('and the duplicate has an answerResult', () => {
test("then any questions in the same glass piece that lead to the duplicate should be modified to just provide the duplicate's answerResult", async () => {
test(
// eslint-disable-next-line max-len
'then any questions in the same glass piece that lead to the duplicate should be modified to just provide the duplicate\'s answerResult',
async () => {
// Arrange
const answerNo = {
answerResult: '456',
answeredQuestions: [
const answerNo = {
answerResult: '456',
answeredQuestions: [
{
questionText: 'Test question 3?',
selectedAnswerText: 'No',
questionNum: 1
}
],
index: 0
};
const { wrapper } = setupMocks({});
wrapper.vm.questionsData = [
{
questionText: 'Test question 3?',
selectedAnswerText: 'No',
questionNum: 1
glassLocation: 'Windshield',
glassName: 'Single',
questions: [
{
questionSequence: 1,
questionText: 'Test question 3?',
answers: [
{
answerResult: '123',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: '456',
answerText: 'No',
nextQuestionSequence: null
}
]
}
]
},
{
glassLocation: 'Driver',
glassName: 'Front',
questions: [
{
questionSequence: 1,
questionText: 'Test question 1?',
answers: [
{
answerResult: '',
answerText: 'Yes',
nextQuestionSequence: 2
},
{
answerResult: '',
answerText: 'No',
nextQuestionSequence: 3
}
]
},
{
questionSequence: 2,
questionText: 'Test question 2?',
answers: [
{
answerResult: '123',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: '234',
answerText: 'No',
nextQuestionSequence: null
}
]
},
{
questionSequence: 3,
questionText: 'Test question 3?',
answers: [
{
answerResult: '345',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: '456',
answerText: 'No',
nextQuestionSequence: null
}
]
}
]
}
],
index: 0
};
const { wrapper } = setupMocks({});
];
wrapper.vm.questionsData = [
{
glassLocation: 'Windshield',
glassName: 'Single',
questions: [
{
questionSequence: 1,
questionText: 'Test question 3?',
answers: [
{
answerResult: '123',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: '456',
answerText: 'No',
nextQuestionSequence: null
}
]
}
]
},
{
glassLocation: 'Driver',
glassName: 'Front',
questions: [
{
questionSequence: 1,
questionText: 'Test question 1?',
answers: [
{
answerResult: '',
answerText: 'Yes',
nextQuestionSequence: 2
},
{
answerResult: '',
answerText: 'No',
nextQuestionSequence: 3
}
]
},
{
questionSequence: 2,
questionText: 'Test question 2?',
answers: [
{
answerResult: '123',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: '234',
answerText: 'No',
nextQuestionSequence: null
}
]
},
{
questionSequence: 3,
questionText: 'Test question 3?',
answers: [
{
answerResult: '345',
answerText: 'Yes',
nextQuestionSequence: null
},
{
answerResult: '456',
answerText: 'No',
nextQuestionSequence: null
}
]
}
]
}
];
// Act
await wrapper.vm.handleAnswerUpdates(answerNo, '', wrapper.vm);
// Act
await wrapper.vm.handleAnswerUpdates(answerNo, '', wrapper.vm);
const questionsToTest = wrapper.vm.questionsData[1].questions;
const answerLeadingToDuplicate = questionsToTest[0].answers[1];
const duplicateQuestion = questionsToTest[2];
const answerInDuplicateQuestion = duplicateQuestion.answers.filter((a) => a.selected);
const questionsToTest = wrapper.vm.questionsData[1].questions;
const answerLeadingToDuplicate = questionsToTest[0].answers[1];
const duplicateQuestion = questionsToTest[2];
const answerInDuplicateQuestion = duplicateQuestion.answers.filter((a) => a.selected);
// Assert
expect(answerLeadingToDuplicate.answerResult).toEqual(answerInDuplicateQuestion[0].answerResult);
expect(answerLeadingToDuplicate.originalAnswerResult).toBeFalsy();
expect(answerLeadingToDuplicate.nextQuestionSequence).toEqual(null);
expect(answerLeadingToDuplicate.originalNextQuestionSequence).toEqual(duplicateQuestion.questionSequence);
});
// Assert
expect(answerLeadingToDuplicate.answerResult).toEqual(answerInDuplicateQuestion[0].answerResult);
expect(answerLeadingToDuplicate.originalAnswerResult).toBeFalsy();
expect(answerLeadingToDuplicate.nextQuestionSequence).toEqual(null);
expect(answerLeadingToDuplicate.originalNextQuestionSequence).toEqual(duplicateQuestion.questionSequence);
}
);
});
});
});
@ -1270,11 +1280,13 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
test('multiple glass locations have part questions => go to parts-questions', async () => {
@ -1383,11 +1395,13 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
test('multiple glass locations selected, one has part question => go to parts-questions', async () => {
@ -1488,11 +1502,13 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
test('a selected glass location has part questions and multiple parts => go to parts-questions', async () => {
@ -1641,11 +1657,13 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
});
@ -1687,11 +1705,13 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
test('multiple glass locations selected, one of them has multiple parts => go to vehicle parts', async () => {
@ -1797,11 +1817,13 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
test('multiple glass locations selected, multiple have multiple parts => go to vehicle-parts', async () => {
@ -1973,11 +1995,13 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
});
@ -2030,52 +2054,59 @@ describe('vehicle-questions-mixin', () => {
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
{ partsOrQuestions }
);
});
});
describe('should go to capability-questions', () => {
test('single glass location has no child part questions but requiresCapabilityQuestions is true => go to capability-questions', async () => {
test(
'single glass location has no child part questions but requiresCapabilityQuestions is true => go to capability-questions',
async () => {
// Arrange
const partsOrQuestions = [
{
glassName: 'Single',
glassLocation: 'Windshield',
parts: [
{
partNumber: 'FB25724GTYN',
description: 'heated glass, solar, antenna',
color: 'Green Tint',
requiresRecalibration: false,
requiresCapabilityQuestions: true,
childParts: null,
childPartQuestions: null
}
],
capabilityQuestions: [],
partQuestions: null
}
];
const partsOrQuestions = [
{
glassName: 'Single',
glassLocation: 'Windshield',
parts: [
{
partNumber: 'FB25724GTYN',
description: 'heated glass, solar, antenna',
color: 'Green Tint',
requiresRecalibration: false,
requiresCapabilityQuestions: true,
childParts: null,
childPartQuestions: null
}
],
capabilityQuestions: [],
partQuestions: null
}
];
const { wrapper } = setupMocks({
partsOrQuestions
});
const { wrapper } = setupMocks({
partsOrQuestions
});
// Act
await wrapper.vm.navigateForward(partsOrQuestions);
// Act
await wrapper.vm.navigateForward(partsOrQuestions);
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions });
});
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
wrapper.vm.$route,
{},
{},
{ partsOrQuestions }
);
}
);
});
});
@ -2089,25 +2120,33 @@ describe('vehicle-questions-mixin', () => {
wrapper.vm.navigateBack();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_REPAIR,
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } });
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_REPAIR,
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
);
});
test('current page is molding questions and there are part questions, multiple parts to choose, and capability questions => go to vehicle-parts', () => {
test(
// eslint-disable-next-line max-len
'current page is molding questions and there are part questions, multiple parts to choose, and capability questions => go to vehicle-parts',
() => {
// Arrange
const { wrapper } = setupMocks({ issPage: issPageValues.MOLDING_QUESTIONS });
wrapper.vm.hasPartQuestions = jest.fn().mockReturnValue(true);
wrapper.vm.hasGlassLocationWithMultipleParts = jest.fn().mockReturnValue(true);
wrapper.vm.hasChildPartQuestions = jest.fn().mockReturnValue(true);
wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true);
const { wrapper } = setupMocks({ issPage: issPageValues.MOLDING_QUESTIONS });
wrapper.vm.hasPartQuestions = jest.fn().mockReturnValue(true);
wrapper.vm.hasGlassLocationWithMultipleParts = jest.fn().mockReturnValue(true);
wrapper.vm.hasChildPartQuestions = jest.fn().mockReturnValue(true);
wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true);
// Act
wrapper.vm.navigateBack();
// Act
wrapper.vm.navigateBack();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE,
{ query: { issPage: issPageValues.MOLDING_QUESTIONS } });
});
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE,
{ query: { issPage: issPageValues.MOLDING_QUESTIONS } }
);
}
);
test('current page is molding questions and there are part questions and capability questions => go to part-questions', () => {
// Arrange
@ -2121,8 +2160,10 @@ describe('vehicle-questions-mixin', () => {
wrapper.vm.navigateBack();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS,
{ query: { issPage: issPageValues.MOLDING_QUESTIONS } });
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS,
{ query: { issPage: issPageValues.MOLDING_QUESTIONS } }
);
});
});
});

View file

@ -119,7 +119,8 @@ async function GetRouteInfoFromPageName(pageName) {
}
// Use this navigation when you need to call next() explicitly. beforeRouteEnter is a good example.
router.overrideNavigation = (scenario,
router.overrideNavigation = (
scenario,
currentRoute,
next,
isSavingNavigation,
@ -131,24 +132,29 @@ router.overrideNavigation = (scenario,
isSavingNavigation,
optionalQuery,
optionalParams,
optionalPageData);
optionalPageData
);
next();
};
router.navigate = (scenario,
router.navigate = (
scenario,
currentRoute,
optionalQuery = {},
optionalParams = {},
optionalPageData = {}) => {
optionalPageData = {}
) => {
navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData);
};
// Navigate to the next route, depending on the scenario.
function navigate(scenario,
function navigate(
scenario,
currentRoute,
optionalQuery = {},
optionalParams = {},
optionalPageData = {}) {
optionalPageData = {}
) {
/*eslint-disable-line*/
if (!scenario) {
window.console.error('No scenario provided. Please review the routing table.');
@ -171,10 +177,12 @@ function navigate(scenario,
} else if (matchingScenarioMap.destinationIssPageValue) {
// Update page data to the store for next page if provided. Otherwise, keep existing page data or set to empty object
const existingPageDataForPage = useMainStore().pageData(matchingScenarioMap.destinationIssPageValue);
baseMixin.methods.savePageDataToStore(matchingScenarioMap.destinationIssPageValue,
baseMixin.methods.savePageDataToStore(
matchingScenarioMap.destinationIssPageValue,
Object.keys(optionalPageData).length > 0
? optionalPageData
: existingPageDataForPage ?? {});
: existingPageDataForPage ?? {}
);
// We're always pushing the same path, just changing query strings.
// Make sure our optional query strings get combined with our issPage one.
@ -229,14 +237,16 @@ function GoToStartOn404(next) {
});
// Put item on the bus
eventBus.addEventToBus(globalEvents.Categories.GLOBAL_ALERT,
eventBus.addEventToBus(
globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND,
{
isDismissible: true,
messageCopy: 'You can get a quote by starting on this page.',
messageHeadline: "We're sorry, something went wrong.",
type: globalEventTypes.Danger
});
}
);
next({
name: errorPageName,

View file

@ -71,7 +71,7 @@ describe('Store', () => {
expect(store.applicationUser.eventBus.length).toBe(1);
// Act
store.removeEventFromBus({ category: event.category, subCategory: event.subCategory })
store.removeEventFromBus({ category: event.category, subCategory: event.subCategory });
// Assert
expect(store.applicationUser.eventBus.length).toBe(0);
@ -200,7 +200,8 @@ describe('Store', () => {
it.each([
[true, coverageStatuses.NO_COMP],
[false, coverageStatuses.PENDING]
])('UpdateVehicle should set coverageStatus appropriately based on noCoverage value',
])(
'UpdateVehicle should set coverageStatus appropriately based on noCoverage value',
(expectedNoCoverage, expectedCoverageStatus) => {
// Arrange
const vehicle = {
@ -213,7 +214,8 @@ describe('Store', () => {
// Assert
expect(store.order.policy.noCoverage).toBe(expectedNoCoverage);
expect(store.order.payment.insuranceCoverage.coverageStatus).toBe(expectedCoverageStatus);
});
}
);
// TODO update test to work also checking store values
it('setVehicle should call globalMethods.callHttpClient', () => {

View file

@ -50,7 +50,8 @@ function setupMocks(mountOptionsMockData = {}) {
describe('alert.vue', () => {
it("Should add class 'alert-dismissible' if isDismissible is true", async () => {
// Arrange
const wrapper = shallowMount(alert,
const wrapper = shallowMount(
alert,
setupMocks({
propsData: {
isDismissible: true,
@ -58,7 +59,8 @@ describe('alert.vue', () => {
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
}
}));
})
);
const wrapperDiv = wrapper.find('div');
@ -68,7 +70,8 @@ describe('alert.vue', () => {
it('Should add specified alert class', async () => {
// Arrange
const wrapper = shallowMount(alert,
const wrapper = shallowMount(
alert,
setupMocks({
propsData: {
alertClass: 'warning',
@ -76,7 +79,8 @@ describe('alert.vue', () => {
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
}
}));
})
);
const wrapperDiv = wrapper.find('div');
@ -94,21 +98,24 @@ describe('alert.vue', () => {
it('Should container a <router-link> tag if the manualCopy contains a {routerLink: testName, testLink} placeholder', () => {
// Arrange & Act
const wrapper = shallowMount(alert,
const wrapper = shallowMount(
alert,
setupMocks({
propsData: {
manualHeadline: 'testHeader',
manualCopy: 'testCopy with a {routerLink: testName, testLink} inside of it',
cmsWidgetName: 'alert'
}
}));
})
);
// Assert
expect(wrapper.findComponent(RouterLinkStub).exists()).toBe(true);
});
it("Should contain 'n+1' <p> tags if the body copy has 'n' <p> tags", () => {
// Arrange & Act
const wrapper = shallowMount(alert,
const wrapper = shallowMount(
alert,
setupMocks({
propsData: {
manualHeadline: 'testHeader',
@ -116,7 +123,8 @@ describe('alert.vue', () => {
'<p>testCopy with a {routerLink: testName, testLink} inside of it</p><p>and two paragraphs</p>',
cmsWidgetName: 'alert'
}
}));
})
);
// Assert
expect(wrapper.findAll('p').length === 3).toBe(true);
});
@ -172,7 +180,8 @@ describe('alert.vue', () => {
Element.prototype.scrollIntoView = mockScrollIntoView;
// Act
shallowMount(alert,
shallowMount(
alert,
setupMocks({
propsData: {
shouldScrollToOnMount: false,
@ -180,7 +189,8 @@ describe('alert.vue', () => {
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
}
}));
})
);
// Assert
// This is an implementation detail - we just need to test that the final step of snapping

View file

@ -15,12 +15,14 @@ function setupMocks(mountOptionsMockData = {}) {
describe('buttonMain.vue', () => {
it('Should return btn-primary class', async () => {
// Act
const wrapper = shallowMount(buttonMain,
const wrapper = shallowMount(
buttonMain,
setupMocks({
propsData: {
isPrimary: true
}
}));
})
);
// Assert
const button = wrapper.find('button');
@ -31,12 +33,14 @@ describe('buttonMain.vue', () => {
it('Should return aria-disabled state', async () => {
// Act
const wrapper = shallowMount(buttonMain,
const wrapper = shallowMount(
buttonMain,
setupMocks({
propsData: {
isDisabled: true
}
}));
})
);
// Assert
const button = wrapper.find('button');
@ -47,13 +51,15 @@ describe('buttonMain.vue', () => {
it('Should return loader color', async () => {
// Act
const wrapper = shallowMount(buttonMain,
const wrapper = shallowMount(
buttonMain,
setupMocks({
propsData: {
loaderColor: 'blue',
loaderEnabled: true
}
}));
})
);
// Assert
@ -68,13 +74,15 @@ describe('buttonMain.vue', () => {
it('Should return loader position', async () => {
// Act
const wrapper = shallowMount(buttonMain,
const wrapper = shallowMount(
buttonMain,
setupMocks({
propsData: {
loaderPosition: 'right',
loaderEnabled: true
}
}));
})
);
// Assert

View file

@ -15,12 +15,14 @@ function setupMocks(mountOptionsMockData = {}) {
describe('modal-button-main.vue', () => {
it('Should return btn-primary class', () => {
// Arrange/Act
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
isPrimary: true
}
}));
})
);
const button = wrapper.find('button');
// Assert
@ -29,12 +31,14 @@ describe('modal-button-main.vue', () => {
it('Should return aria-disabled state', () => {
// Arrange/Act
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
isDisabled: true
}
}));
})
);
const button = wrapper.find('button');
// Assert
@ -43,13 +47,15 @@ describe('modal-button-main.vue', () => {
it('Should return loader color', async () => {
// Arrange
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
loaderColor: 'blue',
loaderEnabled: true
}
}));
})
);
// Act
wrapper.vm.clicked();
@ -63,13 +69,15 @@ describe('modal-button-main.vue', () => {
it('Should return loader position', async () => {
// Arrange
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
loaderPosition: 'right',
loaderEnabled: true
}
}));
})
);
// Act
wrapper.vm.clicked();
@ -82,13 +90,15 @@ describe('modal-button-main.vue', () => {
it("Should set 'isLoaderDisplayed' to false when calling 'removeLoader'", async () => {
// Arrange
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
loaderPosition: 'right',
loaderEnabled: true
}
}));
})
);
wrapper.setData({
isLoaderDisplayed: true
@ -104,13 +114,15 @@ describe('modal-button-main.vue', () => {
it("Should set 'isLoaderDisplayed' to false when calling 'resetButtonStyle'", async () => {
// Arrange
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
loaderPosition: 'right',
loaderEnabled: true
}
}));
})
);
wrapper.setData({
isLoaderDisplayed: true
@ -126,14 +138,16 @@ describe('modal-button-main.vue', () => {
it("Should emit 'click-event' event when clicking if the button is enabled", async () => {
// Arrange
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
loaderPosition: 'right',
loaderEnabled: true,
isDisabled: false
}
}));
})
);
const buttonElement = wrapper.find('button');
@ -148,14 +162,16 @@ describe('modal-button-main.vue', () => {
it("Should not emit 'click-event' event when clicking if the button is disabled", async () => {
// Arrange
const wrapper = shallowMount(modalButtonMain,
const wrapper = shallowMount(
modalButtonMain,
setupMocks({
propsData: {
loaderPosition: 'right',
loaderEnabled: true,
isDisabled: true
}
}));
})
);
const buttonElement = wrapper.find('button');

View file

@ -45,10 +45,12 @@ export default {
this.isLoaderDisplayed = false;
},
clicked() {
this.pushEventToGA(this.$route.query[this.queryStrings.ISS_PAGE],
this.pushEventToGA(
this.$route.query[this.queryStrings.ISS_PAGE],
this.GaActions.CLICKED,
this.buttonText,
true);
true
);
if (!this.isDisabled) {
this.isLoaderDisplayed = true;
this.$emit('click-event');

View file

@ -42,10 +42,12 @@ export default {
emits: ['click-event'],
methods: {
handleClick() {
this.pushEventToGA(this.$route.query[this.queryStrings.ISS_PAGE],
this.pushEventToGA(
this.$route.query[this.queryStrings.ISS_PAGE],
this.GaActions.CLICKED,
this.text,
true);
true
);
this.$emit('click-event');
}
}