From f6fadd8ed8f5b9f4302d47490a77ebef1e7dbda4 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 9 Jul 2024 13:07:06 -0400 Subject: [PATCH] Unit tests & restore FBA functionality --- .../checkbox-question.spec.js | 19 ++++- .../payment-method/payment-method.spec.js | 13 +++- src/layouts/payment-method/payment-method.vue | 70 +++++++++---------- 3 files changed, 64 insertions(+), 38 deletions(-) diff --git a/src/digital-components/checkbox-question/checkbox-question.spec.js b/src/digital-components/checkbox-question/checkbox-question.spec.js index 3c5d75bf9..677312549 100644 --- a/src/digital-components/checkbox-question/checkbox-question.spec.js +++ b/src/digital-components/checkbox-question/checkbox-question.spec.js @@ -29,11 +29,26 @@ describe("checkbox-question.vue", () => { expect(input.attributes().name).toEqual("Checkbox"); }); - it("Should return checkbox id", async () => { + it("Should return default id when no custom id is specified", async () => { // Act const wrapper = shallowMount(checkboxQuestion, { propsData: { - buttonID: "Checkbox ID", + }, + mixins: [mockMixin], + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().id).not.toBeFalsy(); + }); + + it("Should return custom id when specified", async () => { + // Act + const wrapper = shallowMount(checkboxQuestion, { + propsData: { + customInputId: "Checkbox ID", }, mixins: [mockMixin], }); diff --git a/src/layouts/payment-method/payment-method.spec.js b/src/layouts/payment-method/payment-method.spec.js index 16b64a58b..c9f67bca1 100644 --- a/src/layouts/payment-method/payment-method.spec.js +++ b/src/layouts/payment-method/payment-method.spec.js @@ -47,7 +47,12 @@ describe("payment-method.vue", () => { function setupMocks() { store.getters = { damage: {}, - lineItems: [], + lineItems: { + glassParts: [], + supportingItems: [], + vaps: [], + promos: [], + }, order: { payment: { isPia: false, @@ -55,6 +60,12 @@ function setupMocks() { isVerified: true, }, }, + lineItems: { + glassParts: [], + supportingItems: [], + vaps: [], + promos: [], + }, policy: { currentDeductible: 123, isNoComp: false, diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index e791f015e..9ac22878a 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -486,41 +486,41 @@ export default { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, async forwardButtonAction() { - // await this.dispatchStoreAction( - // storeActions.SAVE_PAYMENT_METHOD_CHOICE, - // this.paymentMethod, - // false - // ); - // // save lineitems as they now have salestax added - // await this.dispatchStoreAction( - // storeActions.SAVE_GLASS_PARTS_SUPPRESSING_STATE_RESETTING, - // this.lineItems.glassParts, - // false - // ); - // await this.dispatchStoreAction( - // storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING, - // this.lineItems.supportingItems, - // false - // ); - // await this.dispatchStoreAction(storeActions.SAVE_VAPS, this.lineItems.vaps, false); - // this.dispatchStoreAction( - // storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS, - // { - // activePromos: this.lineItems.promos, - // inactivePromos: this.inactivePromos, - // }, - // false - // ); - // if (this.paymentMethod == paymentMethods.LATER) { - // // this creates the final work order - // await submitWorkOrder({ pageNameToLog: "payment-method", submitAfterSave: true }); - // this.$router.navigateWithoutSaving( - // this.navigationScenarios.CLICKED_FORWARD, - // this.$route - // ); - // } else { - // this.setupPia(); - // } + await this.dispatchStoreAction( + storeActions.SAVE_PAYMENT_METHOD_CHOICE, + this.paymentMethod, + false + ); + // save lineitems as they now have salestax added + await this.dispatchStoreAction( + storeActions.SAVE_GLASS_PARTS_SUPPRESSING_STATE_RESETTING, + this.lineItems.glassParts, + false + ); + await this.dispatchStoreAction( + storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING, + this.lineItems.supportingItems, + false + ); + await this.dispatchStoreAction(storeActions.SAVE_VAPS, this.lineItems.vaps, false); + this.dispatchStoreAction( + storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS, + { + activePromos: this.lineItems.promos, + inactivePromos: this.inactivePromos, + }, + false + ); + if (this.paymentMethod == paymentMethods.LATER) { + // this creates the final work order + await submitWorkOrder({ pageNameToLog: "payment-method", submitAfterSave: true }); + this.$router.navigateWithoutSaving( + this.navigationScenarios.CLICKED_FORWARD, + this.$route + ); + } else { + this.setupPia(); + } }, async setupPia() { this.$refs.loadingModal.showModal();