Merge branch 'develop' into feature/CSR-120_vehicle-banner-2
This commit is contained in:
commit
e3a2ff431e
27 changed files with 394 additions and 278 deletions
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
statements: 60,
|
statements: 70,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="radio_question">
|
<div class="radio_question">
|
||||||
<div class="needed_car_info mt-4 mb-2 d-flex">
|
<div class="needed_car_info mt-5 mb-2 d-flex">
|
||||||
<span class="text-center fs-6 fw-bold w-100 needed_car_info-text">{{
|
<span class="text-center fs-6 fw-bold w-100 needed_car_info-text">{{
|
||||||
questionText
|
questionText
|
||||||
}}</span>
|
}}</span>
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<div class="w-100 d-flex justify-content-center">
|
<div class="w-100 d-flex justify-content-center">
|
||||||
<div class="car_list overflow-scroll position-absolute container-fluid pt-1" role="radiogroup" aria-labelledby="select-year-radio-group">
|
<div class="car_list overflow-scroll position-absolute container-fluid pt-1" role="radiogroup" aria-labelledby="select-year-radio-group">
|
||||||
<h3 class="visually-hidden" id="select-year-radio-group">*</h3>
|
<h3 class="visually-hidden" id="select-year-radio-group">*</h3>
|
||||||
<radio v-for="answer in answers" :key="answer" class="mb-2"
|
<radio v-for="answer in answers" :key="answer"
|
||||||
:radioID="answer"
|
:radioID="answer"
|
||||||
@click="chooseAnswer(answer)"
|
@click="chooseAnswer(answer)"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
|
|
@ -35,4 +35,4 @@ export default {
|
||||||
radio,
|
radio,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
29
src/helpers/cms-content-helper.js
Normal file
29
src/helpers/cms-content-helper.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
|
import { widgetNames } from "@/constants/widget-names.js";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
|
export function fetchCmsContentForPage(fmgPage) {
|
||||||
|
return store.dispatch(storeActions.GET_PAGE_DATA, { pageName: fmgPage }).then((response) => {
|
||||||
|
const pageDataFromCms = {
|
||||||
|
isCmsContentReady: false
|
||||||
|
};
|
||||||
|
|
||||||
|
response.data.Result.forEach((widget) => {
|
||||||
|
if (Object.values(widgetNames).includes(widget.Type)) {
|
||||||
|
// If we already have this widget, push it on the collection
|
||||||
|
if (widget.Type in pageDataFromCms) {
|
||||||
|
pageDataFromCms[widget.Type].push(widget.Model);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pageDataFromCms[widget.Type] = [widget.Model];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Our 'Page' is ready because we have data now
|
||||||
|
pageDataFromCms.isCmsContentReady = true;
|
||||||
|
|
||||||
|
return pageDataFromCms;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
53
src/helpers/cms-helper.spec.js
Normal file
53
src/helpers/cms-helper.spec.js
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
import { dispatch } from "@/store";
|
||||||
|
|
||||||
|
jest.mock("@/store", () => ({
|
||||||
|
dispatch: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
it("cms-content-helper: Should return data from CMS", () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const cmsMockData = {
|
||||||
|
Result: [
|
||||||
|
{
|
||||||
|
Type: "VehicleBannerWidget",
|
||||||
|
Model: {
|
||||||
|
ImageId: "28452dcb-7762-4cc9-ab09-7643d0b89203",
|
||||||
|
GenericVehicleImage: "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3",
|
||||||
|
GenericVehicleImageFilePath: "images/default-source/default-album/blurred-image.jpg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: "PageHeaderWidget",
|
||||||
|
Model: {
|
||||||
|
"HeaderText": "Select a year to get started"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: "PageHeaderWidget",
|
||||||
|
Model: {
|
||||||
|
"HeaderText": "Select a model"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: "RadioQuestionWidget",
|
||||||
|
Model: {
|
||||||
|
"QuestionText": "What year is your vehicle?"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch.mockImplementation(() => Promise.resolve({ data: cmsMockData }));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
fetchCmsContentForPage('testPage').then((response) => {
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(response.isCmsContentReady).toBe(true);
|
||||||
|
expect(response.PageHeaderWidget[0].HeaderText).toEqual('Select a year to get started');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
29
src/helpers/layout-helper.js
Normal file
29
src/helpers/layout-helper.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
export function settleAllPromises(promiseResultMap) {
|
||||||
|
|
||||||
|
// Pull our keys out of the promise 'table'
|
||||||
|
const promiseNames = Object.entries(promiseResultMap);
|
||||||
|
|
||||||
|
return Promise.allSettled(promiseNames.map(e => e[1]).map(n => n.promise))
|
||||||
|
.then(results => {
|
||||||
|
|
||||||
|
const resultMap = {};
|
||||||
|
|
||||||
|
// Build a map of the results
|
||||||
|
for (let i = 0; i < results.length; ++i) {
|
||||||
|
|
||||||
|
const promiseName = promiseNames[i][1].resultKey;
|
||||||
|
|
||||||
|
// Some Promises like the cms content call don't have a 'data' field
|
||||||
|
// when returned, so other promises do. Map the results to the object
|
||||||
|
// so that the object is the return data.
|
||||||
|
|
||||||
|
if (results[i].value.data === undefined) {
|
||||||
|
resultMap[promiseName] = results[i].value
|
||||||
|
} else {
|
||||||
|
resultMap[promiseName] = results[i].value.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
});
|
||||||
|
}
|
||||||
28
src/helpers/layout-helper.spec.js
Normal file
28
src/helpers/layout-helper.spec.js
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
|
||||||
|
it("layout-helper: Should settle all promises and return mapped promise results", () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const mockPromiseOne = Promise.resolve({ data: "test-data" });
|
||||||
|
const mockPromiseTwo = Promise.resolve({ data: "test-data-two" });
|
||||||
|
|
||||||
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "MockResultOne",
|
||||||
|
promise: mockPromiseOne,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "MockResultTwo",
|
||||||
|
promise: mockPromiseTwo,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
settleAllPromises(promiseResultMap).then(results => {
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(results.MockResultOne).toEqual('test-data');
|
||||||
|
expect(results.MockResultTwo).toEqual('test-data-two');
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
|
||||||
export function getMountOptions(mockData, cmsMockData = null) {
|
export function getMountOptions(mockData) {
|
||||||
// Define our mocks to attached to the 'global' object for Vue/Jest.
|
// Define our mocks to attached to the 'global' object for Vue/Jest.
|
||||||
const mocks = {};
|
const mocks = {};
|
||||||
|
|
||||||
|
|
@ -18,16 +18,9 @@ export function getMountOptions(mockData, cmsMockData = null) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(cmsMockData){
|
|
||||||
mocks.GetContentFromCms = jest.fn();
|
|
||||||
mocks.GetContentFromCms.mockImplementation(() =>
|
|
||||||
{
|
|
||||||
return cmsMockData;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mock store actions from js file
|
// Mock store actions from js file
|
||||||
mocks.storeActions = storeActions;
|
mocks.storeActions = storeActions;
|
||||||
|
|
||||||
const global = {
|
const global = {
|
||||||
mocks: mocks,
|
mocks: mocks,
|
||||||
plugins: [store]
|
plugins: [store]
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
<buttonPrimary
|
<buttonPrimary
|
||||||
buttonText="Primary"
|
buttonText="Primary"
|
||||||
loaderColor="white"
|
loaderColor="white"
|
||||||
loaderPosition="right"
|
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -48,7 +47,6 @@
|
||||||
<buttonSecondary
|
<buttonSecondary
|
||||||
buttonText="Secondary"
|
buttonText="Secondary"
|
||||||
loaderColor="white"
|
loaderColor="white"
|
||||||
loaderPosition="right"
|
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -65,43 +63,125 @@
|
||||||
errorText="Test error message"
|
errorText="Test error message"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1.5"
|
sizeInRem="1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row my-4">
|
<div class="row my-4">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h4 class="m-0 p-2 bg-light rounded">Radio Button Group</h4>
|
<h4 class="m-0 p-2 bg-light rounded">Radio Button Group - Single-Line</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
|
<!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
|
||||||
<div role="radiogroup" aria-labelledby="select-year-radio-group" class="col my-3 d-flex align-items-center flex-column">
|
<div role="radiogroup" aria-labelledby="demo-1-radio-group" class="col my-3 d-flex align-items-center flex-column">
|
||||||
<!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. -->
|
<!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. -->
|
||||||
<h3 class="visually-hidden" id="select-year-radio-group">Select Vehicle Year</h3>
|
<h3 class="visually-hidden" id="demo-1-radio-group">Select Vehicle Year</h3>
|
||||||
<radioList
|
<radio
|
||||||
groupName="demo"
|
groupName="demo-1"
|
||||||
ariaLabelBy="vehicle-year"
|
ariaLabelBy="vehicle-year"
|
||||||
radioID="2021"
|
radioID="2021"
|
||||||
|
textPosition="text-start"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1.5"
|
sizeInRem="1"
|
||||||
/>
|
/>
|
||||||
<radioList
|
<radio
|
||||||
groupName="demo"
|
groupName="demo-1"
|
||||||
ariaLabelBy="vehicle-year"
|
ariaLabelBy="vehicle-year"
|
||||||
radioID="2020"
|
radioID="2020"
|
||||||
|
textPosition="text-start"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1.5"
|
sizeInRem="1"
|
||||||
/>
|
/>
|
||||||
<radioList
|
<radio
|
||||||
groupName="demo"
|
groupName="demo-1"
|
||||||
ariaLabelBy="vehicle-year"
|
ariaLabelBy="vehicle-year"
|
||||||
radioID="2019"
|
radioID="2019"
|
||||||
|
textPosition="text-start"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1.5"
|
sizeInRem="1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row my-4">
|
||||||
|
<div class="col">
|
||||||
|
<h4 class="m-0 p-2 bg-light rounded">Radio Button Group - Multi-Line</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
|
||||||
|
<div role="radiogroup" aria-labelledby="demo-2-radio-group" class="col my-3 d-flex align-items-center flex-column">
|
||||||
|
<!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. -->
|
||||||
|
<h3 class="visually-hidden" id="demo-2-radio-group">Select Vehicle Year</h3>
|
||||||
|
<radio
|
||||||
|
groupName="demo-2"
|
||||||
|
ariaLabelBy="vehicle-make"
|
||||||
|
radioID="Chevrolet"
|
||||||
|
radioLabelSubCopy="Test sub-headline"
|
||||||
|
textPosition="text-start"
|
||||||
|
loaderColor="blue"
|
||||||
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
/>
|
||||||
|
<radio
|
||||||
|
groupName="demo-2"
|
||||||
|
ariaLabelBy="vehicle-make"
|
||||||
|
radioID="Dodge"
|
||||||
|
radioLabelSubCopy="Test sub-headline"
|
||||||
|
textPosition="text-start"
|
||||||
|
loaderColor="blue"
|
||||||
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
/>
|
||||||
|
<radio
|
||||||
|
groupName="demo-2"
|
||||||
|
ariaLabelBy="vehicle-make"
|
||||||
|
radioID="Ford"
|
||||||
|
radioLabelSubCopy="Test sub-headline"
|
||||||
|
textPosition="text-start"
|
||||||
|
loaderColor="blue"
|
||||||
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
|
||||||
|
<div role="radiogroup" aria-labelledby="demo-3-radio-group" class="col my-3 d-flex align-items-center flex-column">
|
||||||
|
<!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. -->
|
||||||
|
<h3 class="visually-hidden" id="demo-3-radio-group">Select Vehicle Year</h3>
|
||||||
|
<radio
|
||||||
|
groupName="demo-3"
|
||||||
|
ariaLabelBy="vehicle-model"
|
||||||
|
radioID="Corvette"
|
||||||
|
radioLabelSubCopy="Test sub-headline"
|
||||||
|
textPosition="text-center"
|
||||||
|
loaderColor="blue"
|
||||||
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
/>
|
||||||
|
<radio
|
||||||
|
groupName="demo-3"
|
||||||
|
ariaLabelBy="vehicle-model"
|
||||||
|
radioID="Testarosa"
|
||||||
|
radioLabelSubCopy="Test sub-headline"
|
||||||
|
textPosition="text-center"
|
||||||
|
loaderColor="blue"
|
||||||
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
/>
|
||||||
|
<radio
|
||||||
|
groupName="demo-3"
|
||||||
|
ariaLabelBy="vehicle-model"
|
||||||
|
radioID="S600"
|
||||||
|
radioLabelSubCopy="Test sub-headline"
|
||||||
|
textPosition="text-center"
|
||||||
|
loaderColor="blue"
|
||||||
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -250,7 +330,7 @@
|
||||||
import buttonSecondary from "@/ux-components/button-secondary/button-secondary";
|
import buttonSecondary from "@/ux-components/button-secondary/button-secondary";
|
||||||
import radioCard from "@/ux-components/radio-card/radio-card";
|
import radioCard from "@/ux-components/radio-card/radio-card";
|
||||||
import listButton from "@/ux-components/list-button/list-button";
|
import listButton from "@/ux-components/list-button/list-button";
|
||||||
import radioList from "@/ux-components/radio-list/radio-list";
|
import radio from "@/ux-components/radio/radio";
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -260,7 +340,7 @@
|
||||||
buttonSecondary,
|
buttonSecondary,
|
||||||
radioCard,
|
radioCard,
|
||||||
listButton,
|
listButton,
|
||||||
radioList,
|
radio,
|
||||||
alert,
|
alert,
|
||||||
vehicleBanner
|
vehicleBanner
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,56 @@
|
||||||
import { shallowMount, flushPromises } from "@vue/test-utils";
|
import { shallowMount, flushPromises } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import vehicleYear from "@/layouts/vehicle-year/vehicle-year.vue";
|
import vehicleYear from "@/layouts/vehicle-year/vehicle-year.vue";
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
|
import { nextTick } from 'vue'
|
||||||
|
|
||||||
|
// Mock our module for promises.
|
||||||
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
settleAllPromises: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
describe("vehicle-year.vue", () => {
|
describe("vehicle-year.vue", () => {
|
||||||
test("vehicle-year.vue should render data from CMS", async () => {
|
test("vehicle-year.vue should render data from CMS", async () => {
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
const cmsMockData = {
|
|
||||||
PageHeaderWidget: [{ HeaderText: "Select a year to get started" }],
|
// Our mock data for our call to settleAllPromises
|
||||||
RadioQuestionWidget: [{ QuestionText: "What year is your vehicle?" }],
|
const mockData = {
|
||||||
|
getPageContent: {
|
||||||
|
PageHeaderWidget: [{ HeaderText: "Select a year to get started" }],
|
||||||
|
RadioQuestionWidget: [{ QuestionText: "What year is your vehicle?" }],
|
||||||
|
isCmsContentReady: true,
|
||||||
|
},
|
||||||
|
getVehicleYear: [2023, 2022, 2021]
|
||||||
}
|
}
|
||||||
|
|
||||||
const mountOptions = getMountOptions({}, cmsMockData);
|
// our router information needed.
|
||||||
|
const to = {
|
||||||
|
query: {
|
||||||
|
fmgPage: 'vehicle-year'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const mountOptions = getMountOptions(mockData);
|
||||||
|
|
||||||
|
// our mock implementation of settleAllPromises
|
||||||
|
settleAllPromises.mockImplementation(() => { return Promise.resolve(mockData);});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(vehicleYear, mountOptions);
|
const wrapper = shallowMount(vehicleYear, mountOptions);
|
||||||
await flushPromises();
|
|
||||||
|
// Call our beforeRouteEnter on the component.
|
||||||
|
// This passes (c) => c(wrapper.vm) so that next can be called and our
|
||||||
|
// data can be set.
|
||||||
|
vehicleYear.beforeRouteEnter.call(wrapper.vm, to, undefined, (c) => c(wrapper.vm));
|
||||||
|
|
||||||
|
await nextTick(); // Wait for the DOM to update.
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const header = await wrapper.find(".Header");
|
const header = await wrapper.find(".Header");
|
||||||
expect(header.attributes("text")).toEqual("Select a year to get started");
|
expect(header.attributes("text")).toEqual("Select a year to get started");
|
||||||
|
|
||||||
const yearQuestion = await wrapper.findComponent({name: 'year-question'});
|
const yearQuestion = wrapper.findComponent({ name: 'year-question' });
|
||||||
expect(yearQuestion.attributes("questiontext")).toEqual("What year is your vehicle?");
|
expect(yearQuestion.attributes("questiontext")).toEqual("What year is your vehicle?");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,69 @@
|
||||||
<template v-if="isCmsContentReady">
|
<template v-if="isCmsContentReady">
|
||||||
<div class="select-car">
|
<div class="select-car">
|
||||||
<div class="select-car-form rounded text-center">
|
<div class="select-car-form rounded text-center">
|
||||||
<vehicleBanner />
|
<vehicleBanner />
|
||||||
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
||||||
<yearQuestion :questionText="radioQuestionWidgets.QuestionText" />
|
<yearQuestion :questionText="radioQuestionWidgets.QuestionText" :years="vehicleYears" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Components
|
||||||
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
||||||
import pageHeader from "@/ux-components/header/header";
|
import pageHeader from "@/ux-components/header/header";
|
||||||
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
||||||
|
|
||||||
|
// Supporting files
|
||||||
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
import store from "@/store";
|
||||||
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "vehicle-year",
|
name: "vehicle-year",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
pageHeaderWidgets: {},
|
pageHeaderWidgets: {},
|
||||||
radioQuestionWidgets: {},
|
radioQuestionWidgets: {},
|
||||||
};
|
vehicleYears: [],
|
||||||
},
|
};
|
||||||
computed: {},
|
},
|
||||||
async created() {
|
computed: {},
|
||||||
const pageContent = await this.GetContentFromCms();
|
|
||||||
this.pageHeaderWidgets = pageContent.PageHeaderWidget[0];
|
beforeRouteEnter(to, from, next) {
|
||||||
this.radioQuestionWidgets = pageContent.RadioQuestionWidget[0];
|
|
||||||
},
|
// Call APIs
|
||||||
components: {
|
const contentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
yearQuestion,
|
const getVehicleYearPromise = store.dispatch(storeActions.GET_VEHICLE_YEARS, {});
|
||||||
pageHeader,
|
|
||||||
vehicleBanner,
|
// Settle promises and get results
|
||||||
},
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "getPageContent",
|
||||||
|
promise: contentPromise,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "getVehicleYear",
|
||||||
|
promise: getVehicleYearPromise,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
settleAllPromises(promiseResultMap).then((resultMap) => {
|
||||||
|
|
||||||
|
// Call the "next" function to complete the transition to this page.
|
||||||
|
next((vm) => {
|
||||||
|
vm.pageHeaderWidgets = resultMap.getPageContent.PageHeaderWidget[0];
|
||||||
|
vm.radioQuestionWidgets = resultMap.getPageContent.RadioQuestionWidget[0];
|
||||||
|
vm.vehicleYears = resultMap.getVehicleYear;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
components: {
|
||||||
|
yearQuestion,
|
||||||
|
pageHeader,
|
||||||
|
vehicleBanner
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1 @@
|
||||||
import { shallowMount, flushPromises } from "@vue/test-utils";
|
test.todo("some test to be written in the future");
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
|
||||||
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
|
||||||
|
|
||||||
describe('year-question.vue', () => {
|
|
||||||
|
|
||||||
test('year-question should call API to get years', async () => {
|
|
||||||
// Arrange
|
|
||||||
const mockDataAndAction = {
|
|
||||||
actionList: [{ actionName: storeActions.GET_VEHICLE_YEARS, data: ["2023", "2022", "2021"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const mountOptions = getMountOptions(mockDataAndAction);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const wrapper = shallowMount(yearQuestion, mountOptions);
|
|
||||||
await wrapper.setProps({questionText: 'What year is your vehicle?'})
|
|
||||||
await flushPromises();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
const radioQuestion = await wrapper.findComponent({name: 'radioQuestion'});
|
|
||||||
expect(radioQuestion.attributes('questiontext')).toBe("What year is your vehicle?");
|
|
||||||
expect(radioQuestion.attributes('answers')).toBe('2023,2022,2021');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,9 @@ export default {
|
||||||
name: "year-question",
|
name: "year-question",
|
||||||
props: {
|
props: {
|
||||||
questionText: String,
|
questionText: String,
|
||||||
},
|
years: Array
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
years: [],
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.dispatchNonBlockingStoreAction(this.storeActions.GET_VEHICLE_YEARS, {}).then((response) => {
|
|
||||||
this.years = response.data;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
radioQuestion,
|
radioQuestion,
|
||||||
|
|
|
||||||
|
|
@ -23,30 +23,6 @@ export default {
|
||||||
|
|
||||||
return this.$store.dispatch(type, payload);
|
return this.$store.dispatch(type, payload);
|
||||||
},
|
},
|
||||||
GetContentFromCms() {
|
|
||||||
return this.dispatchNonBlockingStoreAction(this.storeActions.GET_PAGE_DATA,{ pageName: this.$route.query.fmgPage }).then((response) => {
|
|
||||||
|
|
||||||
const pageDataFromCms = {};
|
|
||||||
|
|
||||||
response.data.Result.forEach((widget) => {
|
|
||||||
if (Object.values(this.widgetNames).includes(widget.Type)) {
|
|
||||||
// If we already have this widget, push it on the collection
|
|
||||||
if (widget.Type in pageDataFromCms) {
|
|
||||||
pageDataFromCms[widget.Type].push(widget.Model);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pageDataFromCms[widget.Type] = [widget.Model];
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Our 'Page' is ready because we have data now
|
|
||||||
this.isCmsContentReady = true;
|
|
||||||
|
|
||||||
return pageDataFromCms;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
storeActions() {
|
storeActions() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import baseMixin from "@/mixins/base-mixin"
|
import baseMixin from "@/mixins/base-mixin"
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
import { widgetNames } from "@/constants/widget-names.js";
|
import { widgetNames } from "@/constants/widget-names.js";
|
||||||
import { flushPromises } from "@vue/test-utils";
|
|
||||||
|
|
||||||
describe("baseMixin.js", () => {
|
describe("baseMixin.js", () => {
|
||||||
test('dispatchNonblockingStoreAction: calls dispatch with type and payload', () => {
|
test('dispatchNonblockingStoreAction: calls dispatch with type and payload', () => {
|
||||||
|
|
@ -23,60 +22,6 @@ describe("baseMixin.js", () => {
|
||||||
|
|
||||||
expect(mixIn.methods.$store.dispatch).toBeCalledWith(type, payload);
|
expect(mixIn.methods.$store.dispatch).toBeCalledWith(type, payload);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GetContentFromCms: Should return mapped data and call dispatchNonblockingStoreAction', async () => {
|
|
||||||
const mixIn = getMixInInstance({});
|
|
||||||
|
|
||||||
// Mock dispatch action
|
|
||||||
mixIn.methods.dispatchNonBlockingStoreAction = jest.fn();
|
|
||||||
mixIn.methods.dispatchNonBlockingStoreAction.mockImplementation((action) => {
|
|
||||||
if (action === 'getPageData') {
|
|
||||||
return Promise.resolve({
|
|
||||||
data: {
|
|
||||||
Result: [
|
|
||||||
{
|
|
||||||
Type: "PageConfigWidget",
|
|
||||||
Model: {
|
|
||||||
LayoutNames: [
|
|
||||||
"None",
|
|
||||||
"vehicle-year"
|
|
||||||
],
|
|
||||||
LayoutStyle: "vehicle-year"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Type: "RadioQuestionWidget",
|
|
||||||
Model: {
|
|
||||||
"QuestionText": "What year is your vehicle?"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Type: "RadioQuestionWidget",
|
|
||||||
Model: {
|
|
||||||
"QuestionText": "This is a second radio question"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Type: "PageHeaderWidget",
|
|
||||||
Model: {
|
|
||||||
"HeaderText": "Select a year to get started"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await mixIn.methods.GetContentFromCms();
|
|
||||||
await flushPromises();
|
|
||||||
|
|
||||||
|
|
||||||
expect(mixIn.methods.dispatchNonBlockingStoreAction).toBeCalledWith(storeActions.GET_PAGE_DATA, { pageName: 'test-page'});
|
|
||||||
|
|
||||||
expect(result.PageHeaderWidget[0].HeaderText).toEqual('Select a year to get started');
|
|
||||||
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
function getMixInInstance({ isDispatchSuccess = true }) {
|
function getMixInInstance({ isDispatchSuccess = true }) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ export default createStore({
|
||||||
storage: window.sessionStorage,
|
storage: window.sessionStorage,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// IMPORTANT: Be VERY careful when modifying these fields for at least a few reasons:
|
||||||
|
// * The CMS can reference the fields by name
|
||||||
|
// * Return users may have a previous "version" of the model, and we don't want
|
||||||
|
// them to have a breaking experience, because the model might have changed.
|
||||||
state: {
|
state: {
|
||||||
order: {
|
order: {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
|
|
@ -63,6 +68,8 @@ export default createStore({
|
||||||
experiments: null,
|
experiments: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// See IMPORTANT note at top of "state" declaration.
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
updateVehicleImage(state, data) {
|
updateVehicleImage(state, data) {
|
||||||
state.order.vehicle.imageSrc = data.imgSrc;
|
state.order.vehicle.imageSrc = data.imgSrc;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
@include blue-gradient;
|
@include blue-gradient;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: $border-radius-lg;
|
border-radius: $border-radius-lg;
|
||||||
height: 48px;
|
|
||||||
color: $white;
|
color: $white;
|
||||||
transition: all 150ms linear;
|
transition: all 150ms linear;
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
@ -33,7 +32,6 @@
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 1px solid $blue;
|
border: 1px solid $blue;
|
||||||
border-radius: $border-radius-lg;
|
border-radius: $border-radius-lg;
|
||||||
height: 48px;
|
|
||||||
color: $blue;
|
color: $blue;
|
||||||
transition: all 150ms linear;
|
transition: all 150ms linear;
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
@ -58,7 +56,6 @@
|
||||||
&.list-button {
|
&.list-button {
|
||||||
position: relative;
|
position: relative;
|
||||||
background: $white;
|
background: $white;
|
||||||
height: 48px;
|
|
||||||
transition: all 150ms linear;
|
transition: all 150ms linear;
|
||||||
border-radius: $border-radius-lg;
|
border-radius: $border-radius-lg;
|
||||||
border: 1px solid $gray-500;
|
border: 1px solid $gray-500;
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,13 @@
|
||||||
background: $blue-100;
|
background: $blue-100;
|
||||||
box-shadow: 0 0 0 1px $blue;
|
box-shadow: 0 0 0 1px $blue;
|
||||||
}
|
}
|
||||||
|
&:checked + label p:first-child {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
label {
|
label {
|
||||||
position: relative;
|
position: relative;
|
||||||
background: $white;
|
background: $white;
|
||||||
min-height: 3rem;
|
|
||||||
transition: all 150ms linear;
|
transition: all 150ms linear;
|
||||||
border-radius: $border-radius-lg;
|
border-radius: $border-radius-lg;
|
||||||
border: 1px solid $gray-500;
|
border: 1px solid $gray-500;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ h6,.h6 {
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
line-height: 1.625;
|
line-height: 1.5;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,4 +54,4 @@ caption {
|
||||||
font-size: 1rem !important;
|
font-size: 1rem !important;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,17 +136,18 @@ $border-radius-lg: .5rem;//Used for buttons. Can be used for other th
|
||||||
$border-radius-pill: 50rem;
|
$border-radius-pill: 50rem;
|
||||||
|
|
||||||
//Spacing
|
//Spacing
|
||||||
// Seven spacers available instead of the usual 5
|
// 8 spacers available instead of the usual 5
|
||||||
$spacer: 1rem;
|
$spacer: 1rem;
|
||||||
$spacers: (
|
$spacers: (
|
||||||
0: 0,
|
0: 0,
|
||||||
1: $spacer * .25,
|
1: $spacer * .25, /* 4px */
|
||||||
2: $spacer * .5,
|
2: $spacer * .5, /* 8px */
|
||||||
3: $spacer,
|
3: $spacer * .75, /* 12px */
|
||||||
4: $spacer * 1.5,
|
4: $spacer * 1, /* 16px */
|
||||||
5: $spacer * 2,
|
5: $spacer * 1.5, /* 24px */
|
||||||
6: $spacer * 2.5,
|
6: $spacer * 2, /* 32px */
|
||||||
7: $spacer * 3,
|
7: $spacer * 2.5, /* 40px */
|
||||||
|
8: $spacer * 3, /* 48px */
|
||||||
);
|
);
|
||||||
|
|
||||||
//Grid breakpoints
|
//Grid breakpoints
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
<button
|
<button
|
||||||
:disabled="isDisabled"
|
:disabled="isDisabled"
|
||||||
:aria-disabled="isDisabled"
|
:aria-disabled="isDisabled"
|
||||||
class="btn btn-primary d-flex align-items-center"
|
class="btn btn-primary d-flex align-items-center py-3 px-4"
|
||||||
@click='displayComponent'
|
@click='displayComponent'
|
||||||
>
|
>
|
||||||
{{ this.buttonText }}
|
<span class="m-0">{{ this.buttonText }}</span>
|
||||||
<loader
|
<loader
|
||||||
class="ms-2"
|
class="ms-2"
|
||||||
v-if="display"
|
v-if="display"
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
<button
|
<button
|
||||||
:disabled="isDisabled"
|
:disabled="isDisabled"
|
||||||
:aria-disabled="isDisabled"
|
:aria-disabled="isDisabled"
|
||||||
class="btn btn-secondary d-flex align-items-center"
|
class="btn btn-secondary d-flex align-items-center py-3 px-4"
|
||||||
@click='displayComponent'
|
@click='displayComponent'
|
||||||
>
|
>
|
||||||
{{ this.buttonText }}
|
<span class="m-0">{{ this.buttonText }}</span>
|
||||||
<loader
|
<loader
|
||||||
class="ms-2"
|
class="ms-2"
|
||||||
v-if="display"
|
v-if="display"
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="d-flex flex-column w-100">
|
<div class="d-flex flex-column w-100">
|
||||||
<button
|
<button
|
||||||
class="btn list-button d-flex align-items-center justify-content-between"
|
class="btn list-button d-flex align-items-center justify-content-between py-3 px-4"
|
||||||
@click='displayComponent'
|
@click='displayComponent'
|
||||||
v-bind:class="[
|
v-bind:class="[
|
||||||
this.isLoading ? 'button-loader' : 'not-loading',
|
this.isLoading ? 'button-loader' : 'not-loading',
|
||||||
this.isError ? 'error' : '',
|
this.isError ? 'error' : '',
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
{{ this.buttonText }}
|
<span class="m-0">{{ this.buttonText }}</span>
|
||||||
<loader
|
<loader
|
||||||
v-if="display"
|
v-if="display"
|
||||||
v-bind:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"
|
v-bind:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "loader",
|
name: "loader",
|
||||||
/* Specify size in number value which translates to rem value. For example, 1.5 = 1.5rem */
|
/* Specify size in number value which translates to rem value. For example, 1.5 = 1.5rem = 24px */
|
||||||
props: {
|
props: {
|
||||||
sizeInRem: {
|
sizeInRem: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|
@ -18,7 +18,7 @@ export default {
|
||||||
loaderColor: {
|
loaderColor: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
/* Position options: center, right, left (OPTIONAL) */
|
/* Position options: center, right, left (OPTIONAL, do NOT use on btn-* classes) */
|
||||||
loaderPosition: {
|
loaderPosition: {
|
||||||
type: String
|
type: String
|
||||||
}
|
}
|
||||||
|
|
@ -58,15 +58,16 @@ export default {
|
||||||
}
|
}
|
||||||
//Spinner position
|
//Spinner position
|
||||||
&.center {
|
&.center {
|
||||||
left: 0;
|
position: absolute;
|
||||||
right: 0;
|
right: 50%;
|
||||||
margin: 0 auto;
|
|
||||||
}
|
}
|
||||||
&.right {
|
&.right {
|
||||||
margin: 0 0 0 auto;
|
position: absolute;
|
||||||
|
right: 1rem;
|
||||||
}
|
}
|
||||||
&.left {
|
&.left {
|
||||||
margin: 0 auto 0 0;
|
position: absolute;
|
||||||
|
left: 1rem;
|
||||||
}
|
}
|
||||||
//Spinner color
|
//Spinner color
|
||||||
&:after { //Default spinner color (blue) if no other color is specified from the options below
|
&:after { //Default spinner color (blue) if no other color is specified from the options below
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
test.todo("some test to be written in the future");
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="radiogroup radio-list-button d-flex flex-column w-100">
|
|
||||||
<input type="radio"
|
|
||||||
v-bind:id="radioID"
|
|
||||||
v-bind:name="groupName"
|
|
||||||
v-bind:value="radioID">
|
|
||||||
<label role="radio" tabindex="0" aria-checked="false"
|
|
||||||
v-bind:for="radioID"
|
|
||||||
class="mb-2 d-flex align-items-center justify-content-between p-2"
|
|
||||||
@click='displayComponent'
|
|
||||||
>{{radioID}}
|
|
||||||
<loader
|
|
||||||
v-if="display"
|
|
||||||
v-bind:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"
|
|
||||||
v-bind:class="[this.loaderColor, this.loaderPosition]"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<p class="small">{{errorMessage}}</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import loader from "@/ux-components/loader/loader";
|
|
||||||
export default {
|
|
||||||
name: "radioList",
|
|
||||||
props: [
|
|
||||||
"groupName",
|
|
||||||
"ariaLabelBy",
|
|
||||||
"radioID",
|
|
||||||
"errorMessage",
|
|
||||||
"loaderColor",
|
|
||||||
"loaderPosition",
|
|
||||||
"sizeInRem"
|
|
||||||
|
|
||||||
],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
isError: false,
|
|
||||||
display: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
displayComponent() {
|
|
||||||
this.display = true;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
loader,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
@ -18,7 +18,7 @@ describe("radio.vue", () => {
|
||||||
// Assert
|
// Assert
|
||||||
const input = wrapper.find("input");
|
const input = wrapper.find("input");
|
||||||
const label = wrapper.find("label");
|
const label = wrapper.find("label");
|
||||||
const paragraph = wrapper.find("p");
|
const paragraph = wrapper.find("span");
|
||||||
|
|
||||||
await label.trigger('click');
|
await label.trigger('click');
|
||||||
|
|
||||||
|
|
@ -33,13 +33,13 @@ describe("radio.vue", () => {
|
||||||
role: "radio",
|
role: "radio",
|
||||||
tabindex: "0",
|
tabindex: "0",
|
||||||
for: "2023",
|
for: "2023",
|
||||||
class: "d-flex align-items-center justify-content-between p-2",
|
class: "d-flex flex-column justify-content-center py-3 px-4",
|
||||||
"aria-checked": "false"
|
"aria-checked": "false"
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(label.text()).toEqual('2023');
|
expect(label.text()).toEqual('2023');
|
||||||
|
|
||||||
expect(paragraph.text()).toEqual('null');
|
expect(paragraph.text()).toEqual('2023');
|
||||||
|
|
||||||
expect(wrapper.vm.display).toBe(true);
|
expect(wrapper.vm.display).toBe(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="radiogroup radio-list-button d-flex flex-column w-100">
|
<!-- See the component-test.vue page for example implementation -->
|
||||||
<input type="radio"
|
<!-- role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
|
||||||
:id="radioID"
|
<!-- Example: -->
|
||||||
:name="groupName"
|
<!-- <div role="radiogroup" aria-labelledby="demo-radio-group" class="col my-3 d-flex align-items-center flex-column"> -->
|
||||||
:value="radioID">
|
<!-- An h3 with id must be included just before the opening radio button group. ***The id must match the aria-labelledby of the parent div.*** -->
|
||||||
<label role="radio" tabindex="0" aria-checked="false"
|
<!-- Example -->
|
||||||
:for="radioID"
|
<!-- <h3 class="visually-hidden" id="demo-radio-group">Select Vehicle Year</h3> -->
|
||||||
class="d-flex align-items-center justify-content-between p-2"
|
<div class="radiogroup radio-list-button d-flex flex-column w-100 mb-2">
|
||||||
@click='displayComponent'
|
<input type="radio" :id="radioID" :name="groupName" :value="radioID">
|
||||||
>{{radioID}}
|
<label role="radio" tabindex="0" aria-checked="false" :for="radioID" class="d-flex flex-column justify-content-center py-3 px-4" @click='displayComponent'>
|
||||||
<loader
|
<span class="m-0" :class="[this.textPosition]">{{radioID}}</span>
|
||||||
v-if="display"
|
<span class="m-0 small" :class="[this.textPosition]">{{radioLabelSubCopy}}</span>
|
||||||
:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"
|
<loader v-if="display" :style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}" :class="[this.loaderColor, this.loaderPosition]" />
|
||||||
:class="[this.loaderColor, this.loaderPosition]"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
<p class="small">{{errorMessage}}</p>
|
<p class="small">{{errorMessage}}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -24,12 +22,14 @@ import loader from "@/ux-components/loader/loader";
|
||||||
export default {
|
export default {
|
||||||
name: "radioList",
|
name: "radioList",
|
||||||
props: [
|
props: [
|
||||||
"groupName",
|
"groupName", /* Required, unique for each radio button GROUP */
|
||||||
"radioID",
|
"radioID", /* Required, unique for each radio button. Used for button id, label and <label for> */
|
||||||
"errorMessage",
|
"radioLabelSubCopy", /* Optional, used for multi-line radio buttons */
|
||||||
"loaderColor",
|
"textPosition", /* Optional, use Bootstrap classes: text-start, text-center, text-end. Default (empty) is text-start */
|
||||||
"loaderPosition",
|
"errorMessage", /* Optional */
|
||||||
"sizeInRem"
|
"loaderColor", /* Optional */
|
||||||
|
"loaderPosition", /* Optional */
|
||||||
|
"sizeInRem" /* Optional */
|
||||||
],
|
],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue