commit
641207355d
6 changed files with 178 additions and 3 deletions
|
|
@ -2,6 +2,12 @@ import { mount, shallowMount } from "@vue/test-utils";
|
||||||
import promoModalQuestion from "./promo-modal-question";
|
import promoModalQuestion from "./promo-modal-question";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import {
|
||||||
|
promoErrorCodes,
|
||||||
|
getPromoCodesFromPromoObjectsWithoutDuplicates,
|
||||||
|
getPromoCodeWithoutBundleIdentifier,
|
||||||
|
} from "@/helpers/promotions-helper";
|
||||||
|
import { cartItemCategories } from "@/constants/cart-item-categories";
|
||||||
|
|
||||||
let mockReturnsForStoreActions = {};
|
let mockReturnsForStoreActions = {};
|
||||||
|
|
||||||
|
|
@ -222,4 +228,173 @@ describe("promo-modal-question.vue", () => {
|
||||||
|
|
||||||
expect(taxedLineItems).toEqual(taxedlineItems);
|
expect(taxedLineItems).toEqual(taxedlineItems);
|
||||||
});
|
});
|
||||||
|
test("Get promoCode list will return the applied promos", async () => {
|
||||||
|
// Arrange
|
||||||
|
const promos = [
|
||||||
|
{ promoCode: "duplicatePromo" },
|
||||||
|
{ promoCode: "duplicatePromo" },
|
||||||
|
{ promoCode: "bundlePromo/400" },
|
||||||
|
{ promoCode: "bundlePromo/401" },
|
||||||
|
];
|
||||||
|
const appliedPromos = ["duplicatePromo", "bundlePromo"];
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [],
|
||||||
|
promos: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(promoModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: lineItems,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.getPromoCodeList();
|
||||||
|
const promoCodeToDisplay = getPromoCodesFromPromoObjectsWithoutDuplicates(promos);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(promoCodeToDisplay).toEqual(appliedPromos);
|
||||||
|
});
|
||||||
|
test("On clicking remove the promo gets removed from the lineItems", async () => {
|
||||||
|
//Arrange
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [],
|
||||||
|
promos: [{ promoCode: "duplicatePromo" }, { promoCode: "duplicatePromo" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(promoModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: lineItems,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
const promo = ["bundlePromo"];
|
||||||
|
//Act
|
||||||
|
wrapper.vm.removeItem(promo);
|
||||||
|
const existingPromo = (lineItems[cartItemCategories.PROMOS] = lineItems[
|
||||||
|
cartItemCategories.PROMOS
|
||||||
|
].filter(
|
||||||
|
(lineItemsToKeep) =>
|
||||||
|
getPromoCodeWithoutBundleIdentifier(lineItemsToKeep.promoCode) != promo
|
||||||
|
));
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(existingPromo).toEqual(lineItems.promos);
|
||||||
|
});
|
||||||
|
test("Getting stacking alert on stack promo error code", async () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [],
|
||||||
|
promos: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(promoModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: lineItems,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
const additionalInfo = ["testAdditionalInfo"];
|
||||||
|
|
||||||
|
const stackingErrorCode = promoErrorCodes.PROMO_STACKING_NOT_ALLOWED;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.getErrorMessage(stackingErrorCode, additionalInfo);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.displayStackingPromoAlert).toBe(true);
|
||||||
|
});
|
||||||
|
test("Getting invalid promo alert on invalid promoCode", async () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [],
|
||||||
|
promos: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(promoModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: lineItems,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
const additionalInfo = ["testAdditionalInfo"];
|
||||||
|
|
||||||
|
const invalidErrorCode = promoErrorCodes.INVALID_PROMO_ON_ORDER;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.getErrorMessage(invalidErrorCode, additionalInfo);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.displayInvalidPromoAlert).toBe(true);
|
||||||
|
});
|
||||||
|
test("Getting invalid promo alert on invalid promoCode", async () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [],
|
||||||
|
promos: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(promoModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: lineItems,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
const additionalInfo = ["APPOINTMENT_TYPE"];
|
||||||
|
|
||||||
|
const invalidErrorCode = promoErrorCodes.INVALID_PROMO_ON_ORDER;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.getErrorMessage(invalidErrorCode, additionalInfo);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.displayInShopPromoAlert).toBe(true);
|
||||||
|
});
|
||||||
|
test("Get conflicting promoCodes on applying more than one promo", async () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [],
|
||||||
|
vaps: [],
|
||||||
|
promos: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = mount(promoModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: lineItems,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
const additionalInfo = ["1wiper0", "Glass30"];
|
||||||
|
const conflictingCodes = ["1wiper0", "Glass30"];
|
||||||
|
|
||||||
|
//Act
|
||||||
|
wrapper.vm.getConflictingPromoCode(additionalInfo);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(conflictingCodes).toEqual(additionalInfo);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import textLink from "@/ux-components/text-link/text-link";
|
import textLink from "@/ux-components/text-link/text-link";
|
||||||
import promoQuestion from "@/layouts/payment-method/promo-modal-question/promo-question/promo-question";
|
import promoQuestion from "@/fmg-components/promo-modal-question/promo-question/promo-question";
|
||||||
import modal from "@/digital-components/modal/modal";
|
import modal from "@/digital-components/modal/modal";
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
|
|
@ -82,7 +82,7 @@ import paymentMethodQuestion from "@/layouts/payment-method/payment-method-quest
|
||||||
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
|
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
|
||||||
import cart from "@/fmg-components/cart/cart";
|
import cart from "@/fmg-components/cart/cart";
|
||||||
import reviewDropdown from "@/layouts/payment-method/review-dropdown/review-dropdown";
|
import reviewDropdown from "@/layouts/payment-method/review-dropdown/review-dropdown";
|
||||||
import promoModalQuestion from "@/layouts/payment-method/promo-modal-question/promo-modal-question";
|
import promoModalQuestion from "@/fmg-components/promo-modal-question/promo-modal-question";
|
||||||
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ import {
|
||||||
} from "@/helpers/promotions-helper";
|
} from "@/helpers/promotions-helper";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
||||||
import promoModalQuestion from "@/layouts/payment-method/promo-modal-question/promo-modal-question";
|
import promoModalQuestion from "@/fmg-components/promo-modal-question/promo-modal-question";
|
||||||
|
|
||||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue