From 205b63556ecb10d121f46e8c04eecaa1dc5c88d1 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 24 Jan 2023 10:42:58 -0500 Subject: [PATCH] Added additional field for apartment number or business name --- .../address-questions.spec.js | 72 +++++++++++++++++++ .../address-questions/address-questions.vue | 23 +++++- 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js index cf620b15f..2015997d4 100644 --- a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js +++ b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js @@ -58,6 +58,78 @@ describe("address-questions.vue", () => { expect(state.exists()).toBe(true); expect(zipCode.exists()).toBe(true); }); + + test("Should render apartmentNumberOrBusinessName textbox-question when captureApartmentNumberOrBusinessName = true", async () => { + // Arrange + const { wrapper } = setupMocks({ + props: { + modelValue: { + streetAddress: "", + apartmentNumberOrBusinessName: "", + city: "", + state: "", + zipCode: "", + }, + captureApartmentNumberOrBusinessName: true + }, + }); + + await wrapper.setData({ + showAddressFields: true + }); + + // Act + const streetAddress = wrapper.findComponent({ ref: "autocomplete" }); + const apartmentNumberOrBusinessName = wrapper.findComponent({ ref: "apartmentNumberOrBusinessName" }); + const city = wrapper.findComponent({ ref: "city" }); + const state = wrapper.findComponent({ ref: "state" }); + const zipCode = wrapper.findComponent({ ref: "zipCode" }); + + // Assert + expect(streetAddress.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.isVisible()).toBe(true); + expect(city.exists()).toBe(true); + expect(state.exists()).toBe(true); + expect(zipCode.exists()).toBe(true); + + }); + + test("Should *not* render apartmentNumberOrBusinessName textbox-question when captureApartmentNumberOrBusinessName = false", async () => { + // Arrange + const { wrapper } = setupMocks({ + props: { + modelValue: { + streetAddress: "", + apartmentNumberOrBusinessName: "", + city: "", + state: "", + zipCode: "", + }, + captureApartmentNumberOrBusinessName: false + }, + }); + + await wrapper.setData({ + showAddressFields: true + }); + + // Act + const streetAddress = wrapper.findComponent({ ref: "autocomplete" }); + const apartmentNumberOrBusinessName = wrapper.findComponent({ ref: "apartmentNumberOrBusinessName" }); + const city = wrapper.findComponent({ ref: "city" }); + const state = wrapper.findComponent({ ref: "state" }); + const zipCode = wrapper.findComponent({ ref: "zipCode" }); + + // Assert + expect(streetAddress.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.isVisible()).toBe(false); + expect(city.exists()).toBe(true); + expect(state.exists()).toBe(true); + expect(zipCode.exists()).toBe(true); + + }); test("Should set this.showAddressFields to true when the model is prepopulated", async () => { // Arrange diff --git a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue index 23bc9280c..daae3ad2c 100644 --- a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue +++ b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue @@ -16,6 +16,18 @@ @keydown.enter.prevent /> + +
+
+ +
+
+
@@ -95,12 +107,14 @@ export default { type: Object, default: () => ({ streetAddress: "", + apartmentNumberOrBusinessName: "", city: "", state: "", - zipCode: "", + zipCode: "", }), - }, + }, validationRules: String, + captureApartmentNumberOrBusinessName: false, }, data() { return { @@ -180,6 +194,11 @@ export default { this.$emit("update:modelValue", newValue); }, }, + showApartmentNumberOrBusinessNameField: { + get: function () { + return this.captureApartmentNumberOrBusinessName; + }, + } }, methods: { setupAddressLookup() {