From 8e0ec66203f2c37e44e7f1caf8a6eaa900dd8009 Mon Sep 17 00:00:00 2001 From: Johan Gunawan Date: Wed, 18 Jan 2023 15:36:46 -0500 Subject: [PATCH] SSR-189 --- .../vin-location-information.spec.js | 58 +++ .../vehicle-not-found-alert.vue | 1 + .../vehicle-not-matched-alert.vue | 1 + .../vin-lookup-alerts.spec.js | 57 +++ src/layouts/vin-lookup/vin-lookup.spec.js | 453 ++++++++++++++++++ src/layouts/vin-lookup/vin-lookup.vue | 127 +++-- src/router/router-constants/routing-table.js | 26 +- src/router/router-params.js | 6 +- src/store/index.js | 10 + 9 files changed, 706 insertions(+), 33 deletions(-) create mode 100644 src/layouts/vin-lookup/vin-location-information/vin-location-information.spec.js create mode 100644 src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.spec.js create mode 100644 src/layouts/vin-lookup/vin-lookup.spec.js diff --git a/src/layouts/vin-lookup/vin-location-information/vin-location-information.spec.js b/src/layouts/vin-lookup/vin-location-information/vin-location-information.spec.js new file mode 100644 index 00000000..b6a5ed5d --- /dev/null +++ b/src/layouts/vin-lookup/vin-location-information/vin-location-information.spec.js @@ -0,0 +1,58 @@ +/* eslint-env jest */ +import { render } from '@testing-library/vue'; +import userEvent from '@testing-library/user-event'; +import '@testing-library/jest-dom'; +import VinLocationInformationComponent from './vin-location-information.vue'; + +const mockText = Object.freeze({ + HEADER: 'Mock Header', + BODY: 'Mock Body', +}); + +const mountOptions = { + global: { + mixins: [ + { + methods: { + getCmsContent: jest.fn((cmsWidgetName, fieldName) => { + if (cmsWidgetName === 'WhereCanIFindMyVINToggle') { + if (fieldName === 'HeaderText') { + return mockText.HEADER; + } + + if (fieldName === 'BodyText') { + return mockText.BODY; + } + } + + return ''; + }), + }, + }, + ], + }, +}; + +describe('vin-location-information.vue', () => { + test('VIN Location Detail is NOT displayed on the screen as a default.', () => { + const { container } = render(VinLocationInformationComponent, mountOptions); + + const vinLocationDetailSection = container.querySelector('#vin-location-detail-wrapper'); + + expect(vinLocationDetailSection).not.toBeVisible(); + }); + + test('Toggling VIN Location Detail', async () => { + const user = userEvent.setup(); + const { container, getByText } = render(VinLocationInformationComponent, mountOptions); + const toggleLink = getByText(mockText.HEADER); + + await user.click(toggleLink); + let vinLocationDetailSection = container.querySelector('#vin-location-detail-wrapper'); + expect(vinLocationDetailSection).toBeVisible(); + + await user.click(toggleLink); + vinLocationDetailSection = container.querySelector('#vin-location-detail-wrapper'); + expect(vinLocationDetailSection).not.toBeVisible(); + }); +}); diff --git a/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue index dba53894..d6a27140 100644 --- a/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue +++ b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue @@ -3,6 +3,7 @@ alertClass="alert-danger" cmsWidgetName="AlertVinNotFoundWidget" id="vehicle-not-found-alert" + aria-label="vehicle-not-found-alert" /> diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index eafc217b..273fccb4 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -100,7 +100,31 @@ const routingTable = function(store) { { scenario: navigationScenarios.CLICKED_BACK, destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, - }, + }, + { + scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, + destinationIssPageValue: issPageValues.VEHICLE_PARTS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, + }, ], }, { diff --git a/src/router/router-params.js b/src/router/router-params.js index a8ee17b9..ee03d859 100644 --- a/src/router/router-params.js +++ b/src/router/router-params.js @@ -1,5 +1,5 @@ -const routerParams = { - DISPLAY_VEHICLE_CHANGE_ALERT: "displayVehicleChangeAlert", -}; +const routerParams = Object.freeze({ + DISPLAY_VEHICLE_CHANGE_ALERT: "displayVehicleChangeAlert", +}); export { routerParams }; \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 95d626f7..f9ce744e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -389,6 +389,16 @@ export const useMainStore = defineStore({ }); }, + lookupVehicleByVin(vin) { + return globalMethods.callHttpClient({ + method: endpoints.LookupVehicleByVin.method, + endpoint: endpoints.LookupVehicleByVin.url, + payload: { + vin, + }, + }); + }, + setVehicle() { return globalMethods .callHttpClient({