diff --git a/src/layouts/contact-details/contact-details.spec.js b/src/layouts/contact-details/contact-details.spec.js index 9ee0dec4..7930b319 100644 --- a/src/layouts/contact-details/contact-details.spec.js +++ b/src/layouts/contact-details/contact-details.spec.js @@ -248,13 +248,25 @@ describe('contactDetails.vue', () => { expect(wrapper.vm.$router.navigateWithSpinner) .toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined); }); - test('Forward button clicked triggers navigation', () => { + test('Forward button clicked triggers appropriate navigation when safelite shop', () => { // Arrange - const wrapper = shallowMount(contactDetails, getMountOptions({ + const mountOptions = getMountOptions({ router: { navigate: jest.fn() + }, + navigationScenarios + }); + const mainInitialState = { + order: { + serviceLocation: { IsSafeliteProvider: true } } - })); + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; + const wrapper = shallowMount(contactDetails, mountOptions); // Act wrapper.vm.forwardButtonAction(); @@ -262,7 +274,35 @@ describe('contactDetails.vue', () => { // Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigate) - .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined); + .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE_SHOP, undefined); + }); + test('Forward button clicked triggers appropriate navigation when TPA shop', () => { + // Arrange + const mountOptions = getMountOptions({ + router: { + navigate: jest.fn() + }, + navigationScenarios + }); + const mainInitialState = { + order: { + serviceLocation: { IsSafeliteProvider: false } + } + }; + mountOptions.global.plugins = [createTestingPinia({ + initialState: { + main: mainInitialState + } + })]; + const wrapper = shallowMount(contactDetails, mountOptions); + + // Act + wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + expect(wrapper.vm.$router.navigate) + .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP, undefined); }); test('Forward button click updates contact info', () => { // Arrange diff --git a/src/layouts/contact-details/contact-details.vue b/src/layouts/contact-details/contact-details.vue index 3e30c10f..0eb117bc 100644 --- a/src/layouts/contact-details/contact-details.vue +++ b/src/layouts/contact-details/contact-details.vue @@ -196,10 +196,10 @@ export default { notesForTechnician: this.notesForTechnician }; useMainStore().updateContactInfo(contactInfo); - this.$router.navigate( - this.navigationScenarios.CLICKED_FORWARD, - this.$route - ); + const scenario = useMainStore().order.serviceLocation.IsSafeliteProvider === false + ? this.navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP + : this.navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE_SHOP; + this.$router.navigate(scenario, this.$route); } } }; diff --git a/src/layouts/tpa-submit/tpa-submit.vue b/src/layouts/tpa-submit/tpa-submit.vue index 58fbff05..1ba7f98a 100644 --- a/src/layouts/tpa-submit/tpa-submit.vue +++ b/src/layouts/tpa-submit/tpa-submit.vue @@ -208,7 +208,7 @@ export default { return [this.companyName ?? '', displayAddress, displayPhoneNumber]; }, getContactInfoLines() { - const { firstName, lastName, emailAddress, phoneNumber } = useMainStore().order.contactInfo; + const { firstName, lastName, emailAddress, phoneNumber } = useMainStore().contactInfo; return [ `${firstName} ${lastName}`, emailAddress ?? '', diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 9891ef39..2cded6f6 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -581,8 +581,12 @@ const routingTable = () => [ destinationIssPageValue: issPageValues.SCHEDULE_PAGE }, { - scenario: navigationScenarios.CLICKED_FORWARD, + scenario: navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE_SHOP, destinationIssPageValue: issPageValues.SERVICE_PACKAGES + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP, + destinationIssPageValue: issPageValues.TPA_SUBMIT } ] },