From f21a75f5d7969e8b0c376168a31d69a5464fd257 Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Fri, 15 Sep 2023 14:58:09 -0400 Subject: [PATCH] revisions based on PR feedback --- .../policy-endorsements.spec.js | 18 +++- .../policy-endorsements.vue | 99 ++++++++++--------- .../policy-vehicles/policy-vehicles.vue | 10 +- 3 files changed, 68 insertions(+), 59 deletions(-) diff --git a/src/layouts/policy-endorsements/policy-endorsements.spec.js b/src/layouts/policy-endorsements/policy-endorsements.spec.js index ca26edb1..86b8fa73 100644 --- a/src/layouts/policy-endorsements/policy-endorsements.spec.js +++ b/src/layouts/policy-endorsements/policy-endorsements.spec.js @@ -30,12 +30,22 @@ describe('policyEndorsements.vue', () => { // Assert expect(siteSubHeader.exists()).toBe(true); }); - test('Should render buttonQuestion component', () => { + test('Should render schoolProperty buttonQuestion component', () => { // Arrange const wrapper = shallowMount(policyEndorsements, getMountOptions()); // Act - const buttonQuestion = wrapper.findComponent({ ref: 'endorsementQuestion' }); + const buttonQuestion = wrapper.findComponent({ ref: 'schoolPropertyQuestion' }); + + // Assert + expect(buttonQuestion.exists()).toBe(true); + }); + test('Should render parkingLot buttonQuestion component', () => { + // Arrange + const wrapper = shallowMount(policyEndorsements, getMountOptions()); + + // Act + const buttonQuestion = wrapper.findComponent({ ref: 'parkingLotQuestion' }); // Assert expect(buttonQuestion.exists()).toBe(true); @@ -85,7 +95,6 @@ describe('policyEndorsements.vue', () => { expect(wrapper.vm.$router.navigate) .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined); }); - // *TO DO: once service is ready, revise this test to ensure data is saved to the store test('Forward button clicked saves endorsement question answers', () => { // Arrange const mountOptions = getMountOptions({ @@ -96,13 +105,14 @@ describe('policyEndorsements.vue', () => { plugins: [createTestingPinia()] } }); + const wrapper = shallowMount(policyEndorsements, mountOptions); // Act wrapper.vm.forwardButtonAction(); // Assert - expect(useMainStore().saveEndorsementQuestionAnswers).toHaveBeenCalled(); + expect(useMainStore().saveEndorsementQuestionAnswers).toHaveBeenCalledWith(wrapper.vm.questionAnswersArray); }); }); }); diff --git a/src/layouts/policy-endorsements/policy-endorsements.vue b/src/layouts/policy-endorsements/policy-endorsements.vue index 70b77298..22154818 100644 --- a/src/layouts/policy-endorsements/policy-endorsements.vue +++ b/src/layouts/policy-endorsements/policy-endorsements.vue @@ -4,48 +4,50 @@ v-slot="{ meta }" @submit="onSubmit" @invalidSubmit="onInvalidSubmit"> -
+
- - - - - - + + + + + +
@@ -95,6 +97,7 @@ export default { emits: ['update:modelValue'], data() { return { + questionAnswersArray: [], schoolPropertyAnswer: '', parkingLotAnswer: '', rules: { @@ -122,10 +125,8 @@ export default { this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, async forwardButtonAction() { - // manually creating the array for now, will revise once service returns questions - const questionAnswersArray = []; - - questionAnswersArray.push( + // TO DO: remove hard coding and update data format once service returns endorsement questions + this.questionAnswersArray.push( { questionNum: 1, questionText: this.schoolPropertyQuestionText, @@ -139,7 +140,7 @@ export default { ); // save answers to store as order.policy.endorsementQuestionAnswers - useMainStore().saveEndorsementQuestionAnswers(questionAnswersArray); + useMainStore().saveEndorsementQuestionAnswers(this.questionAnswersArray); return this.navigateForward(); }, @@ -156,13 +157,13 @@ export default { diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 869aa864..f92a8475 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -118,11 +118,11 @@ export default { ? vehicle?.coverages[0].deductible : 0; }, - endorsementsForSelectedVehicle() { + selectedVehicleHasEndorsements() { const vehicle = this.policyVehicles.find((policyVehicle) => policyVehicle?.vin === this.selectedVehicleVin); if (!vehicle) { - return undefined; + return false; } return vehicle.endorsements?.length > 0; }, @@ -206,12 +206,10 @@ export default { {}, {} ); - } else if (this.endorsementsForSelectedVehicle) { + } else if (this.selectedVehicleHasEndorsements) { this.$router.navigate( this.navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS, - this.$route, - {}, - {} + this.$route ); } else { this.$router.navigate(