Merge pull request #1639 from Safelite/feature/CSR-1885

CSR-1885
This commit is contained in:
AMSNEHA 2023-12-14 17:58:29 +05:30 committed by GitHub
commit 511da76fa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 72 deletions

View file

@ -216,9 +216,9 @@ export default {
styleQuestionInitialDataPromise
)
vm.initializeMMSComponent(
resultMap.makeQuestionInitialData,
resultMap.modelQuestionInitialData,
resultMap.styleQuestionInitialData
resultMap.makeQuestionInitialData?.response?.data,
resultMap.modelQuestionInitialData?.response?.data,
resultMap.styleQuestionInitialData?.response?.data
);
});
},
@ -226,17 +226,16 @@ export default {
watch: {
async selectedYear(year) {
if (year) {
this.yearDropdown.disabled = true;
const result = await this.getMakeOptions(year);
this.makeOptions = result?.data;
if (this.selectedYearfromStore() !== year) {
this.selectedMake = null;
this.selectedModel = null;
this.selectedStyle = null;
this.carId = null;
if (result?.year == year) {
this.makeOptions = result?.response?.data;
if (this.selectedYearfromStore() !== year) {
this.selectedMake = null;
this.selectedModel = null;
this.selectedStyle = null;
this.carId = null;
}
}
this.yearDropdown.disabled = false;
this.yearDropdown.focus();
} else {
this.makeOptions = [];
this.selectedMake = null;
@ -247,17 +246,16 @@ export default {
},
async selectedMake(make) {
if (make) {
this.makeDropdown.disabled = true;
const result = await this.getModelOptions(this.selectedYear, make);
this.modelOptions = result?.data;
if (this.modelOptions.length === 1) this.selectedModel = this.modelOptions[0];
else {
this.selectedModel = null;
this.selectedStyle = null;
this.carId = null;
if (decodeURIComponent(result?.make) == make) {
this.modelOptions = result?.response?.data;
if (this.modelOptions.length === 1) this.selectedModel = this.modelOptions[0];
else {
this.selectedModel = null;
this.selectedStyle = null;
this.carId = null;
}
}
this.makeDropdown.disabled = false;
this.makeDropdown.focus();
} else {
this.modelOptions = [];
this.selectedModel = null;
@ -267,25 +265,24 @@ export default {
},
async selectedModel(model) {
if (model) {
this.modelDropdown.disabled = true;
const result = await this.getStyleOptions(
this.selectedYear,
this.selectedMake,
model
);
this.styleOptions = result?.data;
if (this.styleOptions.length === 1) {
const sameStyle = this.selectedStyle === this.styleOptions[0];
this.selectedStyle = this.styleOptions[0];
if (sameStyle) {
this.getVehicleDetails();
if (decodeURIComponent(result?.model) == model) {
this.styleOptions = result?.response?.data;
if (this.styleOptions.length === 1) {
const sameStyle = this.selectedStyle === this.styleOptions[0];
this.selectedStyle = this.styleOptions[0];
if (sameStyle) {
this.getVehicleDetails();
}
} else {
this.selectedStyle = null;
this.carId = null;
}
} else {
this.selectedStyle = null;
this.carId = null;
}
this.modelDropdown.disabled = false;
this.modelDropdown.focus();
} else {
this.styleOptions = [];
this.selectedStyle = null;
@ -294,10 +291,7 @@ export default {
},
async selectedStyle(style) {
if (style) {
this.styleDropdown.disabled = true;
this.getVehicleDetails();
this.styleDropdown.disabled = false;
this.styleDropdown.focus();
} else {
this.imageUrl = null;
this.carId = null;
@ -315,18 +309,6 @@ export default {
else if (this.imageUrl == null && this.carId !== null) return false;
else return true;
},
yearDropdown() {
return document.getElementById("yearQuestionField");
},
makeDropdown() {
return document.getElementById("makeQuestionField");
},
modelDropdown() {
return document.getElementById("modelQuestionField");
},
styleDropdown() {
return document.getElementById("styleQuestionField");
},
allDataRetrieved() {
return (
!!this.selectedYear &&

View file

@ -854,33 +854,54 @@ export const actions = {
},
getVehicleMakes(context, { payload: { year }, pageNameToLog }) {
return globalMethods.callHttpClient({
method: endpoints.GetVehicleMakes.method,
endpoint: `${endpoints.GetVehicleMakes.url}/${year}`,
payload: {},
logApiCall: true,
pageNameToLog: pageNameToLog,
});
return globalMethods
.callHttpClient({
method: endpoints.GetVehicleMakes.method,
endpoint: `${endpoints.GetVehicleMakes.url}/${year}`,
payload: {},
logApiCall: true,
pageNameToLog: pageNameToLog,
})
.then((response) => {
return {
response,
year,
};
});
},
getVehicleModels(context, { payload: { year, make }, pageNameToLog }) {
return globalMethods.callHttpClient({
method: endpoints.GetVehicleModels.method,
endpoint: `${endpoints.GetVehicleModels.url}/${year}/${make}`,
payload: {},
logApiCall: true,
pageNameToLog: pageNameToLog,
});
return globalMethods
.callHttpClient({
method: endpoints.GetVehicleModels.method,
endpoint: `${endpoints.GetVehicleModels.url}/${year}/${make}`,
payload: {},
logApiCall: true,
pageNameToLog: pageNameToLog,
})
.then((response) => {
return {
response,
make,
};
});
},
getVehicleStyles(context, { payload: { year, make, model }, pageNameToLog }) {
return globalMethods.callHttpClient({
method: endpoints.GetVehicleStyles.method,
endpoint: `${endpoints.GetVehicleStyles.url}/${year}/${make}/${model}`,
payload: {},
logApiCall: true,
pageNameToLog: pageNameToLog,
});
return globalMethods
.callHttpClient({
method: endpoints.GetVehicleStyles.method,
endpoint: `${endpoints.GetVehicleStyles.url}/${year}/${make}/${model}`,
payload: {},
logApiCall: true,
pageNameToLog: pageNameToLog,
})
.then((response) => {
return {
response,
model,
};
});
},
getVehicle(context, { payload: { year, make, model, style }, pageNameToLog }) {

View file

@ -493,7 +493,7 @@ describe("Actions", () => {
pageNameToLog: "test",
});
expect(response.data).toEqual(["Acura", "Honda"]);
expect(response.response.data).toEqual(["Acura", "Honda"]);
});
it("getVehicleModels action, should return models list", async () => {
@ -511,7 +511,7 @@ describe("Actions", () => {
pageNameToLog: "test",
});
expect(response.data).toEqual(["ILX", "RDX"]);
expect(response.response.data).toEqual(["ILX", "RDX"]);
});
it("getVehicleStyles action, should return models list", async () => {
@ -529,7 +529,7 @@ describe("Actions", () => {
pageNameToLog: "test",
});
expect(response.data).toEqual({ style: "4 DOOR SEDAN" });
expect(response.response.data).toEqual({ style: "4 DOOR SEDAN" });
});
it("getVehicle action, should get vehicle data ", async () => {