CSR-120: update with CMS content for blurry vehicle image
This commit is contained in:
parent
13f819262c
commit
c98a7a3f5d
3 changed files with 59 additions and 4 deletions
|
|
@ -3,6 +3,12 @@ import vehicleBanner from './vehicle-banner';
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
|
||||||
|
// Mock our module for promises.
|
||||||
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
settleAllPromises: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
describe('vehicleBanner', () => {
|
describe('vehicleBanner', () => {
|
||||||
const $store = {
|
const $store = {
|
||||||
|
|
@ -45,6 +51,17 @@ describe('vehicleBanner', () => {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Our mock data for our call to settleAllPromises
|
||||||
|
const mockData = {
|
||||||
|
getPageContent: {
|
||||||
|
VehicleBannerWidget: [{ GenericVehicleImage: "testurl" }],
|
||||||
|
isCmsContentReady: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// our mock implementation of settleAllPromises
|
||||||
|
settleAllPromises.mockImplementation(() => { return Promise.resolve(mockData);});
|
||||||
|
|
||||||
test('renders the blurrycar image when vehicleImageSrc is not present', () => {
|
test('renders the blurrycar image when vehicleImageSrc is not present', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions(actionList);
|
const mountOptions = getMountOptions(actionList);
|
||||||
|
|
@ -141,4 +158,23 @@ describe('vehicleBanner', () => {
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("vehicle-banner.vue should render data from CMS", async () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions(actionList);
|
||||||
|
mountOptions.global.mocks = {
|
||||||
|
...mountOptions.global.mocks,
|
||||||
|
$store
|
||||||
|
}
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(vehicleBanner, {
|
||||||
|
...mountOptions
|
||||||
|
});
|
||||||
|
// Call method getGenericVehicleImage on the component.
|
||||||
|
await wrapper.vm.getGenericVehicleImage();
|
||||||
|
// Wait for the DOM to update.
|
||||||
|
await nextTick();
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.genericVehicleImageSrc).toEqual("testurl");
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
class="vehicle-image img-fluid blurrycar"
|
class="vehicle-image img-fluid blurrycar"
|
||||||
src='@/assets/img/blurrycar.png'
|
:src="genericVehicleImageSrc"
|
||||||
alt=""
|
alt=""
|
||||||
v-else
|
v-else
|
||||||
/>
|
/>
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "vehicle-banner",
|
name: "vehicle-banner",
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -28,8 +31,8 @@ export default {
|
||||||
make: this.$store.state.order.vehicle.make,
|
make: this.$store.state.order.vehicle.make,
|
||||||
model: this.$store.state.order.vehicle.model,
|
model: this.$store.state.order.vehicle.model,
|
||||||
style: this.$store.state.order.vehicle.style
|
style: this.$store.state.order.vehicle.style
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
passedCarId: String
|
passedCarId: String
|
||||||
|
|
@ -39,9 +42,12 @@ export default {
|
||||||
years: [],
|
years: [],
|
||||||
carId: '',
|
carId: '',
|
||||||
vehicleImageSrc: '',
|
vehicleImageSrc: '',
|
||||||
|
genericVehicleImageSrc: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.getGenericVehicleImage();
|
||||||
|
|
||||||
if (this.passedCarId && this.passedCarId.length > 0) {
|
if (this.passedCarId && this.passedCarId.length > 0) {
|
||||||
this.getVehicleImage(this.passedCarId)
|
this.getVehicleImage(this.passedCarId)
|
||||||
} else if (this.vin && this.vin.length > 0) {
|
} else if (this.vin && this.vin.length > 0) {
|
||||||
|
|
@ -69,8 +75,20 @@ export default {
|
||||||
this.vehicleImageSrc = response.data.imgSrc;
|
this.vehicleImageSrc = response.data.imgSrc;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
getGenericVehicleImage() { // retrieve generic blurry vehicle image
|
||||||
|
const contentPromise = fetchCmsContentForPage("vehicle-year");
|
||||||
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "getPageContent",
|
||||||
|
promise: contentPromise,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
settleAllPromises(promiseResultMap).then((resultMap) => {
|
||||||
|
this.genericVehicleImageSrc = resultMap.getPageContent.VehicleBannerWidget[0].GenericVehicleImage;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
const widgetNames = {
|
const widgetNames = {
|
||||||
PAGE_HEADER_WIDGET: "PageHeaderWidget",
|
PAGE_HEADER_WIDGET: "PageHeaderWidget",
|
||||||
RADIO_QUESTION_WIDGET: "RadioQuestionWidget",
|
RADIO_QUESTION_WIDGET: "RadioQuestionWidget",
|
||||||
|
VEHICLE_BANNER_WIDGET: "VehicleBannerWidget",
|
||||||
};
|
};
|
||||||
|
|
||||||
export { widgetNames };
|
export { widgetNames };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue