Merge pull request #425 from Safelite/refactor/linting9

Final eslint baseline PR  linting 9 !
This commit is contained in:
Jeremy-Z 2023-08-29 09:12:03 -04:00 committed by GitHub
commit 9af9faca33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 1270 additions and 813 deletions

View file

@ -27,6 +27,7 @@ const errorMessages = Object.freeze({
SERVICE_ZIP_FORMAT: 'Please enter a valid service ZIP', SERVICE_ZIP_FORMAT: 'Please enter a valid service ZIP',
VIN_REQUIRED: 'Please enter your VIN', VIN_REQUIRED: 'Please enter your VIN',
VIN_FORMAT: 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', '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', OPTION_REQUIRED: 'Please select an option',
VEHICLE_REQUIRED: 'Please select a vehicle', VEHICLE_REQUIRED: 'Please select a vehicle',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,10 +7,54 @@ import { getMountOptions } from '@/helpers/unit-test-helper.js';
jest.mock('axios'); jest.mock('axios');
jest.mock('@/mixins/analytics-mixin'); 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', () => { it('Global Methods - Call Http Client - Should Resolve Promise', () => {
// Arrange // Arrange
const endpoint = 'https://mock.safelite.com'; const endpoint = 'https://mock.safelite.com';
const httpArgs = setupMocksForHttpClient({ endpoint: endpoint }); const httpArgs = setupMocksForHttpClient({ endpoint });
// Act // Act
globalMethods.callHttpClient(httpArgs).then((response) => { globalMethods.callHttpClient(httpArgs).then((response) => {
@ -25,7 +69,7 @@ it('Global Methods - Call Http Client - Should Reject Promise', () => {
// Arrange // Arrange
const endpoint = 'https://mock.safelite.com'; const endpoint = 'https://mock.safelite.com';
const httpArgs = setupMocksForHttpClient({ const httpArgs = setupMocksForHttpClient({
endpoint: endpoint, endpoint,
isError: true isError: true
}); });
analyticsMixIn.methods.pushEventToGA = jest.fn(); analyticsMixIn.methods.pushEventToGA = jest.fn();
@ -38,46 +82,3 @@ it('Global Methods - Call Http Client - Should Reject Promise', () => {
expect(err.status).toEqual(500); 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(); const store = useMainStore();
return store.validateClientTag(clientTag) return store.validateClientTag(clientTag)
.then((response) => .then(
// Success (response) => response,
response, () => null
// Error );
() => null);
}; };
export default validateISSClientTag; export default validateISSClientTag;

View file

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

View file

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

View file

@ -9,10 +9,14 @@ import { required, regex } from '@/helpers/validation-rules';
function defineGlobalNameRules() { function defineGlobalNameRules() {
defineRule(globalRules.FIRST_NAME_REQUIRED, required(errorMessages.FIRST_NAME_REQUIRED)); defineRule(globalRules.FIRST_NAME_REQUIRED, required(errorMessages.FIRST_NAME_REQUIRED));
defineRule(globalRules.LAST_NAME_REQUIRED, required(errorMessages.LAST_NAME_REQUIRED)); defineRule(globalRules.LAST_NAME_REQUIRED, required(errorMessages.LAST_NAME_REQUIRED));
defineRule(globalRules.POLICYHOLDER_FIRST_NAME_REQUIRED, defineRule(
required(errorMessages.POLICYHOLDER_FIRST_NAME_REQUIRED)); globalRules.POLICYHOLDER_FIRST_NAME_REQUIRED,
defineRule(globalRules.POLICYHOLDER_LAST_NAME_REQUIRED, required(errorMessages.POLICYHOLDER_FIRST_NAME_REQUIRED)
required(errorMessages.POLICYHOLDER_LAST_NAME_REQUIRED)); );
defineRule(
globalRules.POLICYHOLDER_LAST_NAME_REQUIRED,
required(errorMessages.POLICYHOLDER_LAST_NAME_REQUIRED)
);
} }
/** /**
@ -20,9 +24,13 @@ function defineGlobalNameRules() {
*/ */
function defineGlobalEmailRules() { function defineGlobalEmailRules() {
defineRule(globalRules.EMAIL_ADDRESS_REQUIRED, required(errorMessages.EMAIL_ADDRESS_REQUIRED)); defineRule(globalRules.EMAIL_ADDRESS_REQUIRED, required(errorMessages.EMAIL_ADDRESS_REQUIRED));
defineRule(globalRules.EMAIL_ADDRESS_FORMAT, defineRule(
regex(/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/, globalRules.EMAIL_ADDRESS_FORMAT,
errorMessages.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() { function defineGlobalPhoneNumberRules() {
defineRule(globalRules.PHONE_NUMBER_REQUIRED, required(errorMessages.PHONE_NUMBER_REQUIRED)); defineRule(globalRules.PHONE_NUMBER_REQUIRED, required(errorMessages.PHONE_NUMBER_REQUIRED));
defineRule(globalRules.PHONE_NUMBER_FORMAT, defineRule(
regex(/^(\([0-9]{3}\)|[0-9]{3}) *[-.]? *[0-9]{3} *[-.]? *[0-9]{4}$/, globalRules.PHONE_NUMBER_FORMAT,
errorMessages.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' // Pull our keys out of the promise 'table'
const promiseNames = Object.entries(promiseResultMap); const promiseNames = Object.entries(promiseResultMap);
@ -22,4 +22,6 @@ export function settleAllPromises(promiseResultMap) {
return resultMap; 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', () => { it('layout-helper: Should settle all promises and return mapped promise results', () => {
// Arrange // Arrange

View file

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

View file

@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import { RouterLinkStub } from '@vue/test-utils'; import { RouterLinkStub } from '@vue/test-utils';
import { createTestingPinia } from '@pinia/testing'; import { createTestingPinia } from '@pinia/testing';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js'; import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
@ -59,7 +60,9 @@ export function getMountOptions(mockData) {
// Heritage integration common methods // Heritage integration common methods
export const cookies = { 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', UNIQUE_SESSION_ID: '33756020-b58e-4ec7-b8b8-3f1576719c40',
anotherCookie: '{}', anotherCookie: '{}',
someOtherCookie: '{}', someOtherCookie: '{}',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -58,8 +58,10 @@ export default {
emits: ['update: modelValue'], emits: ['update: modelValue'],
computed: { computed: {
differentVehicleAlertHeader() { differentVehicleAlertHeader() {
return this.getCmsContent('AlertMatchedDifferentVehicleWidget', 'HeadlineText').replaceAll('{custom:damage}', return this.getCmsContent(
getDamageString()); 'AlertMatchedDifferentVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
}, },
differentVehicleAlertBody() { differentVehicleAlertBody() {
const vinYmmFound = const vinYmmFound =
@ -73,11 +75,14 @@ export default {
.replaceAll('{custom:vinYmmExpected}', vinYmmExpected); .replaceAll('{custom:vinYmmExpected}', vinYmmExpected);
}, },
AlertMatchedTwoIdenticalYMMVehicleHeader() { AlertMatchedTwoIdenticalYMMVehicleHeader() {
return this.getCmsContent('AlertMatchedTwoIdenticalYMMVehicleWidget', return this.getCmsContent(
'HeadlineText').replaceAll('{custom:damage}', getDamageString()); 'AlertMatchedTwoIdenticalYMMVehicleWidget',
'HeadlineText'
).replaceAll('{custom:damage}', getDamageString());
}, },
AlertMatchedTwoIdenticalYMMVehicleBody() { AlertMatchedTwoIdenticalYMMVehicleBody() {
const vinYmmsFound = const vinYmmsFound =
// eslint-disable-next-line max-len
`${this.selectedVehicle?.vehicle.year} ${this.selectedVehicle?.vehicle.make} ${this.selectedVehicle?.vehicle.model} ${this.selectedVehicle?.vehicle.style}`; `${this.selectedVehicle?.vehicle.year} ${this.selectedVehicle?.vehicle.make} ${this.selectedVehicle?.vehicle.model} ${this.selectedVehicle?.vehicle.style}`;
const vinYmmsExpected = const vinYmmsExpected =
`${this.vehicleSelected?.year} ${this.vehicleSelected?.make} ${this.vehicleSelected?.model} ${this.vehicleSelected?.style}`; `${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 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 { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -21,9 +21,7 @@ jest.mock('@/helpers/cms-content-helper', () => ({
})); }));
// Mock our module for promises. // Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
settleAllPromises: jest.fn()
}));
function setupMocks({ function setupMocks({
route = null, route = null,
@ -209,7 +207,8 @@ describe('address-vehicles.vue', () => {
// Assert // Assert
expect(wrapper.vm.$router.navigate).toBeCalledTimes(1); 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 () => { test('carId is not different on navigateForward (car was found) => Should handle navigating forward with car match', async () => {
// Arrange // Arrange
@ -233,10 +232,12 @@ describe('address-vehicles.vue', () => {
useMainStore().order.vehicle.carId = 'CR00000395'; useMainStore().order.vehicle.carId = 'CR00000395';
// Act // Act
addressVehicles.beforeRouteEnter.call(wrapper.vm, addressVehicles.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'address-vehicles' } }, { query: { issPage: 'address-vehicles' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();

View file

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

View file

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

View file

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

View file

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

View file

@ -205,8 +205,10 @@ export default {
notesForTechnician: this.notesForTechnician notesForTechnician: this.notesForTechnician
}; };
useMainStore().updateContactInfo(contactInfo); useMainStore().updateContactInfo(contactInfo);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$router.navigate(
this.$route); 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 { createTestingPinia } from '@pinia/testing';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js'; import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
import { getRandomString, getRandomInt } from '@/helpers/data-generation.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'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
jest.mock('@/helpers/layout-helper.js', () => ({ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
settleAllPromises: jest.fn()
}));
jest.mock('@/helpers/cms-content-helper', () => ({ jest.mock('@/helpers/cms-content-helper', () => ({
fetchCmsContentForPage: jest.fn(), fetchCmsContentForPage: jest.fn(),

View file

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

View file

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

View file

@ -36,8 +36,10 @@ export default {
methods: methods:
{ {
navigateForward() { navigateForward() {
this.$router.navigate(this.navigationScenarios.MOVE_FORWARD_ENTRY_PAGE, this.$router.navigate(
this.$route); this.navigationScenarios.MOVE_FORWARD_ENTRY_PAGE,
this.$route
);
}, },
parseQueryParms() { parseQueryParms() {
// Dump the query string parameters into an array. Remove casing on the key for easy compare. // 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'; import licensePlateLookup from '@/layouts/license-plate-lookup/license-plate-lookup.vue';
// Supporting Files // Supporting Files
import { settleAllPromises } from '@/helpers/layout-helper.js'; import settleAllPromises from '@/helpers/layout-helper.js';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -14,9 +14,7 @@ jest.mock('@/helpers/damage-helper', () => ({
})); }));
// Mock our module for promises. // Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
settleAllPromises: jest.fn()
}));
// Mock fetchCmsContentForPage // Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({ jest.mock('@/helpers/cms-content-helper', () => ({
@ -57,7 +55,8 @@ function setupMocks({
} }
})); }));
const wrapper = shallowMount(licensePlateLookup, const wrapper = shallowMount(
licensePlateLookup,
getMountOptions({ getMountOptions({
route: route || undefined, route: route || undefined,
router: { router: {
@ -75,7 +74,8 @@ function setupMocks({
} }
} }
})); })
);
const apiResponses = { const apiResponses = {
serviceZipValidationResponse: { serviceZipValidationResponse: {
@ -183,10 +183,12 @@ describe('license-plate-lookup.vue', () => {
} }
}); });
// Act // Act
licensePlateLookup.beforeRouteEnter.call(wrapper.vm, licensePlateLookup.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'license-plate-lookup' } }, { query: { issPage: 'license-plate-lookup' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
await wrapper.vm.backButtonAction(); await wrapper.vm.backButtonAction();
// Assert // Assert
@ -242,11 +244,14 @@ describe('license-plate-lookup.vue', () => {
await wrapper.vm.navigateForward(carsFound); await wrapper.vm.navigateForward(carsFound);
// Assert // 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, undefined,
{}, {},
{ displayVehicleChangeAlert: true }); { displayVehicleChangeAlert: true }
}); );
}
);
}); });
describe('miscellaneous', () => { describe('miscellaneous', () => {
@ -256,10 +261,12 @@ describe('license-plate-lookup.vue', () => {
useMainStore().order.vehicle.carId = 'CR00000395'; useMainStore().order.vehicle.carId = 'CR00000395';
// Act // Act
licensePlateLookup.beforeRouteEnter.call(wrapper.vm, licensePlateLookup.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'license-plate-lookup' } }, { query: { issPage: 'license-plate-lookup' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();

View file

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

View file

@ -22,7 +22,7 @@
<script> <script>
// Import Supporting Files // Import Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; 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 globalRules from '@/constants/global-rules';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -70,8 +70,10 @@ export default {
}, },
computed: { computed: {
AlertFewMoreQuestionsHeader() { AlertFewMoreQuestionsHeader() {
return this.getCmsContent('AdditionalPartsQuestionsAlert', return this.getCmsContent(
'HeadlineText'); 'AdditionalPartsQuestionsAlert',
'HeadlineText'
);
}, },
AlertFewMoreQuestionsCopy() { AlertFewMoreQuestionsCopy() {
return this.getCmsContent('AdditionalPartsQuestionsAlert', 'BodyText'); return this.getCmsContent('AdditionalPartsQuestionsAlert', 'BodyText');
@ -105,18 +107,24 @@ export default {
glass.answerKey = `${glass.glassLocation}-${glass.glassName}`; glass.answerKey = `${glass.glassLocation}-${glass.glassName}`;
// reset selectedAnswers for this glass // reset selectedAnswers for this glass
this.selectedAnswers[glass.answerKey] = []; this.selectedAnswers[glass.answerKey] = [];
const updatedGlass = this.setupInitialData(glass, const updatedGlass = this.setupInitialData(
glass,
index, index,
alreadyAnsweredQuestions); alreadyAnsweredQuestions
);
// Set up watch for each set of glass questions // Set up watch for each set of glass questions
this.$watch(`selectedAnswers.${glass.answerKey}`, this.$watch(
`selectedAnswers.${glass.answerKey}`,
(newValue) => { (newValue) => {
if (newValue && Object.keys(newValue).length > 0) { if (newValue && Object.keys(newValue).length > 0) {
this.handleAnswerUpdates(newValue, this.handleAnswerUpdates(
glass.answerKey); newValue,
glass.answerKey
);
} }
}, },
{ deep: true }); { deep: true }
);
return updatedGlass; 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'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
@ -63,8 +63,10 @@ export default {
return this.navigateForward(); return this.navigateForward();
}, },
navigateForward() { navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$router.navigate(
this.$route); this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
} }
} }
}; };

View file

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

View file

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

View file

@ -27,7 +27,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';

View file

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

View file

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

View file

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

View file

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

View file

@ -107,7 +107,8 @@ describe('provider-pref-radio.vue', () => {
const fileredResults = results.filter((result) => result.includes(' -')); const fileredResults = results.filter((result) => result.includes(' -'));
expect(fileredResults.length).toBe(0); 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 () => { async () => {
// Arrange // Arrange
const moddedProps = mockProps; const moddedProps = mockProps;
@ -123,5 +124,6 @@ describe('provider-pref-radio.vue', () => {
// Assert // Assert
expect(results.length).toBe(5); expect(results.length).toBe(5);
}); }
);
}); });

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,11 @@
import { shallowMount } from '@vue/test-utils'; 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 { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import tpaRecalModal from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-modal.vue'; import tpaRecalModal from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-modal.vue';
// Mock our module for promises. // Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
settleAllPromises: jest.fn()
}));
// Mock fetchCmsContentForPage // Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({ jest.mock('@/helpers/cms-content-helper', () => ({
@ -23,8 +21,10 @@ function setupMocks() {
} }
}); });
const wrapper = shallowMount(tpaRecalModal, const wrapper = shallowMount(
mountOptions); tpaRecalModal,
mountOptions
);
const apiResponses = {}; 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'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -68,8 +68,10 @@ export default {
forwardButtonAction() { forwardButtonAction() {
}, },
navigateForward() { navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$router.navigate(
this.$route); this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
} }
} }
}; };

View file

@ -28,7 +28,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';

View file

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

View file

@ -58,7 +58,7 @@
<script> <script>
// Import Supporting Files // Import Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; 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 { required } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages'; import errorMessages from '@/constants/error-messages';
import buttonQuestion from '@/digital-components/button-question/button-question.vue'; import buttonQuestion from '@/digital-components/button-question/button-question.vue';
@ -118,8 +118,10 @@ export default {
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
vm.setData(resultMap.zipCodeData, vm.setData(
resultMap.serviceabilityDetails); resultMap.zipCodeData,
resultMap.serviceabilityDetails
);
}); });
}, },
setup() { 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)), getServiceabilityDetails: jest.fn((mockServiceZipCode) => mockGetServiceabilityDetails(mockServiceZipCode)),
getZipCodeData: jest.fn((mockServiceZipCode) => mockGetZipCodeData(mockServiceZipCode)) getZipCodeData: jest.fn((mockServiceZipCode) => mockGetZipCodeData(mockServiceZipCode))
})); })
);
const linkWidgetName = 'linkWidgetName'; const linkWidgetName = 'linkWidgetName';
const modalWidgetName = 'modalWidgetName'; const modalWidgetName = 'modalWidgetName';

View file

@ -107,7 +107,8 @@ describe('service-package-radio.vue', () => {
const fileredResults = results.filter((result) => result.includes(' -')); const fileredResults = results.filter((result) => result.includes(' -'));
expect(fileredResults.length).toBe(0); 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 () => { async () => {
// Arrange // Arrange
const moddedProps = mockProps; const moddedProps = mockProps;
@ -123,5 +124,6 @@ describe('service-package-radio.vue', () => {
// Assert // Assert
expect(results.length).toBe(5); 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 siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
import contentGroupModal from '@/iss-components/content-group-modal/content-group-modal.vue'; import contentGroupModal from '@/iss-components/content-group-modal/content-group-modal.vue';
import loadingModal from '@/iss-components/loading-modal/loading-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 { useMainStore } from '@/store';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { Form } from 'vee-validate'; 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'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -71,8 +71,10 @@ export default {
}, },
navigateForward() { navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$router.navigate(
this.$route); 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'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
@ -65,8 +65,10 @@ export default {
return this.navigateForward(); return this.navigateForward();
}, },
navigateForward() { navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$router.navigate(
this.$route); this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
} }
} }
}; };

View file

@ -27,7 +27,7 @@ import siteFooter from '@/iss-components/site-footer/site-footer.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -77,8 +77,10 @@ export default {
}, },
navigateForward() { navigateForward() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$router.navigate(
this.$route); this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
} }
} }
}; };

View file

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

View file

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

View file

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

View file

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

View file

@ -85,7 +85,7 @@ import alert from '@/ux-components/alert/alert.vue';
// Supporting files // Supporting files
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; 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 { Form, defineRule } from 'vee-validate';
import { required } from '@/helpers/validation-rules'; import { required } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages'; import errorMessages from '@/constants/error-messages';
@ -374,12 +374,21 @@ export default {
navigateForward() { navigateForward() {
if (this.mainStore.damage.isRepair) { 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) { } else if (this.mainStore.order.vehicle.vin) {
// If vin already exists, navigate directly to vin-lookup // 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 { } 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'; import damageLocationsSelected from '@/constants/damage-locations-selected.js';
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule('windshield-damage-type-required', defineRule(
required(errorMessages.WINDSHIELD_DAMAGE_TYPE_REQUIRED)); 'windshield-damage-type-required',
defineRule('windshield-chip-count-required', required(errorMessages.WINDSHIELD_DAMAGE_TYPE_REQUIRED)
required(errorMessages.WINDSHIELD_CHIP_COUNT_REQUIRED)); );
defineRule('windshield-replace-options-required', defineRule(
required(errorMessages.WINDSHIELD_REPLACE_OPTIONS_REQUIRED)); '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, selectedDamageLocations) => (
selectedWindshieldDamageType.toString() !== damageLocationsSelected.REPAIR selectedWindshieldDamageType.toString() !== damageLocationsSelected.REPAIR
|| (!selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) || (!selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD)
&& !selectedDamageLocations[0]?.includes(damageLocationsSelected.WINDSHIELD)) && !selectedDamageLocations[0]?.includes(damageLocationsSelected.WINDSHIELD))
|| selectedDamageLocations[0].length === 1 || selectedDamageLocations[0].length === 1
)); )
);
defineRule('repair-only', (value) => value.toString() === damageLocationsSelected.REPAIR); defineRule('repair-only', (value) => value.toString() === damageLocationsSelected.REPAIR);
defineRule('prevent-split-and-single-together', (value) => { defineRule('prevent-split-and-single-together', (value) => {
if ( if (
@ -126,9 +134,11 @@ export default {
return this.selectedValues.selectedWindshieldChipCount; return this.selectedValues.selectedWindshieldChipCount;
}, },
set(newValue) { set(newValue) {
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValue, this.selectedValues = this.getWindshieldOptions(
this.selectedWindshieldDamageTypeValue,
newValue, newValue,
null); null
);
} }
}, },
selectedWindshieldReplaceOptionsValues: { selectedWindshieldReplaceOptionsValues: {
@ -136,9 +146,11 @@ export default {
return this.selectedValues.selectedWindshieldReplaceOptions; return this.selectedValues.selectedWindshieldReplaceOptions;
}, },
set(newValue) { set(newValue) {
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValue, this.selectedValues = this.getWindshieldOptions(
this.selectedWindshieldDamageTypeValue,
null, null,
newValue); newValue
);
} }
}, },
isWindshieldDamageLocation() { isWindshieldDamageLocation() {
@ -197,9 +209,11 @@ export default {
this.windshieldAvailableReplacementOptions = windshieldAvailableReplacementOptions; this.windshieldAvailableReplacementOptions = windshieldAvailableReplacementOptions;
this.$refs.replaceOptionsQuestion.initializeComponent(windshieldAvailableReplacementOptions); this.$refs.replaceOptionsQuestion.initializeComponent(windshieldAvailableReplacementOptions);
}, },
getWindshieldOptions(selectedWindshieldDamageType, getWindshieldOptions(
selectedWindshieldDamageType,
selectedWindshieldChipCount, selectedWindshieldChipCount,
selectedWindshieldReplaceOptions) { selectedWindshieldReplaceOptions
) {
// ONLY UPDATE THE NEW VALUE IF IT IS TRUTHY (NOT NULL) // ONLY UPDATE THE NEW VALUE IF IT IS TRUTHY (NOT NULL)
return { return {
selectedWindshieldDamageType: selectedWindshieldDamageType || this.selectedValues.selectedWindshieldDamageType, selectedWindshieldDamageType: selectedWindshieldDamageType || this.selectedValues.selectedWindshieldDamageType,

View file

@ -40,7 +40,7 @@
<script> <script>
// Import Supporting Files // Import Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin'; import BaseFormMixin from '@/mixins/base-form-mixin';
import vinLookupMethodSelections from '@/constants/vin-lookup-methods'; import vinLookupMethodSelections from '@/constants/vin-lookup-methods';

View file

@ -14,7 +14,7 @@
// Import Other Supporting Files // Import Other Supporting Files
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import vinLookupMethodSelections from '@/constants/vin-lookup-methods'; 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 globalRules from '@/constants/global-rules';
// Import Component // Import Component

View file

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

View file

@ -91,8 +91,10 @@ export default {
return validationRuleName; return validationRuleName;
}, },
colorQuestionText() { colorQuestionText() {
return getCustomTransformValue(this.glassColorQuestion, return getCustomTransformValue(
`${this.glassLocation} ${this.glassName}`); this.glassColorQuestion,
`${this.glassLocation} ${this.glassName}`
);
}, },
tintSelectionOptions() { 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'; import glassPartQuestion from '@/layouts/vehicle-parts/glass-part-question/glass-part-question.vue';
// Supporting Files // Supporting Files
import { settleAllPromises } from '@/helpers/layout-helper.js'; import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; 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'; import applicationConfig from '@/constants/application-config';
// Mock our module for promises. // Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
settleAllPromises: jest.fn()
}));
// Mock fetchCmsContentForPage // Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({ jest.mock('@/helpers/cms-content-helper', () => ({
@ -126,10 +124,12 @@ describe('vehicle-parts.vue', () => {
}); });
// Act // Act
vehicleParts.beforeRouteEnter.call(wrapper.vm, vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
// Assert // Assert
@ -159,10 +159,12 @@ describe('vehicle-parts.vue', () => {
}); });
// Act // Act
vehicleParts.beforeRouteEnter.call(wrapper.vm, vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
await nextTick(); await nextTick();
@ -191,10 +193,12 @@ describe('vehicle-parts.vue', () => {
}); });
// Act // Act
vehicleParts.beforeRouteEnter.call(wrapper.vm, vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
await nextTick(); await nextTick();
@ -227,16 +231,20 @@ describe('vehicle-parts.vue', () => {
}); });
// Act // Act
vehicleParts.beforeRouteEnter.call(wrapper.vm, vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
wrapper.vm.navigateBack(); wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
wrapper.vm.$route); 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 () => { 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 // Act
vehicleParts.beforeRouteEnter.call(wrapper.vm, vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
wrapper.vm.navigateBack(); wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
wrapper.vm.$route); 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 () => { test('ForwardButtonAction triggers a router.navigate change if there are child part questions', async () => {
@ -330,21 +342,25 @@ describe('vehicle-parts.vue', () => {
}); });
// Act // Act
vehicleParts.beforeRouteEnter.call(wrapper.vm, vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
expect(wrapper.vm.$router.navigate) expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith('CLICKED_FORWARD_WITH_MOLDING_QUESTIONS', .toHaveBeenCalledWith(
'CLICKED_FORWARD_WITH_MOLDING_QUESTIONS',
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
{}, {},
{}, {},
expect.anything()); expect.anything()
);
}); });
test('ForwardButtonAction triggers a router.navigate change if there are capability questions', async () => { test('ForwardButtonAction triggers a router.navigate change if there are capability questions', async () => {
@ -396,19 +412,23 @@ describe('vehicle-parts.vue', () => {
}); });
// Act // Act
vehicleParts.beforeRouteEnter.call(wrapper.vm, vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: 'vehicle-parts' } }, { query: { issPage: 'vehicle-parts' } },
undefined, undefined,
(c) => c(wrapper.vm)); (c) => c(wrapper.vm)
);
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); 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' } }, { query: { issPage: 'vehicle-parts' } },
{}, {},
{}, {},
expect.anything()); expect.anything()
);
}); });
}); });

View file

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

View file

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

View file

@ -306,10 +306,12 @@ describe('vin-lookup.vue', () => {
await flushPromises(); await flushPromises();
await waitFor(() => { await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); 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, mockRoute,
{}, {},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }); { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
);
}); });
}); });
@ -336,11 +338,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => { await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate) expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, .toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
mockRoute, mockRoute,
{}, {},
{}, {},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }); { partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
}); });
}); });
@ -366,11 +370,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => { await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate) expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, .toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
mockRoute, mockRoute,
{}, {},
{}, {},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }); { partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
}); });
}); });
@ -396,11 +402,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => { await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate) expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, .toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
mockRoute, mockRoute,
{}, {},
{}, {},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }); { partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
}); });
}); });
@ -429,11 +437,13 @@ describe('vin-lookup.vue', () => {
await waitFor(() => { await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate) expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, .toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
mockRoute, mockRoute,
{}, {},
{}, {},
{ partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }); { partsOrQuestions: getPartsOrQuestions.mockResponse.data.partsOrQuestions }
);
}); });
}); });
@ -460,8 +470,10 @@ describe('vin-lookup.vue', () => {
await waitFor(() => { await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate) expect(mockRouter.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, .toHaveBeenCalledWith(
mockRoute); navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
mockRoute
);
}); });
}); });
@ -486,8 +498,10 @@ describe('vin-lookup.vue', () => {
await flushPromises(); await flushPromises();
await waitFor(() => { await waitFor(() => {
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, expect(mockRouter.navigate).toHaveBeenCalledWith(
mockRoute); 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 vehicleLookupAlertTypes from '@/constants/vehicle-lookup-alert-types';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { isGlassAvailableForCarId } from '@/helpers/damage-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 routerParams from '@/router/router-constants/router-params';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -183,8 +183,10 @@ export default {
} }
if (this.bailout) { if (this.bailout) {
return this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, return this.$router.navigate(
this.$route); this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route
);
} }
// Add vin bcs the response from the service doesn't contain vin // Add vin bcs the response from the service doesn't contain vin
this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { vin: this.vin }); this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { vin: this.vin });
@ -218,10 +220,12 @@ export default {
if (this.isCarIdDifferentFromTheStore && !isSelectedGlassAvailableForVehicle) { if (this.isCarIdDifferentFromTheStore && !isSelectedGlassAvailableForVehicle) {
this.mainStore.updateVehicle(this.vehicleFromLookup); this.mainStore.updateVehicle(this.vehicleFromLookup);
this.mainStore.resetDamageState(); 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, this.$route,
{}, {},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }); { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
);
// navigate() doesn't stop the processing flow // navigate() doesn't stop the processing flow
return null; return null;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -158,18 +158,35 @@ router.overrideNavigation = (
isSavingNavigation, isSavingNavigation,
optionalQuery = {}, optionalQuery = {},
optionalParams = {}, optionalParams = {},
optionalPageData = {} optionalPageData) => {
) => { navigate(scenario,
navigate(scenario, currentRoute, isSavingNavigation, optionalQuery, optionalParams, optionalPageData); currentRoute,
isSavingNavigation,
optionalQuery,
optionalParams,
optionalPageData
);
next(); next();
}; };
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => { router.navigate = (
scenario,
currentRoute,
optionalQuery = {},
optionalParams = {},
optionalPageData = {}
) => {
navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData); navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData);
}; };
// Navigate to the next route, depending on the scenario. // Navigate to the next route, depending on the scenario.
function navigate(scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) { function navigate(
scenario,
currentRoute,
optionalQuery = {},
optionalParams = {},
optionalPageData = {}
) {
/*eslint-disable-line*/ /*eslint-disable-line*/
if (!scenario) { if (!scenario) {
window.console.error('No scenario provided. Please review the routing table.'); window.console.error('No scenario provided. Please review the routing table.');
@ -194,7 +211,9 @@ function navigate(scenario, currentRoute, optionalQuery = {}, optionalParams = {
const existingPageDataForPage = useMainStore().pageData(matchingScenarioMap.destinationIssPageValue); const existingPageDataForPage = useMainStore().pageData(matchingScenarioMap.destinationIssPageValue);
baseMixin.methods.savePageDataToStore( baseMixin.methods.savePageDataToStore(
matchingScenarioMap.destinationIssPageValue, matchingScenarioMap.destinationIssPageValue,
Object.keys(optionalPageData).length > 0 ? optionalPageData : existingPageDataForPage ?? {} Object.keys(optionalPageData).length > 0
? optionalPageData
: existingPageDataForPage ?? {}
); );
// We're always pushing the same path, just changing query strings. // We're always pushing the same path, just changing query strings.

View file

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

View file

@ -50,7 +50,8 @@ function setupMocks(mountOptionsMockData = {}) {
describe('alert.vue', () => { describe('alert.vue', () => {
it("Should add class 'alert-dismissible' if isDismissible is true", async () => { it("Should add class 'alert-dismissible' if isDismissible is true", async () => {
// Arrange // Arrange
const wrapper = shallowMount(alert, const wrapper = shallowMount(
alert,
setupMocks({ setupMocks({
propsData: { propsData: {
isDismissible: true, isDismissible: true,
@ -58,7 +59,8 @@ describe('alert.vue', () => {
manualCopy: 'testCopy', manualCopy: 'testCopy',
cmsWidgetName: 'alert' cmsWidgetName: 'alert'
} }
})); })
);
const wrapperDiv = wrapper.find('div'); const wrapperDiv = wrapper.find('div');
@ -68,7 +70,8 @@ describe('alert.vue', () => {
it('Should add specified alert class', async () => { it('Should add specified alert class', async () => {
// Arrange // Arrange
const wrapper = shallowMount(alert, const wrapper = shallowMount(
alert,
setupMocks({ setupMocks({
propsData: { propsData: {
alertClass: 'warning', alertClass: 'warning',
@ -76,7 +79,8 @@ describe('alert.vue', () => {
manualCopy: 'testCopy', manualCopy: 'testCopy',
cmsWidgetName: 'alert' cmsWidgetName: 'alert'
} }
})); })
);
const wrapperDiv = wrapper.find('div'); 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', () => { it('Should container a <router-link> tag if the manualCopy contains a {routerLink: testName, testLink} placeholder', () => {
// Arrange & Act // Arrange & Act
const wrapper = shallowMount(alert, const wrapper = shallowMount(
alert,
setupMocks({ setupMocks({
propsData: { propsData: {
manualHeadline: 'testHeader', manualHeadline: 'testHeader',
manualCopy: 'testCopy with a {routerLink: testName, testLink} inside of it', manualCopy: 'testCopy with a {routerLink: testName, testLink} inside of it',
cmsWidgetName: 'alert' cmsWidgetName: 'alert'
} }
})); })
);
// Assert // Assert
expect(wrapper.findComponent(RouterLinkStub).exists()).toBe(true); expect(wrapper.findComponent(RouterLinkStub).exists()).toBe(true);
}); });
it("Should contain 'n+1' <p> tags if the body copy has 'n' <p> tags", () => { it("Should contain 'n+1' <p> tags if the body copy has 'n' <p> tags", () => {
// Arrange & Act // Arrange & Act
const wrapper = shallowMount(alert, const wrapper = shallowMount(
alert,
setupMocks({ setupMocks({
propsData: { propsData: {
manualHeadline: 'testHeader', 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>', '<p>testCopy with a {routerLink: testName, testLink} inside of it</p><p>and two paragraphs</p>',
cmsWidgetName: 'alert' cmsWidgetName: 'alert'
} }
})); })
);
// Assert // Assert
expect(wrapper.findAll('p').length === 3).toBe(true); expect(wrapper.findAll('p').length === 3).toBe(true);
}); });
@ -172,7 +180,8 @@ describe('alert.vue', () => {
Element.prototype.scrollIntoView = mockScrollIntoView; Element.prototype.scrollIntoView = mockScrollIntoView;
// Act // Act
shallowMount(alert, shallowMount(
alert,
setupMocks({ setupMocks({
propsData: { propsData: {
shouldScrollToOnMount: false, shouldScrollToOnMount: false,
@ -180,7 +189,8 @@ describe('alert.vue', () => {
manualCopy: 'testCopy', manualCopy: 'testCopy',
cmsWidgetName: 'alert' cmsWidgetName: 'alert'
} }
})); })
);
// Assert // Assert
// This is an implementation detail - we just need to test that the final step of snapping // 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', () => { describe('buttonMain.vue', () => {
it('Should return btn-primary class', async () => { it('Should return btn-primary class', async () => {
// Act // Act
const wrapper = shallowMount(buttonMain, const wrapper = shallowMount(
buttonMain,
setupMocks({ setupMocks({
propsData: { propsData: {
isPrimary: true isPrimary: true
} }
})); })
);
// Assert // Assert
const button = wrapper.find('button'); const button = wrapper.find('button');
@ -31,12 +33,14 @@ describe('buttonMain.vue', () => {
it('Should return aria-disabled state', async () => { it('Should return aria-disabled state', async () => {
// Act // Act
const wrapper = shallowMount(buttonMain, const wrapper = shallowMount(
buttonMain,
setupMocks({ setupMocks({
propsData: { propsData: {
isDisabled: true isDisabled: true
} }
})); })
);
// Assert // Assert
const button = wrapper.find('button'); const button = wrapper.find('button');
@ -47,13 +51,15 @@ describe('buttonMain.vue', () => {
it('Should return loader color', async () => { it('Should return loader color', async () => {
// Act // Act
const wrapper = shallowMount(buttonMain, const wrapper = shallowMount(
buttonMain,
setupMocks({ setupMocks({
propsData: { propsData: {
loaderColor: 'blue', loaderColor: 'blue',
loaderEnabled: true loaderEnabled: true
} }
})); })
);
// Assert // Assert
@ -68,13 +74,15 @@ describe('buttonMain.vue', () => {
it('Should return loader position', async () => { it('Should return loader position', async () => {
// Act // Act
const wrapper = shallowMount(buttonMain, const wrapper = shallowMount(
buttonMain,
setupMocks({ setupMocks({
propsData: { propsData: {
loaderPosition: 'right', loaderPosition: 'right',
loaderEnabled: true loaderEnabled: true
} }
})); })
);
// Assert // Assert

View file

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

View file

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

View file

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