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', () => {
|
||||
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
|
||||
const { wrapper } = setupMocks({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||
useMainStore().order.loadedFromCookie = false;
|
||||
useMainStore().order.visitedDuplicateCheckPage = false;
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
isValid: true
|
||||
|
|
@ -173,6 +175,58 @@ describe('navigation', () => {
|
|||
{ [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 () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
|
@ -277,26 +331,22 @@ describe('navigation', () => {
|
|||
{ [routerParams.SKIP_SAVE_SESSION]: true }
|
||||
);
|
||||
});
|
||||
test('getDuplicateReferrals throws rejected promise => navigate called', async () => {
|
||||
test('getDuplicateReferrals throws rejected promise => error propagates', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
const error = 'duplicate referrals error';
|
||||
const error = new Error('duplicate referrals 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({
|
||||
data: {
|
||||
isValid: true
|
||||
}
|
||||
}));
|
||||
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
} catch (e) {
|
||||
expect(e).toMatch(error);
|
||||
}
|
||||
// Act & Assert
|
||||
await expect(wrapper.vm.forwardButtonAction()).rejects.toEqual(error);
|
||||
expect(wrapper.vm.$router.navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -386,7 +386,10 @@ export default {
|
|||
},
|
||||
navigateForward() {
|
||||
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.
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_DUPLICATES,
|
||||
|
|
@ -498,8 +501,6 @@ export default {
|
|||
},
|
||||
startNewReferral() {
|
||||
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.$refs.continueModal.closeModal();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue