Merge branch 'develop' into bugfix/CSR-1503
This commit is contained in:
commit
df3060486a
2 changed files with 71 additions and 14 deletions
|
|
@ -1,6 +1,13 @@
|
|||
import { shallowMount } from "@vue/test-utils";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import appointmentTypeQuestion from "./appointment-type-question";
|
||||
import store from "@/store";
|
||||
|
||||
store.getters = {
|
||||
damage: {
|
||||
isRepair: false,
|
||||
},
|
||||
};
|
||||
|
||||
const mockCmsContent = {
|
||||
QuestionText: "Choose a service option:",
|
||||
|
|
@ -42,6 +49,15 @@ const mockMixin = {
|
|||
},
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
// reset store after each test
|
||||
store.getters = {
|
||||
damage: {
|
||||
isRepair: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("appointment-type-question.vue", () => {
|
||||
it("Should display all options if both in-shop and mobile are available", async () => {
|
||||
// Arrange/Act
|
||||
|
|
@ -141,6 +157,45 @@ describe("appointment-type-question.vue", () => {
|
|||
},
|
||||
]);
|
||||
});
|
||||
it("Should not display Drop off answer when it is repair order", async () => {
|
||||
// Arrange/Act
|
||||
|
||||
store.getters = {
|
||||
damage: {
|
||||
isRepair: true,
|
||||
},
|
||||
};
|
||||
|
||||
const { wrapper } = setupMocks({
|
||||
mixins: [mockMixin],
|
||||
props: {
|
||||
cmsWidgetName: cmsWidgetName,
|
||||
isServiceableInshop: true,
|
||||
isServiceableMobile: true,
|
||||
},
|
||||
mountOptions: {
|
||||
attachTo: document.body,
|
||||
},
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.answersToDisplay).toEqual([
|
||||
{
|
||||
AnswerImageUrl: "",
|
||||
Name: "Mobile",
|
||||
SubText: "",
|
||||
SubWidgetName: "",
|
||||
Text: "Mobile",
|
||||
},
|
||||
{
|
||||
AnswerImageUrl: "",
|
||||
Name: "Inshop",
|
||||
SubText: "",
|
||||
SubWidgetName: "",
|
||||
Text: "In-shop",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("Should display no answers if neither in-shop nor mobile service are available", async () => {
|
||||
// Arrange/Act
|
||||
|
|
@ -169,6 +224,8 @@ function setupMocks({ mountOptions, mixins, props, isShallowMount = true }) {
|
|||
|
||||
if (props) resultingMountOptions.propsData = props;
|
||||
|
||||
resultingMountOptions.global.mocks["$store"] = store;
|
||||
|
||||
const wrapper = isShallowMount
|
||||
? shallowMount(appointmentTypeQuestion, resultingMountOptions)
|
||||
: mount(appointmentTypeQuestion, resultingMountOptions);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
<script>
|
||||
import buttonQuestion from "@/digital-components/button-question/button-question";
|
||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||
|
||||
export default {
|
||||
name: "appointment-type-question",
|
||||
|
|
@ -40,20 +41,19 @@ export default {
|
|||
return this.getCmsContent(this.cmsWidgetName, "Answers");
|
||||
},
|
||||
answersToDisplay() {
|
||||
let filteredAnswers;
|
||||
if (this.isServiceableMobile && this.isServiceableInshop) {
|
||||
filteredAnswers = this.answersFromCms;
|
||||
} else if (this.isServiceableMobile) {
|
||||
filteredAnswers = this.answersFromCms.filter((answer) => answer.Name == "Mobile");
|
||||
} else if (this.isServiceableInshop) {
|
||||
filteredAnswers = this.answersFromCms.filter(
|
||||
(answer) => answer.Name == "Inshop" || answer.Name == "Dropoff"
|
||||
);
|
||||
} else {
|
||||
filteredAnswers = [];
|
||||
}
|
||||
|
||||
return filteredAnswers;
|
||||
const shouldShowMobile = this.isServiceableMobile;
|
||||
const shouldShowInshop = this.isServiceableInshop;
|
||||
const shouldShowDropoff =
|
||||
this.isServiceableInshop && !this.$store.getters.damage.isRepair;
|
||||
return this.answersFromCms
|
||||
? this.answersFromCms.filter((answer) => {
|
||||
return (
|
||||
(answer.Name == AppointmentTypeStrings.IN_SHOP && shouldShowInshop) ||
|
||||
(answer.Name == AppointmentTypeStrings.MOBILE && shouldShowMobile) ||
|
||||
(answer.Name == AppointmentTypeStrings.DROP_OFF && shouldShowDropoff)
|
||||
);
|
||||
})
|
||||
: [];
|
||||
},
|
||||
selectedValues: {
|
||||
get: function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue