CASH-3025: Consent management changes
This commit is contained in:
parent
202d16ba35
commit
df80ede623
5 changed files with 38 additions and 25 deletions
|
|
@ -32,7 +32,7 @@ const errorMessages = {
|
||||||
DATE_REQUIRED: "Please select a date",
|
DATE_REQUIRED: "Please select a date",
|
||||||
PHONE_REQUIRED: "Please enter your phone number",
|
PHONE_REQUIRED: "Please enter your phone number",
|
||||||
PHONE_FORMAT: "Phone number must be 10 digits",
|
PHONE_FORMAT: "Phone number must be 10 digits",
|
||||||
SMS_CONSENT_REQUIRED: "Please select at least one consent option",
|
SMS_CONSENT_REQUIRED: "Please select checkbox to receive text messages",
|
||||||
YEAR_REQUIRED: "Please select your vehicle year",
|
YEAR_REQUIRED: "Please select your vehicle year",
|
||||||
MAKE_REQUIRED: "Please select your vehicle make",
|
MAKE_REQUIRED: "Please select your vehicle make",
|
||||||
MODEL_REQUIRED: "Please select your vehicle model",
|
MODEL_REQUIRED: "Please select your vehicle model",
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,14 @@ describe("save-progress-popup-question ", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("contact method tabs", () => {
|
describe("contact method tabs", () => {
|
||||||
test("should default to the phone tab", () => {
|
test("should default to the email tab", () => {
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
props: {
|
props: {
|
||||||
modalWidgetName: "SaveProgressPopupWidget",
|
modalWidgetName: "SaveProgressPopupWidget",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.vm.isPhoneTabSelected).toBe(true);
|
expect(wrapper.vm.isPhoneTabSelected).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should use tab labels from phone and email specific CMS widgets", () => {
|
test("should use tab labels from phone and email specific CMS widgets", () => {
|
||||||
|
|
@ -83,21 +83,24 @@ describe("save-progress-popup-question ", () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.vm.modalDisclaimerText).toBe("Phone disclaimer");
|
expect(wrapper.vm.modalDisclaimerText).toBe("Email disclaimer");
|
||||||
|
|
||||||
wrapper.vm.selectContactMethod("EmailAnswer");
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
expect(wrapper.vm.modalDisclaimerText).toBe("Email disclaimer");
|
expect(wrapper.vm.modalDisclaimerText).toBe("Phone disclaimer");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should use phone question CMS widget on the phone tab", () => {
|
test("should use phone question CMS widget on the phone tab", async () => {
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
props: {
|
props: {
|
||||||
modalWidgetName: "SaveProgressPopupWidget",
|
modalWidgetName: "SaveProgressPopupWidget",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
expect(wrapper.vm.phoneQuestionWidgetName).toBe("SaveProgressPopupPhoneQuestionWidget");
|
expect(wrapper.vm.phoneQuestionWidgetName).toBe("SaveProgressPopupPhoneQuestionWidget");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -108,15 +111,26 @@ describe("save-progress-popup-question ", () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.selectContactMethod("EmailAnswer");
|
|
||||||
await wrapper.vm.$nextTick();
|
|
||||||
|
|
||||||
expect(wrapper.vm.contactMethod).toBe("EmailAnswer");
|
expect(wrapper.vm.contactMethod).toBe("EmailAnswer");
|
||||||
expect(wrapper.vm.isPhoneTabSelected).toBe(false);
|
expect(wrapper.vm.isPhoneTabSelected).toBe(false);
|
||||||
expect(wrapper.vm.userInput).toBe("");
|
|
||||||
expect(wrapper.vm.emailQuestionWidgetName).toBe("SaveProgressPopupEmailQuestionWidget");
|
expect(wrapper.vm.emailQuestionWidgetName).toBe("SaveProgressPopupEmailQuestionWidget");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("should show phone content when the phone tab is selected", async () => {
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
props: {
|
||||||
|
modalWidgetName: "SaveProgressPopupWidget",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
expect(wrapper.vm.contactMethod).toBe("PhoneAnswer");
|
||||||
|
expect(wrapper.vm.isPhoneTabSelected).toBe(true);
|
||||||
|
expect(wrapper.vm.userInput).toBe("");
|
||||||
|
});
|
||||||
|
|
||||||
test("should reset sms consent when switching tabs", async () => {
|
test("should reset sms consent when switching tabs", async () => {
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -126,7 +140,7 @@ describe("save-progress-popup-question ", () => {
|
||||||
|
|
||||||
wrapper.vm.smsConsent = { transactional: true, marketing: true };
|
wrapper.vm.smsConsent = { transactional: true, marketing: true };
|
||||||
wrapper.vm.showConsentErrors = true;
|
wrapper.vm.showConsentErrors = true;
|
||||||
wrapper.vm.selectContactMethod("EmailAnswer");
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
expect(wrapper.vm.smsConsent).toEqual({ transactional: false, marketing: false });
|
expect(wrapper.vm.smsConsent).toEqual({ transactional: false, marketing: false });
|
||||||
|
|
@ -142,6 +156,7 @@ describe("save-progress-popup-question ", () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
wrapper.vm.modal.validate = jest.fn().mockResolvedValue({ valid: true });
|
wrapper.vm.modal.validate = jest.fn().mockResolvedValue({ valid: true });
|
||||||
const resetSpy = jest.spyOn(wrapper.vm, "resetPhoneSendButtonStyle");
|
const resetSpy = jest.spyOn(wrapper.vm, "resetPhoneSendButtonStyle");
|
||||||
|
|
||||||
|
|
@ -158,6 +173,7 @@ describe("save-progress-popup-question ", () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
wrapper.vm.modal.validate = jest.fn().mockResolvedValue({ valid: false });
|
wrapper.vm.modal.validate = jest.fn().mockResolvedValue({ valid: false });
|
||||||
const resetSpy = jest.spyOn(wrapper.vm, "resetPhoneSendButtonStyle");
|
const resetSpy = jest.spyOn(wrapper.vm, "resetPhoneSendButtonStyle");
|
||||||
|
|
||||||
|
|
@ -179,6 +195,7 @@ describe("save-progress-popup-question ", () => {
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
||||||
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
wrapper.vm.userInput = "555-123-4567";
|
wrapper.vm.userInput = "555-123-4567";
|
||||||
wrapper.vm.smsConsent = { transactional: true, marketing: false };
|
wrapper.vm.smsConsent = { transactional: true, marketing: false };
|
||||||
wrapper.vm.modal.validate = jest.fn().mockResolvedValue({ valid: true });
|
wrapper.vm.modal.validate = jest.fn().mockResolvedValue({ valid: true });
|
||||||
|
|
@ -203,6 +220,7 @@ describe("save-progress-popup-question ", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
||||||
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
wrapper.vm.userInput = "555-123-4567";
|
wrapper.vm.userInput = "555-123-4567";
|
||||||
wrapper.vm.smsConsent = { transactional: true, marketing: false };
|
wrapper.vm.smsConsent = { transactional: true, marketing: false };
|
||||||
|
|
||||||
|
|
@ -238,7 +256,6 @@ describe("save-progress-popup-question ", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
||||||
wrapper.vm.selectContactMethod("EmailAnswer");
|
|
||||||
wrapper.vm.userInput = "test@example.com";
|
wrapper.vm.userInput = "test@example.com";
|
||||||
|
|
||||||
await wrapper.vm.saveProgress();
|
await wrapper.vm.saveProgress();
|
||||||
|
|
@ -267,6 +284,7 @@ describe("save-progress-popup-question ", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
||||||
|
wrapper.vm.selectContactMethod("PhoneAnswer");
|
||||||
wrapper.vm.userInput = "555-123-4567";
|
wrapper.vm.userInput = "555-123-4567";
|
||||||
wrapper.vm.smsConsent = { transactional: true, marketing: false };
|
wrapper.vm.smsConsent = { transactional: true, marketing: false };
|
||||||
|
|
||||||
|
|
@ -289,7 +307,6 @@ describe("save-progress-popup-question ", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
wrapper.vm.dispatchStoreAction = dispatchStoreAction;
|
||||||
wrapper.vm.selectContactMethod("EmailAnswer");
|
|
||||||
wrapper.vm.userInput = "test@example.com";
|
wrapper.vm.userInput = "test@example.com";
|
||||||
|
|
||||||
await wrapper.vm.saveProgress();
|
await wrapper.vm.saveProgress();
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
userInput: "",
|
userInput: "",
|
||||||
contactMethod: saveProgressPopupContactMethods.PHONE,
|
contactMethod: saveProgressPopupContactMethods.EMAIL,
|
||||||
smsConsent: defaultSaveProgressSmsConsent(),
|
smsConsent: defaultSaveProgressSmsConsent(),
|
||||||
smsConsentCopy: getSaveProgressSmsConsentFallbackCopy(),
|
smsConsentCopy: getSaveProgressSmsConsentFallbackCopy(),
|
||||||
isProgressSaved: false,
|
isProgressSaved: false,
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,14 @@ import {
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
|
|
||||||
describe("save-progress-popup-sms-consent-question", () => {
|
describe("save-progress-popup-sms-consent-question", () => {
|
||||||
it("should render two consent checkboxes with default copy", () => {
|
it("should render the transactional consent checkbox with default copy", () => {
|
||||||
const wrapper = shallowMount(saveProgressPopupSmsConsentQuestion);
|
const wrapper = shallowMount(saveProgressPopupSmsConsentQuestion);
|
||||||
const fallbackCopy = getSaveProgressSmsConsentFallbackCopy();
|
const fallbackCopy = getSaveProgressSmsConsentFallbackCopy();
|
||||||
|
|
||||||
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
||||||
|
|
||||||
expect(checkboxes).toHaveLength(2);
|
expect(checkboxes).toHaveLength(1);
|
||||||
expect(checkboxes.at(0).props("labelText")).toBe(fallbackCopy.transactional);
|
expect(checkboxes.at(0).props("labelText")).toBe(fallbackCopy.transactional);
|
||||||
expect(checkboxes.at(1).props("labelText")).toBe(fallbackCopy.marketing);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should emit updated consent when a checkbox changes", async () => {
|
it("should emit updated consent when a checkbox changes", async () => {
|
||||||
|
|
@ -47,8 +46,8 @@ describe("save-progress-popup-sms-consent-question", () => {
|
||||||
|
|
||||||
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
||||||
|
|
||||||
|
expect(checkboxes).toHaveLength(1);
|
||||||
expect(checkboxes.at(0).props("labelText")).toBe("API transactional copy");
|
expect(checkboxes.at(0).props("labelText")).toBe("API transactional copy");
|
||||||
expect(checkboxes.at(1).props("labelText")).toBe("API marketing copy");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should disable consent checkboxes when isDisabled is true", () => {
|
it("should disable consent checkboxes when isDisabled is true", () => {
|
||||||
|
|
@ -61,7 +60,6 @@ describe("save-progress-popup-sms-consent-question", () => {
|
||||||
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
||||||
|
|
||||||
expect(checkboxes.at(0).props("isDisabled")).toBe(true);
|
expect(checkboxes.at(0).props("isDisabled")).toBe(true);
|
||||||
expect(checkboxes.at(1).props("isDisabled")).toBe(true);
|
|
||||||
expect(wrapper.find("fieldset").attributes("disabled")).toBe("");
|
expect(wrapper.find("fieldset").attributes("disabled")).toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -76,7 +74,6 @@ describe("save-progress-popup-sms-consent-question", () => {
|
||||||
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
||||||
|
|
||||||
expect(checkboxes.at(0).props("hasError")).toBe(false);
|
expect(checkboxes.at(0).props("hasError")).toBe(false);
|
||||||
expect(checkboxes.at(1).props("hasError")).toBe(false);
|
|
||||||
expect(wrapper.text()).not.toContain(errorMessages.SMS_CONSENT_REQUIRED);
|
expect(wrapper.text()).not.toContain(errorMessages.SMS_CONSENT_REQUIRED);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -94,7 +91,6 @@ describe("save-progress-popup-sms-consent-question", () => {
|
||||||
|
|
||||||
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
||||||
expect(checkboxes.at(0).props("hasError")).toBe(true);
|
expect(checkboxes.at(0).props("hasError")).toBe(true);
|
||||||
expect(checkboxes.at(1).props("hasError")).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should clear consent errors when a selection is made while showConsentErrors is true", async () => {
|
it("should clear consent errors when a selection is made while showConsentErrors is true", async () => {
|
||||||
|
|
@ -111,6 +107,5 @@ describe("save-progress-popup-sms-consent-question", () => {
|
||||||
|
|
||||||
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
const checkboxes = wrapper.findAllComponents({ name: "checkboxQuestion" });
|
||||||
expect(checkboxes.at(0).props("hasError")).toBe(false);
|
expect(checkboxes.at(0).props("hasError")).toBe(false);
|
||||||
expect(checkboxes.at(1).props("hasError")).toBe(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,13 @@
|
||||||
:labelText="consentCopy.transactional"
|
:labelText="consentCopy.transactional"
|
||||||
:hasError="showConsentError"
|
:hasError="showConsentError"
|
||||||
:isDisabled="isDisabled" />
|
:isDisabled="isDisabled" />
|
||||||
<checkboxQuestion
|
<!-- Temporarily hiding marketing consent checkbox. Will be re-added in a future release.
|
||||||
|
<checkboxQuestion
|
||||||
v-model="marketingConsent"
|
v-model="marketingConsent"
|
||||||
checkboxName="saveProgressMarketingConsent"
|
checkboxName="saveProgressMarketingConsent"
|
||||||
:labelText="consentCopy.marketing"
|
:labelText="consentCopy.marketing"
|
||||||
:hasError="showConsentError"
|
:hasError="showConsentError"
|
||||||
:isDisabled="isDisabled" />
|
:isDisabled="isDisabled" /> -->
|
||||||
<span
|
<span
|
||||||
v-if="showConsentError"
|
v-if="showConsentError"
|
||||||
class="save-progress-popup-sms-consent__error d-inline-flex small mt-1"
|
class="save-progress-popup-sms-consent__error d-inline-flex small mt-1"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue