Spinner updates, refactored for back button

This commit is contained in:
Bill Richardson 2024-01-08 20:59:07 -05:00
parent b7fb74d16f
commit 0fc57dedb1
42 changed files with 138 additions and 183 deletions

View file

@ -2,6 +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 baseMixin from '@/mixins/base-mixin';
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';
@ -84,6 +85,8 @@ function setupMocks({
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => '');
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
wrapper.vm.$router.navigateWithSpinner = jest.fn();
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn(); wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
wrapper.vm.$refs.siteFooter.removeLoader = jest.fn(); wrapper.vm.$refs.siteFooter.removeLoader = jest.fn();
wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn(); wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn();
@ -164,7 +167,8 @@ describe('address-lookup.vue', () => {
}); });
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
test('if the looking up VIN by address is not allowed in the state selected display the Vin Lookup By HomeAddress Not Allowed Alert', test(
'if the looking up VIN by address is not allowed in the state selected display the Vin Lookup By HomeAddress Not Allowed Alert',
async () => { async () => {
// Arrange // Arrange
const mockRegistrationAddress = { const mockRegistrationAddress = {
@ -208,7 +212,8 @@ describe('address-lookup.vue', () => {
// Assert // Assert
expect(wrapper.findComponent({ ref: 'alertVinLookupsByHomeAddressNotAllowed' }).isVisible()).toBe(true); expect(wrapper.findComponent({ ref: 'alertVinLookupsByHomeAddressNotAllowed' }).isVisible()).toBe(true);
}); }
);
test('if no vehicles found, display Vin Not Found alert', async () => { test('if no vehicles found, display Vin Not Found alert', async () => {
// Arrange // Arrange
@ -251,10 +256,10 @@ describe('address-lookup.vue', () => {
}); });
// Act // Act
await wrapper.vm.backButtonAction(); await wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
}); });
test('if the car entered matches one of the vehicles found navigate forward', async () => { test('if the car entered matches one of the vehicles found navigate forward', async () => {
@ -358,7 +363,8 @@ describe('address-lookup.vue', () => {
}); });
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
test('if a different vehicle is found than the one entered and the selected glass is not available for that vehicle, navigate back to vehicle-damage page', test(
'if a different vehicle is found than the one entered and the selected glass is not available for that vehicle, navigate back to vehicle-damage page',
async () => { async () => {
// Arrange // Arrange
const mockRegistrationAddress = { const mockRegistrationAddress = {

View file

@ -62,7 +62,7 @@
:isDisabled="!meta.valid" :isDisabled="!meta.valid"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -205,11 +205,6 @@ export default {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return useMainStore().order.vehicle.carId !== null; return useMainStore().order.vehicle.carId !== null;
}, },
backButtonAction() {
// route to move backwards
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
attachCustomEvents() { attachCustomEvents() {
this.prependActionToMethod(this, this.forwardButtonAction, () => { this.prependActionToMethod(this, this.forwardButtonAction, () => {
this.pushEventToGA( this.pushEventToGA(

View file

@ -1,4 +1,5 @@
import addressVehicles from '@/layouts/address-vehicles/address-vehicles.vue'; import addressVehicles from '@/layouts/address-vehicles/address-vehicles.vue';
import baseMixin from '@/mixins/base-mixin';
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';
@ -115,6 +116,8 @@ function setupMocks({
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => '');
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
wrapper.vm.$router.navigateWithSpinner = jest.fn();
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn(); wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
wrapper.vm.$refs.siteFooter.removeLoader = jest.fn(); wrapper.vm.$refs.siteFooter.removeLoader = jest.fn();
@ -127,10 +130,10 @@ describe('address-vehicles.vue', () => {
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
// Act // Act
await wrapper.vm.backButtonAction(); await wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toBeCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toBeCalled();
}); });
test('navigateForward should be called if forwardButtonAction is run', async () => { test('navigateForward should be called if forwardButtonAction is run', async () => {
@ -190,7 +193,8 @@ describe('address-vehicles.vue', () => {
}); });
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
test('Should navigate to CLICKED_FORWARD scenario if carId is different and selected glass not available for vehicle on navigateForward', test(
'Should navigate to CLICKED_FORWARD scenario if carId is different and selected glass not available for vehicle on navigateForward',
async () => { async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});

View file

@ -56,7 +56,7 @@
ref="siteFooter" ref="siteFooter"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -231,9 +231,6 @@ export default {
} }
return false; return false;
}, },
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async forwardButtonAction() { async forwardButtonAction() {
const vinLookup = await useMainStore() const vinLookup = await useMainStore()
.lookupVehicleByVin(this.selectedVehicle.vin) .lookupVehicleByVin(this.selectedVehicle.vin)

View file

@ -15,7 +15,7 @@
:validationRules="rules.optionRequired" :validationRules="rules.optionRequired"
:index="currentGlassIndex" :index="currentGlassIndex"
@forwardButtonAction="forwardButtonAction" @forwardButtonAction="forwardButtonAction"
@backClick="navigateBack" /> @backClick="navigateBackByVehicleQuestions" />
</Form> </Form>
</template> </template>
<script> <script>

View file

@ -4,6 +4,7 @@ import { createTestingPinia } from '@pinia/testing';
import contactDetails from '@/layouts/contact-details/contact-details.vue'; import contactDetails from '@/layouts/contact-details/contact-details.vue';
// Supporting Files // Supporting Files
import baseMixin from '@/mixins/base-mixin';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js'; import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js'; import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
@ -234,16 +235,17 @@ describe('contactDetails.vue', () => {
// Arrange // Arrange
const wrapper = shallowMount(contactDetails, getMountOptions({ const wrapper = shallowMount(contactDetails, getMountOptions({
router: { router: {
navigate: jest.fn() navigateWithSpinner: jest.fn()
} }
})); }));
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
// Act // Act
wrapper.vm.backButtonAction(); wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
expect(wrapper.vm.$router.navigate) expect(wrapper.vm.$router.navigateWithSpinner)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined); .toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined);
}); });
test('Forward button clicked triggers navigation', () => { test('Forward button clicked triggers navigation', () => {

View file

@ -55,7 +55,6 @@
checkboxName="requestTextUpdates" checkboxName="requestTextUpdates"
buttonID="requestTextUpdates" buttonID="requestTextUpdates"
:checkboxLabel="requestTextUpdatesCheckboxText" /> :checkboxLabel="requestTextUpdatesCheckboxText" />
<textareaQuestion <textareaQuestion
ref="notesQuestion" ref="notesQuestion"
v-model="notesForTechnician" v-model="notesForTechnician"
@ -66,11 +65,10 @@
:cmsWidgetName="widget.notesQuestion" :cmsWidgetName="widget.notesQuestion"
maxLength="250" maxLength="250"
:inputRows="4" /> :inputRows="4" />
<p <p
ref="disclaimerText" ref="disclaimerText"
class="caption dark-gray mt-6"> class="caption dark-gray mt-6">
{{ textUpdateDisclaimerText }} I also agree to Safelite's {{ textUpdateDisclaimerText }} I also agree to Safelite's
<textLink <textLink
ref="privacyPolicyLink" ref="privacyPolicyLink"
class="normal-line-height" class="normal-line-height"
@ -85,14 +83,13 @@
text="Terms of Use" text="Terms of Use"
href="//www.safelite.com/terms-of-use" />. href="//www.safelite.com/terms-of-use" />.
</p> </p>
<siteFooter <siteFooter
ref="siteFooter" ref="siteFooter"
class="my-5" class="my-5"
:cmsWidgetName="widget.siteFooter" :cmsWidgetName="widget.siteFooter"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@forwardClicked="forwardButtonAction" @forwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -186,12 +183,6 @@ export default {
}, },
methods: methods:
{ {
/**
* @summary Steps to perform when back button clicked.
*/
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
/** /**
* @summary Steps to perform when forward button clicked. * @summary Steps to perform when forward button clicked.
*/ */

View file

@ -87,7 +87,7 @@
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@backClicked="navigateBack" @backClicked="navigateBackByVehicleQuestions"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>

View file

@ -4,6 +4,7 @@ import { createTestingPinia } from '@pinia/testing';
import duplicateCheck from '@/layouts/duplicate-check/duplicate-check.vue'; import duplicateCheck from '@/layouts/duplicate-check/duplicate-check.vue';
// Supporting Files // Supporting Files
import baseMixin from '@/mixins/base-mixin';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js'; import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
import { getRandomString } from '@/helpers/data-generation.js'; import { getRandomString } from '@/helpers/data-generation.js';
@ -333,16 +334,17 @@ describe('duplicateCheck.vue', () => {
// Arrange // Arrange
const wrapper = shallowMount(duplicateCheck, getMountOptions({ const wrapper = shallowMount(duplicateCheck, getMountOptions({
router: { router: {
navigate: jest.fn() navigateWithSpinner: jest.fn()
} }
})); }));
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
// Act // Act
wrapper.vm.backButtonAction(); wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
expect(wrapper.vm.$router.navigate) expect(wrapper.vm.$router.navigateWithSpinner)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined); .toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined);
}); });

View file

@ -33,7 +33,7 @@
:cmsWidgetName="widget.siteFooter" :cmsWidgetName="widget.siteFooter"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@forwardClicked="forwardButtonAction" @forwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -122,12 +122,6 @@ export default {
} }
}, },
methods: { methods: {
/**
* @summary Steps to perform when back button clicked.
*/
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
/** /**
* @summary Steps to perform when forward button clicked. * @summary Steps to perform when forward button clicked.
*/ */

View file

@ -2,6 +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 baseMixin from '@/mixins/base-mixin';
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';
@ -93,6 +94,8 @@ function setupMocks({
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => '');
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
wrapper.vm.$router.navigateWithSpinner = jest.fn();
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn(); wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
wrapper.vm.$refs.siteFooter.removeLoader = jest.fn(); wrapper.vm.$refs.siteFooter.removeLoader = jest.fn();
wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn(); wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn();
@ -189,10 +192,10 @@ describe('license-plate-lookup.vue', () => {
undefined, undefined,
(c) => c(wrapper.vm) (c) => c(wrapper.vm)
); );
await wrapper.vm.backButtonAction(); await wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
}); });
test('License plate found and matches entered vehicle => navigateForwardWithSingleCarMatch', async () => { test('License plate found and matches entered vehicle => navigateForwardWithSingleCarMatch', async () => {
@ -213,7 +216,7 @@ describe('license-plate-lookup.vue', () => {
expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalledTimes(1); expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalledTimes(1);
}); });
// eslint-disable-next-line max-len // eslint-disable-next-line max-len, function-paren-newline
test('if a different vehicle is found than the one entered and the selected glass is not available for that vehicle, navigate back to vehicle-damage page', test('if a different vehicle is found than the one entered and the selected glass is not available for that vehicle, navigate back to vehicle-damage page',
async () => { async () => {
// Arrange // Arrange

View file

@ -64,7 +64,7 @@
class="mt-5" class="mt-5"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -223,10 +223,6 @@ export default {
loadDefaultsFromStore() { loadDefaultsFromStore() {
this.customerQuestions = this.mainStore.customerData.addressQuestions.state; this.customerQuestions = this.mainStore.customerData.addressQuestions.state;
}, },
backButtonAction() {
// route to move backwards
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
attachCustomEvents() { attachCustomEvents() {
this.prependActionToMethod(this, this.forwardButtonAction, () => { this.prependActionToMethod(this, this.forwardButtonAction, () => {
this.pushEventToGA( this.pushEventToGA(

View file

@ -16,7 +16,7 @@
:validationRules="rules.optionRequired" :validationRules="rules.optionRequired"
:index="currentGlassIndex" :index="currentGlassIndex"
@forwardButtonAction="forwardButtonAction" @forwardButtonAction="forwardButtonAction"
@backClick="navigateBack" /> @backClick="navigateBackByVehicleQuestions" />
</Form> </Form>
</template> </template>
<script> <script>

View file

@ -14,7 +14,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -56,9 +56,6 @@ export default {
}, },
methods: methods:
{ {
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
forwardButtonAction() { forwardButtonAction() {
return this.navigateForward(); return this.navigateForward();
}, },

View file

@ -14,7 +14,7 @@
:validationRules="rules.optionRequired" :validationRules="rules.optionRequired"
:index="currentGlassIndex" :index="currentGlassIndex"
@forwardButtonAction="forwardButtonAction" @forwardButtonAction="forwardButtonAction"
@backClick="navigateBack" /> @backClick="navigateBackByVehicleQuestions" />
</Form> </Form>
</template> </template>

View file

@ -14,7 +14,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -68,14 +68,9 @@ export default {
}, },
methods: methods:
{ {
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
forwardButtonAction() { forwardButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route);
}, },
navigateForward() { navigateForward() {
} }
} }

View file

@ -2,6 +2,7 @@
import policyEndorsements from '@/layouts/policy-endorsements/policy-endorsements.vue'; import policyEndorsements from '@/layouts/policy-endorsements/policy-endorsements.vue';
// Supporting Files // Supporting Files
import baseMixin from '@/mixins/base-mixin';
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 navigationScenarios from '@/router/router-constants/navigation-scenarios'; import navigationScenarios from '@/router/router-constants/navigation-scenarios';
@ -128,16 +129,17 @@ describe('policyEndorsements.vue', () => {
// Arrange // Arrange
const wrapper = shallowMount(policyEndorsements, getMountOptions({ const wrapper = shallowMount(policyEndorsements, getMountOptions({
router: { router: {
navigate: jest.fn() navigateWithSpinner: jest.fn()
} }
})); }));
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
// Act // Act
wrapper.vm.backButtonAction(); wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
expect(wrapper.vm.$router.navigate) expect(wrapper.vm.$router.navigateWithSpinner)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined); .toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined);
}); });
test('Forward button clicked with valid car id triggers navigation', () => { test('Forward button clicked with valid car id triggers navigation', () => {
@ -170,7 +172,7 @@ describe('policyEndorsements.vue', () => {
})); }));
wrapper.setData({ wrapper.setData({
hasValidCarId: false, hasValidCarId: false
}); });
// Act // Act

View file

@ -48,7 +48,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@forwardClicked="forwardButtonAction" @forwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -136,9 +136,6 @@ export default {
}, },
methods: methods:
{ {
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async forwardButtonAction() { async forwardButtonAction() {
// TO DO: remove hard coding and update data format once service returns endorsement questions // TO DO: remove hard coding and update data format once service returns endorsement questions
if (this.educatorEndorsement) { if (this.educatorEndorsement) {

View file

@ -1,7 +1,7 @@
import policyHolderDetails from '@/layouts/policy-holder-details/policy-holder-details.vue'; import policyHolderDetails from '@/layouts/policy-holder-details/policy-holder-details.vue';
// Supporting files // Supporting files
// Supporting files import baseMixin from '@/mixins/base-mixin';
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';
@ -60,6 +60,8 @@ function setupMocks() {
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ''); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => '');
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
wrapper.vm.$router.navigateWithSpinner = jest.fn();
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn(); wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
wrapper.vm.$refs.siteFooter.removeLoader = jest.fn(); wrapper.vm.$refs.siteFooter.removeLoader = jest.fn();
wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn(); wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn();
@ -91,10 +93,10 @@ describe('navigation', () => {
}); });
// Act // Act
await wrapper.vm.backButtonAction(); await wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
}); });
test('if the car entered matches one of the vehicles found navigate forward', async () => { test('if the car entered matches one of the vehicles found navigate forward', async () => {

View file

@ -43,7 +43,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -120,10 +120,6 @@ export default {
}, },
methods: methods:
{ {
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async forwardButtonAction() { async forwardButtonAction() {
this.mainStore.updatePolicyHolderDetails(this.customerQuestions); this.mainStore.updatePolicyHolderDetails(this.customerQuestions);
return this.navigateForward(); return this.navigateForward();

View file

@ -26,7 +26,7 @@
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="isForwardActionDisabled" :isForwardActionDisabled="isForwardActionDisabled"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -166,9 +166,6 @@ export default {
arePagePrerequisiteValid() { arePagePrerequisiteValid() {
return true; return true;
}, },
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
navigateForward(scenario) { navigateForward(scenario) {
this.$router.navigate(scenario, this.$route); this.$router.navigate(scenario, this.$route);
}, },

View file

@ -83,7 +83,7 @@
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</Form> </Form>
@ -253,9 +253,6 @@ export default {
&& customerReqs && customerReqs
); );
}, },
backButtonAction() {
this.$router.navigate(navigationScenarios.CLICKED_BACK, this.$route);
},
editVehicle() { editVehicle() {
this.$router.navigateWithoutSaving( this.$router.navigateWithoutSaving(
navigationScenarios.CLICKED_VEHICLE_EDIT, navigationScenarios.CLICKED_VEHICLE_EDIT,

View file

@ -53,7 +53,7 @@
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -456,9 +456,6 @@ export default {
} }
} }
}, },
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
forwardButtonAction() { forwardButtonAction() {
this.updateSupportingItems(); this.updateSupportingItems();
this.mainStore.saveSchedule(this.selectedTimeSlotInfo.timeSlot); this.mainStore.saveSchedule(this.selectedTimeSlotInfo.timeSlot);

View file

@ -1,3 +1,4 @@
import baseMixin from '@/mixins/base-mixin';
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 serviceLocation from '@/layouts/service-location/service-location.vue'; import serviceLocation from '@/layouts/service-location/service-location.vue';
@ -18,6 +19,9 @@ function setupMocks() {
}) })
); );
wrapper.vm.$router.navigateWithSpinner = jest.fn();
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
return { wrapper }; return { wrapper };
} }
@ -92,10 +96,10 @@ describe('navigation', () => {
}); });
// Act // Act
await wrapper.vm.backButtonAction(); await wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
}); });
}); });

View file

@ -86,7 +86,7 @@
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid || displayNoShopsAlert" :isForwardActionDisabled="!meta.valid || displayNoShopsAlert"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -329,12 +329,6 @@ export default {
&& useMainStore().order.serviceLocation.zipCode !== null && useMainStore().order.serviceLocation.zipCode !== null
); );
}, },
backButtonAction() {
/**
* this.navigationScenarios comes from base-mixin
*/
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async reloadShopData(zipCode) { async reloadShopData(zipCode) {
await this.$refs.shopQuestion.reloadShopData(zipCode); await this.$refs.shopQuestion.reloadShopData(zipCode);
}, },

View file

@ -27,7 +27,7 @@
<siteFooter <siteFooter
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@back-clicked="backButtonAction" @backClicked="navigateBack"
@ForwardClicked="forwardButtonAction" /> @ForwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -167,9 +167,6 @@ export default {
vapsItemsSelectedAction(vapsItemsSelected) { vapsItemsSelectedAction(vapsItemsSelected) {
this.selectedVaps = vapsItemsSelected; this.selectedVaps = vapsItemsSelected;
}, },
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
forwardButtonAction() { forwardButtonAction() {
const parts = { glassParts: this.pricedGlassParts, supportingItems: this.supportingItems, vaps: this.selectedVaps }; const parts = { glassParts: this.pricedGlassParts, supportingItems: this.supportingItems, vaps: this.selectedVaps };
if (!allGlassPartsAndItemsHavePrices(parts)) { if (!allGlassPartsAndItemsHavePrices(parts)) {

View file

@ -14,7 +14,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -63,9 +63,6 @@ export default {
}, },
methods: methods:
{ {
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async forwardButtonAction() { async forwardButtonAction() {
return this.navigateForward(); return this.navigateForward();
}, },

View file

@ -4,6 +4,7 @@ import { createTestingPinia } from '@pinia/testing';
import tpaSearch from '@/layouts/tpa-search/tpa-search.vue'; import tpaSearch from '@/layouts/tpa-search/tpa-search.vue';
// Supporting Files // Supporting Files
import baseMixin from '@/mixins/base-mixin';
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 { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
@ -47,6 +48,9 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
const wrapper = shallowMount(tpaSearch, mountOptions); const wrapper = shallowMount(tpaSearch, mountOptions);
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {}); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {});
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
wrapper.vm.$router.navigateWithSpinner = jest.fn();
wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
return { wrapper }; return { wrapper };
} }
@ -957,10 +961,10 @@ describe('TPA search page', () => {
const { wrapper } = getMountedComponent(); const { wrapper } = getMountedComponent();
// Act // Act
wrapper.vm.backButtonAction(); wrapper.vm.navigateBack();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalled();
}); });
describe('forwardButtonAction', () => { describe('forwardButtonAction', () => {
test('invokes navigate method with safelite shop scenario when selectedProviderIsSafeliteShop true', async () => { test('invokes navigate method with safelite shop scenario when selectedProviderIsSafeliteShop true', async () => {

View file

@ -105,7 +105,7 @@
:cmsWidgetName="widget.siteFooter" :cmsWidgetName="widget.siteFooter"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</Form> </Form>
</div> </div>
@ -337,9 +337,6 @@ export default {
this.providers = await this.getProviderButtonData(); this.providers = await this.getProviderButtonData();
this.mapZipCode = this.zipCode; this.mapZipCode = this.zipCode;
}, },
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
forwardButtonAction() { forwardButtonAction() {
const scenario = this.selectedProviderIsSafeliteShop const scenario = this.selectedProviderIsSafeliteShop
? this.navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE_SHOP ? this.navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE_SHOP

View file

@ -14,7 +14,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -68,14 +68,9 @@ export default {
}, },
methods: methods:
{ {
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
forwardButtonAction() { forwardButtonAction() {
return this.navigateForward(); return this.navigateForward();
}, },
navigateForward() { navigateForward() {
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD, this.navigationScenarios.CLICKED_FORWARD,

View file

@ -60,7 +60,7 @@
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -236,12 +236,6 @@ export default {
} }
return false; return false;
}, },
backButtonAction() {
// route to move backwards
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
getDamageLocationsFromStore() { getDamageLocationsFromStore() {
const glassSelections = []; const glassSelections = [];
@ -268,7 +262,6 @@ export default {
return glassSelections; return glassSelections;
}, },
getWindshieldOptionsFromStore() { getWindshieldOptionsFromStore() {
const windShieldOptions = { const windShieldOptions = {
selectedWindshieldDamageType: '', selectedWindshieldDamageType: '',
@ -315,7 +308,6 @@ export default {
return windShieldOptions; return windShieldOptions;
}, },
getDoorSidesFromStore() { getDoorSidesFromStore() {
const doorSides = []; const doorSides = [];
if ( if (
@ -332,7 +324,6 @@ export default {
return doorSides; return doorSides;
}, },
getDriverSideReplaceOptionsFromStore() { getDriverSideReplaceOptionsFromStore() {
const driverSideReplaceOptions = []; const driverSideReplaceOptions = [];
@ -344,7 +335,6 @@ export default {
return driverSideReplaceOptions; return driverSideReplaceOptions;
}, },
getPassengerSideReplaceOptionsFromStore() { getPassengerSideReplaceOptionsFromStore() {
const passengerSideReplaceOptions = []; const passengerSideReplaceOptions = [];
@ -356,14 +346,12 @@ export default {
return passengerSideReplaceOptions; return passengerSideReplaceOptions;
}, },
getRearReplaceOptionsFromStore() { getRearReplaceOptionsFromStore() {
const rearReplaceOptions = this.mainStore.order.damage const rearReplaceOptions = this.mainStore.order.damage
.glassToReplace?.filter((glass) => glass.glassLocation === damageLocationsSelected.REAR)[0]?.glassName; .glassToReplace?.filter((glass) => glass.glassLocation === damageLocationsSelected.REAR)[0]?.glassName;
return rearReplaceOptions; return rearReplaceOptions;
}, },
async forwardButtonAction() { async forwardButtonAction() {
this.mainStore.saveVehicleDamage( this.mainStore.saveVehicleDamage(
this.isWindshieldRepair, this.isWindshieldRepair,
@ -403,7 +391,6 @@ export default {
return null; return null;
}, },
selectedGlassToReplace() { selectedGlassToReplace() {
const selectedGlassToReplace = []; const selectedGlassToReplace = [];
if (this.isWindshieldDamageLocation && !this.isWindshieldRepair) { if (this.isWindshieldDamageLocation && !this.isWindshieldRepair) {

View file

@ -1,5 +1,6 @@
/* eslint-env jest */ /* eslint-env jest */
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import baseMixin from '@/mixins/base-mixin';
import navigationScenarios from '@/router/router-constants/navigation-scenarios'; import navigationScenarios from '@/router/router-constants/navigation-scenarios';
import queryStrings from '@/constants/query-strings'; import queryStrings from '@/constants/query-strings';
import { GaActions } from '@/constants/analytics'; import { GaActions } from '@/constants/analytics';
@ -56,7 +57,8 @@ function setupMocks() {
}; };
const mockRouter = { const mockRouter = {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSpinner: jest.fn()
}; };
const mockIsVinbyAddressPermissibleToBeFalse = { const mockIsVinbyAddressPermissibleToBeFalse = {
@ -105,7 +107,8 @@ function setupMocks() {
}), }),
getFooterInfoBoxHeight: jest.fn(() => 80), getFooterInfoBoxHeight: jest.fn(() => 80),
getPageNameByQueryString: jest.fn(() => 'vehicle-lookup'), getPageNameByQueryString: jest.fn(() => 'vehicle-lookup'),
pushEventToGA: jest.fn() pushEventToGA: jest.fn(),
navigateBack: baseMixin.methods.navigateBack
} }
} }
], ],
@ -121,6 +124,8 @@ function setupMocks() {
} }
}); });
// wrapper.vm.navigateBack = baseMixin.methods.navigateBack;
return { mockRoute, mockRouter, wrapper, mockIsVinbyAddressPermissibleToBeFalse }; return { mockRoute, mockRouter, wrapper, mockIsVinbyAddressPermissibleToBeFalse };
} }
@ -178,8 +183,8 @@ describe('vehicle-lookup.vue', () => {
const { mockRoute, mockRouter, wrapper } = setupMocks(); const { mockRoute, mockRouter, wrapper } = setupMocks();
await wrapper.get('[data-test-id="site-footer-back-button"]').trigger('click'); await wrapper.get('[data-test-id="site-footer-back-button"]').trigger('click');
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigateWithSpinner).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate) expect(mockRouter.navigateWithSpinner)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, mockRoute); .toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, mockRoute);
}); });
@ -264,10 +269,10 @@ describe('vehicle-lookup.vue', () => {
}); });
/** /**
* To Do: Error message is not displayed when running test * To Do: Error message is not displayed when running test
* but in reality it shows up. Need to find out * but in reality it shows up. Need to find out
* how to write a test that verifies the error message is displayed. * how to write a test that verifies the error message is displayed.
*/ */
// test.only('Error message is diplayed when no selection is made // test.only('Error message is diplayed when no selection is made
// and "Continue" button clicked.', async () => { // and "Continue" button clicked.', async () => {
// const { wrapper } = setupMocks(); // const { wrapper } = setupMocks();

View file

@ -26,7 +26,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="isForwardActionDisabled" :isForwardActionDisabled="isForwardActionDisabled"
class="mt-5" class="mt-5"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -96,12 +96,6 @@ export default {
arePagePrerequisiteValid() { arePagePrerequisiteValid() {
return true; return true;
}, },
backButtonAction() {
/**
* this.navigationScenarios comes from base-mixin
*/
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
forwardButtonAction() { forwardButtonAction() {
switch (this.selectedVinLookupMethod) { switch (this.selectedVinLookupMethod) {
case vinLookupMethodSelections.MANUALVIN: case vinLookupMethodSelections.MANUALVIN:

View file

@ -220,7 +220,7 @@ describe('vehicle-parts.vue', () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigateWithSpinner: jest.fn()
}, },
route: { route: {
query: { query: {
@ -238,10 +238,10 @@ describe('vehicle-parts.vue', () => {
(c) => c(wrapper.vm) (c) => c(wrapper.vm)
); );
wrapper.vm.navigateBack(); wrapper.vm.navigateBackByVehicleQuestions();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route wrapper.vm.$route
); );
@ -252,7 +252,7 @@ describe('vehicle-parts.vue', () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn() navigateWithSpinner: jest.fn()
}, },
route: { route: {
query: { query: {
@ -270,10 +270,10 @@ describe('vehicle-parts.vue', () => {
(c) => c(wrapper.vm) (c) => c(wrapper.vm)
); );
wrapper.vm.navigateBack(); wrapper.vm.navigateBackByVehicleQuestions();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route wrapper.vm.$route
); );

View file

@ -49,7 +49,7 @@
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="isForwardActionDisabled" :isForwardActionDisabled="isForwardActionDisabled"
@backClicked="navigateBack" @backClicked="navigateBackByVehicleQuestions"
@ForwardClicked="forwardButtonAction" /> @ForwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>

View file

@ -63,7 +63,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
@backClicked="backButtonAction" /> @backClicked="navigateBack" />
</div> </div>
</div> </div>
</div> </div>
@ -181,9 +181,6 @@ export default {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return true; return true;
}, },
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async forwardButtonAction() { async forwardButtonAction() {
return this.navigateForward(); return this.navigateForward();
}, },

View file

@ -2,6 +2,7 @@
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
import { flushPromises } from '@vue/test-utils'; import { flushPromises } from '@vue/test-utils';
import { render, waitFor } from '@testing-library/vue'; import { render, waitFor } from '@testing-library/vue';
import baseMixin from '@/mixins/base-mixin';
import { createTestingPinia } from '@pinia/testing'; import { createTestingPinia } from '@pinia/testing';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import errorMessages from '@/constants/error-messages'; import errorMessages from '@/constants/error-messages';
@ -132,7 +133,8 @@ const mockRoute = {
} }
}; };
const mockRouter = { const mockRouter = {
navigate: jest.fn() navigate: jest.fn(),
navigateWithSpinner: jest.fn()
}; };
const maska = jest.fn(); const maska = jest.fn();
jest.mock('@/helpers/damage-helper', () => ({ jest.mock('@/helpers/damage-helper', () => ({
@ -147,6 +149,7 @@ const mountOptions = {
{ {
methods: { methods: {
getCmsContent: jest.fn(() => ''), getCmsContent: jest.fn(() => ''),
navigateBack: baseMixin.methods.navigateBack,
getFooterInfoBoxHeight: jest.fn(() => 80), getFooterInfoBoxHeight: jest.fn(() => 80),
cssClassNameForCmsWidget: jest.fn(() => 'widget-name-mock-class'), cssClassNameForCmsWidget: jest.fn(() => 'widget-name-mock-class'),
getPageNameByQueryString: jest.fn(() => ''), getPageNameByQueryString: jest.fn(() => ''),
@ -275,8 +278,8 @@ describe('vin-lookup.vue', () => {
await user.click(backButton); await user.click(backButton);
expect(mockRouter.navigate).toHaveBeenCalledTimes(1); expect(mockRouter.navigateWithSpinner).toHaveBeenCalledTimes(1);
expect(mockRouter.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, mockRoute); expect(mockRouter.navigateWithSpinner).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, mockRoute);
}); });
// eslint-disable-next-line max-len // eslint-disable-next-line max-len

View file

@ -31,7 +31,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
class="mt-5" class="mt-5"
@backClicked="backButtonAction" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" /> @forwardClicked="forwardButtonAction" />
</div> </div>
</div> </div>
@ -166,12 +166,6 @@ export default {
hasValidCarId() { hasValidCarId() {
return this.mainStore.vehicle.carId && this.mainStore.vehicle.carId !== '0'; return this.mainStore.vehicle.carId && this.mainStore.vehicle.carId !== '0';
}, },
backButtonAction() {
/**
* this.navigationScenarios comes from base-mixin
*/
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
// 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
async forwardButtonAction() { async forwardButtonAction() {
this.resetActiveAlert(); this.resetActiveAlert();

View file

@ -23,6 +23,11 @@ export default {
const footerInfoBox = document.querySelector('.footer#infoBox'); const footerInfoBox = document.querySelector('.footer#infoBox');
return footerInfoBox ? footerInfoBox.offsetHeight : 0; return footerInfoBox ? footerInfoBox.offsetHeight : 0;
}, },
navigateBack(vm) {
const self = vm ?? this;
self.$router.navigateWithSpinner(this.navigationScenarios.CLICKED_BACK, self.$route);
},
savePageDataToStore(page, data) { savePageDataToStore(page, data) {
useMainStore().updatePageData({ page, data }); useMainStore().updatePageData({ page, data });
}, },

View file

@ -432,7 +432,7 @@ export default {
} }
}, },
navigateBack(vm) { navigateBackByVehicleQuestions(vm) {
const self = vm ?? this; const self = vm ?? this;
const partsOrQuestions = ( const partsOrQuestions = (
self.mainStore.pageData(issPageValues.CAPABILITY_QUESTIONS) self.mainStore.pageData(issPageValues.CAPABILITY_QUESTIONS)
@ -476,7 +476,7 @@ export default {
backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS; backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS;
} }
self.$router.navigate(backNavigationScenario, self.$route); self.$router.navigateWithSpinner(backNavigationScenario, self.$route);
} }
} }
}; };

View file

@ -2110,14 +2110,14 @@ describe('vehicle-questions-mixin', () => {
}); });
}); });
describe('navigateBack', () => { describe('navigateBackByVehicleQuestions', () => {
test('current page is coverage-statement and damage is repair => go to vehicle-damage', () => { test('current page is coverage-statement and damage is repair => go to vehicle-damage', () => {
// Arrange // Arrange
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT }); const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
useMainStore().order.damage.isRepair = true; useMainStore().order.damage.isRepair = true;
// Act // Act
wrapper.vm.navigateBack(); wrapper.vm.navigateBackByVehicleQuestions();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
@ -2138,7 +2138,7 @@ describe('vehicle-questions-mixin', () => {
wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true); wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true);
// Act // Act
wrapper.vm.navigateBack(); wrapper.vm.navigateBackByVehicleQuestions();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
@ -2157,7 +2157,7 @@ describe('vehicle-questions-mixin', () => {
wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true); wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true);
// Act // Act
wrapper.vm.navigateBack(); wrapper.vm.navigateBackByVehicleQuestions();
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(

View file

@ -221,13 +221,21 @@ router.navigate = (
navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData); navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData);
}; };
router.navigateWithSpinner = (
scenario,
currentRoute
) => {
navigate(scenario, currentRoute, undefined, undefined, undefined, true);
};
// Navigate to the next route, depending on the scenario. // Navigate to the next route, depending on the scenario.
function navigate( function navigate(
scenario, scenario,
currentRoute, currentRoute,
optionalQuery = {}, optionalQuery = {},
optionalParams = {}, optionalParams = {},
optionalPageData = {} optionalPageData = {},
forceSpinner = false
) { ) {
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.');
@ -242,6 +250,10 @@ function navigate(
return; return;
} }
if (forceSpinner) {
showIssLoadingModal(true);
}
if (scenario === navigationScenarios.CLICKED_BACK_PREVIOUS) { if (scenario === navigationScenarios.CLICKED_BACK_PREVIOUS) {
// Update page to the prevous page in the router. // Update page to the prevous page in the router.
// If we need to worry about typing this in from outside of the app, // If we need to worry about typing this in from outside of the app,