Checking for Carl to look at

This commit is contained in:
Leah Schumann 2023-05-10 08:09:05 -04:00
parent 3cf505f697
commit fe0d3f45ce
7 changed files with 121 additions and 102 deletions

View file

@ -28,4 +28,6 @@ module.exports = {
// Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90
},
},
// Uncomment this to avoid the massive amount of warnings we are getting for onSubmit and onInvalidSubmit
// silent: true,
};

View file

@ -137,7 +137,7 @@ export default {
alertInvalidZipWidgetName: String,
customComponentId: String,
validationRules: String,
optionalCallback: {
onZipUpdateCallback: {
type: Function,
},
},
@ -260,8 +260,8 @@ export default {
// Update the page level model
this.$emit("update:modelValue", this.internalModel);
if (this.optionalCallback) {
await this.optionalCallback(serviceZipCode);
if (this.onZipUpdateCallback) {
await this.onZipUpdateCallback(serviceZipCode);
}
this.closeModal();

View file

@ -186,7 +186,7 @@ beforeEach(() => {
describe("service-location.vue", () => {
describe("beforeRouteEnter", () => {
test("on load sets the mobile fee part when an service zip code has already been provided", async () => {
test("on load sets the mobile fee part when a service zip code has already been provided", async () => {
// Arrange
const { wrapper } = setupMocks({});

View file

@ -13,7 +13,7 @@
@updated-contains-military-base="setContainsMilitaryBase"
linkWidgetName="ServiceZipLinkWidget"
modalWidgetName="ServiceZipModalWidget"
:optionalCallback="reloadShopData" />
:onZipUpdateCallback="reloadShopData" />
<alert
ref="alertMilitaryBaseZip"
class="my-5"
@ -66,7 +66,7 @@
ref="mobileLocationQuestions"
linkWidgetName="MobileLocationLinkWidget"
modalWidgetName="MobileLocationModalWidget"
:optionalCallback="reloadShopData" />
:onZipUpdateCallback="reloadShopData" />
<Transition name="fade" mode="out-in">
<shopQuestion
ref="shopQuestion"

View file

@ -69,7 +69,7 @@ export default {
},
linkWidgetName: String,
modalWidgetName: String,
optionalCallback: {
onZipUpdateCallback: {
type: Function,
},
},
@ -164,8 +164,8 @@ export default {
// Update the page level model
this.$emit("update:modelValue", this.internalModel);
if (this.optionalCallback) {
await this.optionalCallback(serviceZipCode);
if (this.onZipUpdateCallback) {
await this.onZipUpdateCallback(serviceZipCode);
}
this.closeModal();

View file

@ -166,25 +166,22 @@ describe("shop-question.vue", () => {
zipCode: "43065",
},
distanceInMiles: 16.2690495685233,
providerNumber: "003341",
providerNumber: null,
},
serviceZipCode: "43081",
selectedAppointmentType: null,
selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName,
isDisplayed: true
},
mountOptions: {
attachTo: document.body,
},
});
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
// Act
wrapper.vm.initializeComponent(shopQuestionInitialData);
wrapper.setProps({
selectedAppointmentType: "Inshop",
});
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
// Assert
@ -230,12 +227,12 @@ describe("shop-question.vue", () => {
serviceZipCode: "43081",
selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName,
isDisplayed: true
},
mountOptions: {
attachTo: document.body,
},
});
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
// Act
wrapper.vm.initializeComponent(shopQuestionInitialData);
@ -243,12 +240,13 @@ describe("shop-question.vue", () => {
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
const showMoreShopsLink = wrapper.findComponent({ ref: "showMoreShopsLink" });
// Assert
expect(showMoreShopsLink.exists()).toBe(true);
expect(showMoreShopsLink.exists()).toBe(true);
expect(showMoreShopsLink.isVisible()).toBe(true);
});
it("Should not display the 'Show more locations' link when there are fewer than three locations to chose from", async () => {
@ -308,12 +306,12 @@ describe("shop-question.vue", () => {
serviceZipCode: "43081",
selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName,
isDisplayed: true
},
mountOptions: {
attachTo: document.body,
},
});
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
// Act
wrapper.vm.initializeComponent(alsoShopQuestionInitialData);
@ -367,25 +365,30 @@ describe("shop-question.vue", () => {
serviceZipCode: "43081",
selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName,
isDisplayed: true
},
mountOptions: {
attachTo: document.body,
},
});
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
// Act
wrapper.vm.initializeComponent(shopQuestionInitialData);
await wrapper.vm.$nextTick();
wrapper.vm.answers = displayedAnswers;
wrapper.vm.shopIndex = 3;
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
const showMoreShopsLink = wrapper.findComponent({ ref: "showMoreShopsLink" });
await wrapper.vm.$nextTick();
showMoreShopsLink.trigger("click");
await wrapper.vm.$nextTick();
@ -456,7 +459,6 @@ describe("shop-question.vue", () => {
attachTo: document.body,
},
});
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
// Act
wrapper.vm.initializeComponent(shopQuestionInitialData);
@ -493,12 +495,13 @@ describe("shop-question.vue", () => {
attachTo: document.body,
},
});
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
// Act
wrapper.vm.initializeComponent(shopQuestionInitialData);
wrapper.setProps({
await wrapper.vm.$nextTick();
await wrapper.setProps({
selectedAppointmentType: "Inshop",
});
@ -508,87 +511,85 @@ describe("shop-question.vue", () => {
expect(wrapper.vm.answers.length).toEqual(3);
});
it("Should reload the shops when the service zip code changes", async () => {
// Arrange
const { wrapper } = setupMocks({
mixins: [mockMixin],
props: {
modelValue: {
address: {
city: "POWELL",
country: "US",
state: "OH",
streetAddress: "3938 POWELL RD",
zipCode: "43065",
},
distanceInMiles: 16.2690495685233,
providerNumber: "003341",
},
serviceZipCode: "43081",
selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName,
},
mountOptions: {
attachTo: document.body,
},
});
// it("Should reload the shops when the service zip code changes", async () => {
// // Arrange
// const { wrapper } = setupMocks({
// mixins: [mockMixin],
// props: {
// modelValue: {
// address: {
// city: "POWELL",
// country: "US",
// state: "OH",
// streetAddress: "3938 POWELL RD",
// zipCode: "43065",
// },
// distanceInMiles: 16.2690495685233,
// providerNumber: "003341",
// },
// serviceZipCode: "43081",
// selectedAppointmentType: "Dropoff",
// cmsWidgetName: cmsWidgetName,
// isDisplayed: true
// },
// mountOptions: {
// attachTo: document.body,
// },
// });
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
wrapper.vm.$options.methods.loadInitialData = jest.fn().mockImplementation(() => {
return new Promise((resolve) => {
resolve(mockNewShopList);
});
});
// wrapper.vm.$options.methods.loadInitialData = jest.fn().mockImplementation(() => {
// return new Promise((resolve) => {
// resolve(mockNewShopList);
// });
// });
// Act
wrapper.vm.initializeComponent(shopQuestionInitialData);
// // Act
// wrapper.vm.initializeComponent(shopQuestionInitialData);
await wrapper.vm.$options.watch.serviceZipCode.handler.call(wrapper.vm, "43054");
// await wrapper.vm.$options.watch.serviceZipCode.handler.call(wrapper.vm, "43054");
// Assert
expect(wrapper.vm.shopProviders.length).toEqual(3);
expect(wrapper.vm.shopProviders).toEqual(mockNewShopList.shopProviders);
});
// // Assert
// expect(wrapper.vm.shopProviders.length).toEqual(3);
// expect(wrapper.vm.shopProviders).toEqual(mockNewShopList.shopProviders);
// });
it("Should clear the existing answers when the service zip code changes", async () => {
// Arrange
const { wrapper } = setupMocks({
mixins: [mockMixin],
props: {
modelValue: {
address: {
city: "POWELL",
country: "US",
state: "OH",
streetAddress: "3938 POWELL RD",
zipCode: "43065",
},
distanceInMiles: 16.2690495685233,
providerNumber: "003341",
},
serviceZipCode: "43081",
selectedAppointmentType: "Dropoff",
cmsWidgetName: cmsWidgetName,
},
mountOptions: {
attachTo: document.body,
},
});
// it("Should clear the existing answers when the service zip code changes", async () => {
// // Arrange
// const { wrapper } = setupMocks({
// mixins: [mockMixin],
// props: {
// modelValue: {
// address: {
// city: "POWELL",
// country: "US",
// state: "OH",
// streetAddress: "3938 POWELL RD",
// zipCode: "43065",
// },
// distanceInMiles: 16.2690495685233,
// providerNumber: "003341",
// },
// serviceZipCode: "43081",
// selectedAppointmentType: "Dropoff",
// cmsWidgetName: cmsWidgetName,
// },
// mountOptions: {
// attachTo: document.body,
// },
// });
wrapper.vm.$refs.buttonQuestion.resetField = jest.fn();
// //Act
// wrapper.vm.initializeComponent(shopQuestionInitialData);
//Act
wrapper.vm.initializeComponent(shopQuestionInitialData);
// wrapper.setProps({
// selectedAppointmentType: "Inshop",
// });
wrapper.setProps({
selectedAppointmentType: "Inshop",
});
// await wrapper.vm.$nextTick();
await wrapper.vm.$nextTick();
// Assert
expect(wrapper.vm.answers.length).toEqual(3);
});
// // Assert
// expect(wrapper.vm.answers.length).toEqual(3);
// });
});
function setupMocks({ mountOptions, mixins, props, isShallowMount = true }) {

View file

@ -68,7 +68,6 @@ export default {
props: {
modelValue: {
type: Object,
required: true,
},
serviceZipCode: String,
selectedAppointmentType: String,
@ -167,7 +166,7 @@ export default {
this.scrollToPageBottom();
},
resetShopList() {
resetAnswers() {
this.answers = [];
this.shopIndex = 0;
this.selectedValue = "";
@ -185,17 +184,34 @@ export default {
watch: {
selectedAppointmentType: {
async handler(newValue) {
this.resetShopList();
this.resetAnswers();
await this.$nextTick();
if (newValue !== "Mobile") {
await this.getNextShopsFromList();
await this.$nextTick();
this.scrollToPageBottom();
}
},
},
shopProviders: {
async handler(newValue) {
this.resetAnswers();
await this.$nextTick();
if (this.selectedAppointmentType) {
const selectedShopIndex = newValue.findIndex(
(provider) => provider.providerNumber == this.modelValue?.providerNumber
);
if (selectedShopIndex >= 3) {
await this.getNextShopsFromList(selectedShopIndex + 1);
} else {
await this.getNextShopsFromList();
}
}
},
}
},
components: {
alert,