Merge pull request #1287 from Safelite/feature/jzimmerman/INSR-10176
INSR-10176: Fixed issue where picking new referral on cookie popup skips duplicate check page.
This commit is contained in:
commit
16f589fe26
2 changed files with 66 additions and 15 deletions
|
|
@ -150,11 +150,13 @@ describe('navigation', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('When zip code check succeeds', () => {
|
describe('When zip code check succeeds', () => {
|
||||||
test('if duplicates found, navigate to duplicate check page', async () => {
|
test('if duplicates found, NOT loaded from cookie, and NOT visited duplicate check page, navigate to duplicate check page', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||||
|
useMainStore().order.loadedFromCookie = false;
|
||||||
|
useMainStore().order.visitedDuplicateCheckPage = false;
|
||||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
data: {
|
data: {
|
||||||
isValid: true
|
isValid: true
|
||||||
|
|
@ -173,6 +175,58 @@ describe('navigation', () => {
|
||||||
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
test('if duplicates found but loadedFromCookie is true, skip duplicate check and navigate to policy verified path', async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
|
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||||
|
useMainStore().order.loadedFromCookie = true;
|
||||||
|
useMainStore().order.visitedDuplicateCheckPage = false;
|
||||||
|
useMainStore().order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||||
|
useMainStore().order.policy.vehicles = [{ vin: 'TEST_VIN' }];
|
||||||
|
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
|
data: {
|
||||||
|
isValid: true
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
|
||||||
|
undefined,
|
||||||
|
{},
|
||||||
|
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('if duplicates found but visitedDuplicateCheckPage is true, skip duplicate check and navigate to policy verified path', async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||||
|
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||||
|
useMainStore().order.loadedFromCookie = false;
|
||||||
|
useMainStore().order.visitedDuplicateCheckPage = true;
|
||||||
|
useMainStore().order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||||
|
useMainStore().order.policy.vehicles = [{ vin: 'TEST_VIN' }];
|
||||||
|
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
|
data: {
|
||||||
|
isValid: true
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED_WITH_VEHICLES,
|
||||||
|
undefined,
|
||||||
|
{},
|
||||||
|
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
||||||
|
);
|
||||||
|
});
|
||||||
test('if policy and vehicles are found but no duplicates, navigate to policy-vehicle page', async () => {
|
test('if policy and vehicles are found but no duplicates, navigate to policy-vehicle page', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
@ -277,26 +331,22 @@ describe('navigation', () => {
|
||||||
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
test('getDuplicateReferrals throws rejected promise => navigate called', async () => {
|
test('getDuplicateReferrals throws rejected promise => error propagates', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
const error = 'duplicate referrals error';
|
const error = new Error('duplicate referrals error');
|
||||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.reject(error));
|
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.reject(error));
|
||||||
|
useMainStore().order.loadedFromCookie = false;
|
||||||
|
useMainStore().order.visitedDuplicateCheckPage = false;
|
||||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
data: {
|
data: {
|
||||||
isValid: true
|
isValid: true
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Act
|
// Act & Assert
|
||||||
|
await expect(wrapper.vm.forwardButtonAction()).rejects.toEqual(error);
|
||||||
// Assert
|
expect(wrapper.vm.$router.navigate).not.toHaveBeenCalled();
|
||||||
expect.assertions(1);
|
|
||||||
try {
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
|
||||||
} catch (e) {
|
|
||||||
expect(e).toMatch(error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -386,7 +386,10 @@ export default {
|
||||||
},
|
},
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
if ((this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false)
|
if ((this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false)
|
||||||
&& !this.answeredContinueModal) {
|
&& !this.mainStore.order.loadedFromCookie
|
||||||
|
&& !this.mainStore.order.visitedDuplicateCheckPage) {
|
||||||
|
// NOTE: Only navigate to duplicate check page if the user has not already loaded an
|
||||||
|
// existing referral from cookie (continue option from cookie popup) and they have not visited the duplicate check page already.
|
||||||
// Duplicate orders found; navigating to duplicate check page and skipping save session.
|
// Duplicate orders found; navigating to duplicate check page and skipping save session.
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
this.navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
||||||
|
|
@ -498,8 +501,6 @@ export default {
|
||||||
},
|
},
|
||||||
startNewReferral() {
|
startNewReferral() {
|
||||||
this.mainStore.issConfig.enableContinueFromCookie = false;
|
this.mainStore.issConfig.enableContinueFromCookie = false;
|
||||||
// Setting this to true so we skip dupe check since the user already decided not to load the previous referral
|
|
||||||
this.mainStore.order.loadedFromCookie = true;
|
|
||||||
this.answeredContinueModal = true;
|
this.answeredContinueModal = true;
|
||||||
this.$refs.continueModal.closeModal();
|
this.$refs.continueModal.closeModal();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue