From 67f2707995c9a3b477ad23d50ca94b228ff760f5 Mon Sep 17 00:00:00 2001 From: Jason Wheeler Date: Thu, 3 Nov 2022 12:58:19 -0400 Subject: [PATCH 1/3] updated pattern for asynchronous testing. It should now fail the test if assertion in promise fails or if an error is thrown during the assertion. --- src/layouts/vehicle-make/vehicle-make.spec.js | 26 +++++++++++----- .../vehicle-model/vehicle-model.spec.js | 30 ++++++++++++++----- .../vehicle-style/vehicle-style.spec.js | 22 ++++++++++---- src/layouts/vehicle-year/vehicle-year.spec.js | 14 ++++++--- 4 files changed, 67 insertions(+), 25 deletions(-) diff --git a/src/layouts/vehicle-make/vehicle-make.spec.js b/src/layouts/vehicle-make/vehicle-make.spec.js index 0e13d56f..48d995a6 100644 --- a/src/layouts/vehicle-make/vehicle-make.spec.js +++ b/src/layouts/vehicle-make/vehicle-make.spec.js @@ -39,11 +39,17 @@ describe("vehicle-make.vue", () => { ); //Assert - apiPromise.finally(() => { - expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith( - makeQuestionInitialData - ); + return apiPromise.finally(() => { + try { + expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith( + makeQuestionInitialData + ); + } + catch (e) { + throw e + } }); + }); test("BackButtonAction triggers a router.navigate change", async () => { @@ -68,9 +74,15 @@ describe("vehicle-make.vue", () => { await nextTick(); //Assert - apiPromise.finally(() => { - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); - }); + return apiPromise.finally(() => { + try { + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + } + catch (e) { + throw e + } + }); + }); test("Year set, arePagePrerequisitesValid should be true ", async () => { diff --git a/src/layouts/vehicle-model/vehicle-model.spec.js b/src/layouts/vehicle-model/vehicle-model.spec.js index 21ddd5fa..7360f795 100644 --- a/src/layouts/vehicle-model/vehicle-model.spec.js +++ b/src/layouts/vehicle-model/vehicle-model.spec.js @@ -36,17 +36,23 @@ describe("vehicle-model.vue", () => { undefined, (c) => c(wrapper.vm) ); + //Assert - apiPromise.finally(() => { - expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith( - modelQuestionInitialData - ); + return apiPromise.finally(() => { + try { + expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith( + modelQuestionInitialData + ); + } + catch (e) { + throw e + } }); }); }); describe("vehicle-model.vue", () => { - test("BackButtonAction triggers a router.navigateWithoutSaving change", async () => { + test("BackButtonAction triggers a router.navigate change", async () => { //Arrange const { wrapper, apiPromise } = setupMocks({ pageHeaderWidgetHeaderText: "Select a model to get started", @@ -65,12 +71,20 @@ describe("vehicle-model.vue", () => { ); wrapper.vm.backButtonAction(); await nextTick(); + //Assert - apiPromise.finally(() => { - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); - }); + return apiPromise.finally(() => { + try { + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + } + catch (e) { + throw e + } + }); + }); }); + describe("vehicle-model.vue", () => { test("Make set, arePagePrerequisitesValid should be true ", async () => { //Arrange diff --git a/src/layouts/vehicle-style/vehicle-style.spec.js b/src/layouts/vehicle-style/vehicle-style.spec.js index dca24943..3b055afd 100644 --- a/src/layouts/vehicle-style/vehicle-style.spec.js +++ b/src/layouts/vehicle-style/vehicle-style.spec.js @@ -43,10 +43,15 @@ describe("vehicle-style.vue", () => { ); //Assert - apiPromise.finally(() => { - expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith( - styleQuestionInitialData - ); + return apiPromise.finally(() => { + try { + expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith( + styleQuestionInitialData + ); + } + catch (e) { + throw e + } }); }); @@ -72,8 +77,13 @@ describe("vehicle-style.vue", () => { await nextTick(); //Assert - apiPromise.finally(() => { - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + return apiPromise.finally(() => { + try { + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + } + catch (e) { + throw e + } }); }); diff --git a/src/layouts/vehicle-year/vehicle-year.spec.js b/src/layouts/vehicle-year/vehicle-year.spec.js index 0d05479d..5db8c4ed 100644 --- a/src/layouts/vehicle-year/vehicle-year.spec.js +++ b/src/layouts/vehicle-year/vehicle-year.spec.js @@ -36,11 +36,17 @@ describe("vehicle-year.vue", () => { ); //Assert - apiPromise.finally(() => { - expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith( - yearQuestionInitialData - ); + return apiPromise.finally(() => { + try { + expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith( + yearQuestionInitialData + ); + } + catch (e) { + throw e + } }); + }); }); From 3df7c3384551734250cdf975c74e45d7d8dcdf58 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Fri, 4 Nov 2022 08:30:22 -0400 Subject: [PATCH 2/3] commit --- .../site-header/menu-modal/menu-modal.spec.js | 51 ++++++ .../site-header/menu-modal/menu-modal.vue | 170 ++++++++++++++++++ .../site-header/site-header.vue | 19 +- src/mixins/base-mixin.js | 4 + src/ux-components/text-link/text-link.spec.js | 49 +++++ src/ux-components/text-link/text-link.vue | 66 +++++++ 6 files changed, 351 insertions(+), 8 deletions(-) create mode 100644 src/common-components/site-header/menu-modal/menu-modal.spec.js create mode 100644 src/common-components/site-header/menu-modal/menu-modal.vue create mode 100644 src/ux-components/text-link/text-link.spec.js create mode 100644 src/ux-components/text-link/text-link.vue diff --git a/src/common-components/site-header/menu-modal/menu-modal.spec.js b/src/common-components/site-header/menu-modal/menu-modal.spec.js new file mode 100644 index 00000000..49aa5d3c --- /dev/null +++ b/src/common-components/site-header/menu-modal/menu-modal.spec.js @@ -0,0 +1,51 @@ +import { shallowMount } from "@vue/test-utils"; +import menuModal from "./menu-modal"; + +describe("menu-modal.vue", () => { + it("Should return text Footer Navigation", async () => { + // Act + const wrapper = shallowMount(menuModal); + + // Assert + const footerModalLabel = wrapper.find("h5"); + + // Expect + expect(footerModalLabel.text()).toContain("Footer Navigation"); + }); + + it("Should return footer text as Safelite Group", async () => { + // Act + const wrapper = shallowMount(menuModal); + + // Assert + const modalFooter = wrapper.find("div.modal-footer"); + + // Expect + expect(modalFooter.text()).toContain("Safelite Group"); + }); + + it("Should return Terms of use text link text", async () => { + // Act + const wrapper = shallowMount(menuModal); + + // Expect + expect(wrapper.html()).toContain("Terms of use"); + }); + + it("Should return Privacy policy text link text", async () => { + // Act + const wrapper = shallowMount(menuModal); + + // Expect + expect(wrapper.html()).toContain("Privacy policy"); + }); + + it("Should returnDo not sell my information text link text", async () => { + // Act + const wrapper = shallowMount(menuModal); + + // Expect + expect(wrapper.html()).toContain("Do not sell my information"); + }); + +}); diff --git a/src/common-components/site-header/menu-modal/menu-modal.vue b/src/common-components/site-header/menu-modal/menu-modal.vue new file mode 100644 index 00000000..f43a66e6 --- /dev/null +++ b/src/common-components/site-header/menu-modal/menu-modal.vue @@ -0,0 +1,170 @@ + + + + + + \ No newline at end of file diff --git a/src/common-components/site-header/site-header.vue b/src/common-components/site-header/site-header.vue index 6518f870..76de47be 100644 --- a/src/common-components/site-header/site-header.vue +++ b/src/common-components/site-header/site-header.vue @@ -1,10 +1,12 @@ \ No newline at end of file diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 83fd9097..61a358be 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -19,6 +19,10 @@ export default { getCmsContent(widgetName, fieldName) { return this.$root.cmsContentByWidget?.[widgetName]?.[fieldName] ? this.$root.cmsContentByWidget[widgetName][fieldName] : ''; }, + getFooterInfoBoxHeight() { + const footerInfoBox = document.querySelector(".footer#infoBox"); + return footerInfoBox ? footerInfoBox.offsetHeight : 0; + }, }, computed: { // store will be accessible globally as its id + 'Store' diff --git a/src/ux-components/text-link/text-link.spec.js b/src/ux-components/text-link/text-link.spec.js new file mode 100644 index 00000000..ab1c21b5 --- /dev/null +++ b/src/ux-components/text-link/text-link.spec.js @@ -0,0 +1,49 @@ +import { shallowMount } from "@vue/test-utils"; +import textLink from "./text-link"; + +describe("text-link.vue", () => { + it("Should return class navigation-link", async () => { + // Act + const wrapper = shallowMount(textLink, { + propsData: { + linkType: "navigation", + }, + }); + + // Assert + const paragraph = wrapper.find("a"); + + // Expect + expect(paragraph.attributes("class")).toContain("navigation-link"); + }); + + it("Should return class footer", async () => { + // Act + const wrapper = shallowMount(textLink, { + propsData: { + linkType: "footer", + }, + }); + + // Assert + const paragraph = wrapper.find("a"); + + // Expect + expect(paragraph.attributes("class")).toContain("footer"); + }); + + it("Should return class text-small", async () => { + // Act + const wrapper = shallowMount(textLink, { + propsData: { + linkType: "textSmall", + }, + }); + + // Assert + const paragraph = wrapper.find("a"); + + // Expect + expect(paragraph.attributes("class")).toContain("small"); + }); +}); diff --git a/src/ux-components/text-link/text-link.vue b/src/ux-components/text-link/text-link.vue new file mode 100644 index 00000000..cd29bcd7 --- /dev/null +++ b/src/ux-components/text-link/text-link.vue @@ -0,0 +1,66 @@ + + + + + + \ No newline at end of file From aa0b8b93d171ed2264cf2f28e110c554897c2332 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Fri, 4 Nov 2022 08:55:23 -0400 Subject: [PATCH 3/3] fixed styling for hamburger menu --- .../site-header/menu-modal/menu-modal.vue | 49 +------------------ 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/src/common-components/site-header/menu-modal/menu-modal.vue b/src/common-components/site-header/menu-modal/menu-modal.vue index f43a66e6..37e80850 100644 --- a/src/common-components/site-header/menu-modal/menu-modal.vue +++ b/src/common-components/site-header/menu-modal/menu-modal.vue @@ -8,13 +8,6 @@