SSR-1178. Fix WO not created when Pay at the time of service is selected. (#643)
This commit is contained in:
parent
63219c7776
commit
9e6e91b98c
3 changed files with 44 additions and 5 deletions
|
|
@ -10,6 +10,12 @@ import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import { paymentMethods } from '@/constants/payment-method-constants';
|
import { paymentMethods } from '@/constants/payment-method-constants';
|
||||||
import queryStrings from '@/constants/query-strings';
|
import queryStrings from '@/constants/query-strings';
|
||||||
import { experimentSettings } from '@/constants/experiments';
|
import { experimentSettings } from '@/constants/experiments';
|
||||||
|
import { submitWorkOrder } from '@/helpers/order-helper.js';
|
||||||
|
|
||||||
|
// Mock so it can be used as an assertion
|
||||||
|
jest.mock('@/helpers/order-helper.js', () => ({
|
||||||
|
submitWorkOrder: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
function setupMocks({ customMountOptions = {}, queryString }, mainInitialState = {}, customMixin = null) {
|
function setupMocks({ customMountOptions = {}, queryString }, mainInitialState = {}, customMixin = null) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
|
|
@ -251,4 +257,25 @@ describe('payment-method.vue', () => {
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('forwardButtonAction', () => {
|
||||||
|
test('Pay at the time of service is selected, should call saveWorkOrder', async () => {
|
||||||
|
// Arrange
|
||||||
|
const store = {
|
||||||
|
order: {
|
||||||
|
payment: {
|
||||||
|
isPayInAdvance: false,
|
||||||
|
payInAdvanceType: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const wrapper = setupMocks({}, store);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(submitWorkOrder).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
|
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
|
||||||
import VehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner.vue';
|
import VehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner.vue';
|
||||||
|
import { submitWorkOrder } from '@/helpers/order-helper.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'payment-method',
|
name: 'payment-method',
|
||||||
|
|
@ -296,10 +297,21 @@ export default {
|
||||||
await useMainStore().savePaymentMethodChoice(this.paymentMethod);
|
await useMainStore().savePaymentMethodChoice(this.paymentMethod);
|
||||||
|
|
||||||
if (this.paymentMethod === paymentMethods.PAY_AT_TIME_OF_SERVICE) {
|
if (this.paymentMethod === paymentMethods.PAY_AT_TIME_OF_SERVICE) {
|
||||||
|
try {
|
||||||
|
await submitWorkOrder({
|
||||||
|
pageNameToLog: 'payment-method',
|
||||||
|
submitAfterSave: true
|
||||||
|
});
|
||||||
|
|
||||||
|
useMainStore().resetSubmittedOrder();
|
||||||
|
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD,
|
this.navigationScenarios.CLICKED_FORWARD,
|
||||||
this.$route
|
this.$route
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`error: response from submit work order:${error.message}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_PAY_NOW,
|
this.navigationScenarios.CLICKED_PAY_NOW,
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,7 @@ export const useMainStore = defineStore({
|
||||||
experimentSettings: (state) => state.applicationUser.experiments
|
experimentSettings: (state) => state.applicationUser.experiments
|
||||||
.map((x) => x.settings)
|
.map((x) => x.settings)
|
||||||
.reduce((r, c) => Object.assign(r, c), {}) ?? {},
|
.reduce((r, c) => Object.assign(r, c), {}) ?? {},
|
||||||
submittedOrder: () => JSON.parse(window.sessionStorage.getItem('submittedOrder'))
|
submittedOrder: () => JSON.parse(window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER))
|
||||||
},
|
},
|
||||||
actions:
|
actions:
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue