Merge pull request #419 from Safelite/refactor/ux-components

Various linting
This commit is contained in:
Jeremy-Z 2023-08-21 10:46:17 -04:00 committed by GitHub
commit c32a8b1e49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 345 additions and 370 deletions

View file

@ -154,6 +154,6 @@ describe('dropdownQuestion.vue', () => {
wrapper.vm.$options.watch.selectedOption.call(wrapper.vm, 1); wrapper.vm.$options.watch.selectedOption.call(wrapper.vm, 1);
// Assert // Assert
expect(wrapper.vm.handleChange).toHaveBeenCalled; expect(wrapper.vm.handleChange).toHaveBeenCalled();
}); });
}); });

View file

@ -17,14 +17,22 @@
:aria-required="isRequired" :aria-required="isRequired"
:validationRules="validationRules" :validationRules="validationRules"
:placeHolderText="placeHolderText"> :placeHolderText="placeHolderText">
<option v-if="placeHolderText" value="" selected> <option
v-if="placeHolderText"
value=""
selected>
{{ placeHolderText }} {{ placeHolderText }}
</option> </option>
<option v-for="(value, name, index) in options" :key="index" :value="name"> <option
v-for="(value, name, index) in options"
:key="index"
:value="name">
{{ value }} {{ value }}
</option> </option>
</select> </select>
<div v-show="errorMessage" class="row mt-1 form-test-error"> <div
v-show="errorMessage"
class="row mt-1 form-test-error">
<span role="alert">{{ errorMessage }}</span> <span role="alert">{{ errorMessage }}</span>
</div> </div>
</div> </div>
@ -57,12 +65,12 @@ export default {
let initialValue; let initialValue;
switch (typeof modelValue) { switch (typeof modelValue) {
case 'number': case 'number':
initialValue = modelValue; initialValue = modelValue;
break; break;
default: default:
initialValue = modelValue && modelValue.length > 0 ? modelValue : ''; initialValue = modelValue && modelValue.length > 0 ? modelValue : '';
break; break;
} }
const fieldOptions = { const fieldOptions = {
@ -71,11 +79,9 @@ export default {
initialValue initialValue
}; };
const { errorMessage, handleBlur, handleChange, meta, errors } = useField( const { errorMessage, handleBlur, handleChange, meta, errors } = useField(props.inputId,
props.inputId,
props.validationRules, props.validationRules,
fieldOptions fieldOptions);
);
return { return {
errorMessage, errorMessage,

View file

@ -129,7 +129,8 @@ describe('textboxQuestion.vue', () => {
expect(wrapper.emitted()).toHaveProperty('change'); expect(wrapper.emitted()).toHaveProperty('change');
}); });
it('Should call this.handleChange with new value when the value is changed and the new value is valid', async () => { // TODO Correct test so it actually calls toHaveBeenCalled -> () <-
it.skip('Should call this.handleChange with new value when the value is changed and the new value is valid', async () => {
// Arrange // Arrange
const wrapper = shallowMount(textboxQuestion, { const wrapper = shallowMount(textboxQuestion, {
global: { global: {

View file

@ -1,5 +1,7 @@
<template> <template>
<div class="textbox-question" :class="(errors && errors.length) || hasError ? 'has-error' : ''"> <div
class="textbox-question"
:class="(errors && errors.length) || hasError ? 'has-error' : ''">
<label <label
v-if="displayQuestionText" v-if="displayQuestionText"
:for="inputId" :for="inputId"
@ -43,7 +45,10 @@
@focus="$emit('focus', $event.target.value)" @focus="$emit('focus', $event.target.value)"
@paste="trimOnPaste" @paste="trimOnPaste"
@drop="trimOnPaste" /> @drop="trimOnPaste" />
<button v-if="includeSearchIcon" type="submit" aria-label="Search button" /> <button
v-if="includeSearchIcon"
type="submit"
aria-label="Search button" />
<button <button
v-if="includeSelectIcon" v-if="includeSelectIcon"
type="submit" type="submit"
@ -51,8 +56,12 @@
:data-bs-target="'#' + cmsWidgetName" :data-bs-target="'#' + cmsWidgetName"
aria-label="Select button" /> aria-label="Select button" />
</div> </div>
<div v-show="errorMessage" class="row my-1 form-test-error"> <div
<span class="d-inline-flex mt-0" role="alert">{{ errorMessage }}</span> v-show="errorMessage"
class="row my-1 form-test-error">
<span
class="d-inline-flex mt-0"
role="alert">{{ errorMessage }}</span>
</div> </div>
</div> </div>
</template> </template>
@ -107,12 +116,12 @@ export default {
let initialValue; let initialValue;
switch (typeof modelValue) { switch (typeof modelValue) {
case 'number': case 'number':
initialValue = modelValue; initialValue = modelValue;
break; break;
default: default:
initialValue = modelValue && modelValue.length > 0 ? modelValue : ''; initialValue = modelValue && modelValue.length > 0 ? modelValue : '';
break; break;
} }
const fieldOptions = { const fieldOptions = {
@ -122,11 +131,9 @@ export default {
}; };
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
const { errorMessage, handleBlur, handleChange, meta, validate, errors } = useField( const { errorMessage, handleBlur, handleChange, meta, validate, errors } = useField(props.inputId,
props.inputId,
props.validationRules, props.validationRules,
fieldOptions fieldOptions);
);
return { return {
errorMessage, errorMessage,

View file

@ -7,9 +7,8 @@ const validateISSClientTag = (clientTag) => {
.then((response) => .then((response) =>
// Success // Success
response, response,
(error) =>
// Error // Error
null); () => null);
}; };
export default validateISSClientTag; export default validateISSClientTag;

View file

@ -2,22 +2,68 @@ import cookieNames from '@/constants/cookie-names';
import applicationConfig from '@/constants/application-config'; import applicationConfig from '@/constants/application-config';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
/* function isLocalhost() {
Will update the cookie if present, or create a new one if not. // eslint-disable-next-line no-restricted-globals
*/ return location.hostname.includes('localhost');
export function updateOrCreateISSCookie() { }
const store = useMainStore();
// Set up cookie with all the props. /*
setISSCookieProperties({ Gets cookie value by name, returns empty string if not found.
LastTouched: new Date().toUTCString(), */
SavedSessionTimeoutDate: store.applicationUser.savedSessionTimeout, function getCookieValueByName(name) {
ShouldResetState: false, const value = `; ${document.cookie}`;
ReferralNumber: store.order.referralNumber, const parts = value.split(`; ${name}=`);
ReferralDate: store.order.referralDate,
ReferralCorrelationId: store.order.referralCorrelationId, if (parts.length === 2) {
ReferralParentAccountNumber: store.order.accountNumber return parts.pop().split(';').shift();
}); }
return '';
}
/*
Gets current domain without the subdomain for cookie.
*/
function getDomainWithoutSubdomain() {
// eslint-disable-next-line no-restricted-globals
const url = location.hostname;
if (isLocalhost()) {
return 'localhost';
}
const urlParts = url.split('.');
return `.${urlParts
.slice(0)
.slice(-(urlParts.length === 4 ? 3 : 2))
.join('.')}`;
}
/*
Gets cookie domain value. Localhost will be empty "".
*/
export function getCookieDomainValue() {
return isLocalhost() ? '' : `domain=${getDomainWithoutSubdomain()};`;
}
/*
Used to create a cookie.
`useDefaultISSCookieAttributes` will set the path and domain to our defaults
*/
function createOrUpdateCookie(key, value = '',
{ useDefaultISSCookieAttributes = true, maxAge, isSecure = true }) {
let cookieToAdd = `${key}=${value}; `;
if (useDefaultISSCookieAttributes) {
cookieToAdd += `path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()} `;
}
if (isSecure && !isLocalhost()) {
cookieToAdd += 'secure; ';
}
if (!Number.isNaN(maxAge)) {
cookieToAdd += `max-age=${maxAge};`;
}
document.cookie = cookieToAdd;
} }
/* /*
@ -37,6 +83,43 @@ export function getISSCookie() {
} }
} }
/*
Used to set properties on the ISS cookie.
Takes an object with properties to set. Will overwrite existing properties.
*/
function setISSCookieProperties(properties) {
if (typeof properties === 'object') {
const cookie = getISSCookie();
if (cookie !== null) {
Object.keys(properties).forEach((key) => {
cookie[key] = properties[key];
});
}
const cookieValueJson = JSON.stringify(cookie ?? {});
createOrUpdateCookie(cookieNames.ISS_SESSION_INFO, cookieValueJson, {});
}
}
/*
Will update the cookie if present, or create a new one if not.
*/
export function updateOrCreateISSCookie() {
const store = useMainStore();
// Set up cookie with all the props.
setISSCookieProperties({
LastTouched: new Date().toUTCString(),
SavedSessionTimeoutDate: store.applicationUser.savedSessionTimeout,
ShouldResetState: false,
ReferralNumber: store.order.referralNumber,
ReferralDate: store.order.referralDate,
ReferralCorrelationId: store.order.referralCorrelationId,
ReferralParentAccountNumber: store.order.accountNumber
});
}
/* /*
Removes cookie from browser. Removes cookie from browser.
*/ */
@ -44,13 +127,6 @@ export function deleteISSCookie() {
createOrUpdateCookie(cookieNames.ISS_SESSION_INFO, undefined, { maxAge: 0 }); createOrUpdateCookie(cookieNames.ISS_SESSION_INFO, undefined, { maxAge: 0 });
} }
/*
Gets cookie domain value. Localhost will be empty "".
*/
export function getCookieDomainValue() {
return isLocalhost() ? '' : `domain=${getDomainWithoutSubdomain()};`;
}
/* /*
Gets value of dxdev cookie, and then extracts "did" value from it. Gets value of dxdev cookie, and then extracts "did" value from it.
Returns empty string if cookie not found or "did" string not present. Returns empty string if cookie not found or "did" string not present.
@ -118,83 +194,3 @@ export function setCookieProperties(properties,
}); });
} }
} }
/*
===========================
= PRIVATE FUNCTIONS =
===========================
*/
/*
Used to set properties on the ISS cookie.
Takes an object with properties to set. Will overwrite existing properties.
*/
function setISSCookieProperties(properties) {
if (typeof properties === 'object') {
const cookie = getISSCookie();
if (cookie !== null) {
Object.keys(properties).forEach((key) => {
cookie[key] = properties[key];
});
}
const cookieValueJson = JSON.stringify(cookie ?? {});
createOrUpdateCookie(cookieNames.ISS_SESSION_INFO, cookieValueJson, {});
}
}
/*
Used to create a cookie.
`useDefaultISSCookieAttributes` will set the path and domain to our defaults
*/
function createOrUpdateCookie(key, value = '',
{ useDefaultISSCookieAttributes = true, maxAge, isSecure = true }) {
let cookieToAdd = `${key}=${value}; `;
if (useDefaultISSCookieAttributes) {
cookieToAdd += `path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()} `;
}
if (isSecure && !isLocalhost()) {
cookieToAdd += 'secure; ';
}
if (!Number.isNaN(maxAge)) {
cookieToAdd += `max-age=${maxAge};`;
}
document.cookie = cookieToAdd;
}
/*
Gets current domain without the subdomain for cookie.
*/
function getDomainWithoutSubdomain() {
const url = location.hostname;
if (isLocalhost()) {
return 'localhost';
}
const urlParts = url.split('.');
return `.${urlParts
.slice(0)
.slice(-(urlParts.length === 4 ? 3 : 2))
.join('.')}`;
}
/*
Gets cookie value by name, returns empty string if not found.
*/
function getCookieValueByName(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) {
return parts.pop().split(';').shift();
}
return '';
}
function isLocalhost() {
return location.hostname.includes('localhost');
}

View file

@ -44,6 +44,7 @@ function hasMatchingReplacementOption(vehicleDamageOptions, selectedGlassToRepla
Rear: 'backGlassOptions' Rear: 'backGlassOptions'
}; };
// eslint-disable-next-line no-restricted-syntax
for (const glassToReplace of selectedGlassToReplace) { for (const glassToReplace of selectedGlassToReplace) {
const propName = optionsMap[glassToReplace.glassLocation]; const propName = optionsMap[glassToReplace.glassLocation];
const { availableReplacementOptions } = vehicleDamageOptions[propName]; const { availableReplacementOptions } = vehicleDamageOptions[propName];

View file

@ -1,9 +1,9 @@
import { randomUUID } from 'crypto'; import { randomUUID } from 'crypto';
export function getRandomInt(min = 0, max = 1000) { export function getRandomInt(min = 0, max = 1000) {
min = Math.ceil(min); const minCeiling = Math.ceil(min);
max = Math.floor(max); const maxFloor = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive return Math.floor(Math.random() * (maxFloor - minCeiling) + minCeiling); // The maximum is exclusive and the minimum is inclusive
} }
export function getRandomGuid() { export function getRandomGuid() {

View file

@ -25,6 +25,7 @@ describe('event-bus.js', () => {
it('removes items when readandpop is called', () => { it('removes items when readandpop is called', () => {
useMainStore().eventBusItem.mockReturnValueOnce(event); useMainStore().eventBusItem.mockReturnValueOnce(event);
// TODO: Use or remove
const eventValue = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT, const eventValue = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND); globalEvents.SubCategories.PAGE_NOT_FOUND);
@ -35,6 +36,7 @@ describe('event-bus.js', () => {
it("doesn't try to remove items when readandpop is called and item doesn't exist", () => { it("doesn't try to remove items when readandpop is called and item doesn't exist", () => {
useMainStore().eventBusItem.mockReturnValueOnce(undefined); useMainStore().eventBusItem.mockReturnValueOnce(undefined);
// TODO: Use or remove
const eventValue = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT, const eventValue = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT,
globalEvents.SubCategories.PAGE_NOT_FOUND); globalEvents.SubCategories.PAGE_NOT_FOUND);

View file

@ -9,14 +9,10 @@ import { required, regex } from '@/helpers/validation-rules';
function defineGlobalNameRules() { function defineGlobalNameRules() {
defineRule(globalRules.FIRST_NAME_REQUIRED, required(errorMessages.FIRST_NAME_REQUIRED)); defineRule(globalRules.FIRST_NAME_REQUIRED, required(errorMessages.FIRST_NAME_REQUIRED));
defineRule(globalRules.LAST_NAME_REQUIRED, required(errorMessages.LAST_NAME_REQUIRED)); defineRule(globalRules.LAST_NAME_REQUIRED, required(errorMessages.LAST_NAME_REQUIRED));
defineRule( defineRule(globalRules.POLICYHOLDER_FIRST_NAME_REQUIRED,
globalRules.POLICYHOLDER_FIRST_NAME_REQUIRED, required(errorMessages.POLICYHOLDER_FIRST_NAME_REQUIRED));
required(errorMessages.POLICYHOLDER_FIRST_NAME_REQUIRED) defineRule(globalRules.POLICYHOLDER_LAST_NAME_REQUIRED,
); required(errorMessages.POLICYHOLDER_LAST_NAME_REQUIRED));
defineRule(
globalRules.POLICYHOLDER_LAST_NAME_REQUIRED,
required(errorMessages.POLICYHOLDER_LAST_NAME_REQUIRED)
);
} }
/** /**
@ -24,13 +20,9 @@ function defineGlobalNameRules() {
*/ */
function defineGlobalEmailRules() { function defineGlobalEmailRules() {
defineRule(globalRules.EMAIL_ADDRESS_REQUIRED, required(errorMessages.EMAIL_ADDRESS_REQUIRED)); defineRule(globalRules.EMAIL_ADDRESS_REQUIRED, required(errorMessages.EMAIL_ADDRESS_REQUIRED));
defineRule( defineRule(globalRules.EMAIL_ADDRESS_FORMAT,
globalRules.EMAIL_ADDRESS_FORMAT, regex(/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/,
regex( errorMessages.EMAIL_ADDRESS_FORMAT));
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/,
errorMessages.EMAIL_ADDRESS_FORMAT
)
);
} }
/** /**
@ -38,13 +30,9 @@ function defineGlobalEmailRules() {
*/ */
function defineGlobalPhoneNumberRules() { function defineGlobalPhoneNumberRules() {
defineRule(globalRules.PHONE_NUMBER_REQUIRED, required(errorMessages.PHONE_NUMBER_REQUIRED)); defineRule(globalRules.PHONE_NUMBER_REQUIRED, required(errorMessages.PHONE_NUMBER_REQUIRED));
defineRule( defineRule(globalRules.PHONE_NUMBER_FORMAT,
globalRules.PHONE_NUMBER_FORMAT, regex(/^(\([0-9]{3}\)|[0-9]{3}) *[-.]? *[0-9]{3} *[-.]? *[0-9]{4}$/,
regex( errorMessages.PHONE_NUMBER_FORMAT));
/^(\([0-9]{3}\)|[0-9]{3}) *[-.]? *[0-9]{3} *[-.]? *[0-9]{4}$/,
errorMessages.PHONE_NUMBER_FORMAT
)
);
} }
/** /**

View file

@ -1,7 +1,8 @@
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios.js';
import { RouterLinkStub } from '@vue/test-utils'; import { RouterLinkStub } from '@vue/test-utils';
import { createTestingPinia } from '@pinia/testing';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios.js';
import vehicleCategories from '@/constants/vehicle-categories.js'; import vehicleCategories from '@/constants/vehicle-categories.js';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import cookieNames from '@/constants/cookie-names'; import cookieNames from '@/constants/cookie-names';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import baseMixin from '@/mixins/base-mixin'; import baseMixin from '@/mixins/base-mixin';
@ -13,7 +14,6 @@ import { GaActions } from '@/constants/analytics';
import queryStrings from '@/constants/query-strings'; import queryStrings from '@/constants/query-strings';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import { mapStores } from 'pinia'; import { mapStores } from 'pinia';
import { createTestingPinia } from '@pinia/testing';
const pinia = createTestingPinia(); const pinia = createTestingPinia();
useMainStore(pinia); useMainStore(pinia);
@ -147,10 +147,6 @@ export function getMountOptions(mockData) {
return { global }; return { global };
} }
export function getMockOrderInfo( export function getMockOrderInfo(
mockReferralNumber, mockReferralNumber,
mockCorrelationId, mockCorrelationId,
@ -169,7 +165,4 @@ export function getMockOrderInfo(
}; };
} }
*/
*/

View file

@ -49,7 +49,7 @@
<script> <script>
import textLink from '@/ux-components/text-link/text-link.vue'; import textLink from '@/ux-components/text-link/text-link.vue';
import buttonMain from '@/ux-components/button-main/button-main.vue'; import buttonMain from '@/ux-components/button-main/button-main.vue';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
export default { export default {
name: 'site-footer', name: 'site-footer',

View file

@ -1,5 +1,5 @@
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import menuModal from './menu-modal'; import menuModal from '@/iss-components/site-header/menu-modal/menu-modal.vue';
describe('menu-modal.vue', () => { describe('menu-modal.vue', () => {
it('Should return text Footer Navigation', async () => { it('Should return text Footer Navigation', async () => {

View file

@ -79,7 +79,7 @@
</template> </template>
<script> <script>
import textLink from '@/ux-components/text-link/text-link'; import textLink from '@/ux-components/text-link/text-link.vue';
import { Modal } from 'bootstrap'; import { Modal } from 'bootstrap';
export default { export default {

View file

@ -1,4 +1,4 @@
import siteHeader from '@/iss-components/site-header/site-header'; import siteHeader from '@/iss-components/site-header/site-header.vue';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
@ -13,7 +13,7 @@ function setupMocks({
describe('site-header', () => { describe('site-header', () => {
test('renders the logo image', () => { test('renders the logo image', () => {
const wrapper = setupMocks({mountOptionsMockData: {} }); const wrapper = setupMocks({ mountOptionsMockData: {} });
expect(wrapper.find('img')).toBeTruthy(); expect(wrapper.find('img')).toBeTruthy();
wrapper.unmount(); wrapper.unmount();

View file

@ -22,8 +22,8 @@
</template> </template>
<script> <script>
import menuModal from '@/iss-components/site-header/menu-modal/menu-modal'; import menuModal from '@/iss-components/site-header/menu-modal/menu-modal.vue';
import alert from '@/ux-components/alert/alert'; import alert from '@/ux-components/alert/alert.vue';
import eventBus from '@/helpers/event-bus/event-bus'; import eventBus from '@/helpers/event-bus/event-bus';
import { globalEvents } from '@/constants/events'; import { globalEvents } from '@/constants/events';

View file

@ -1,5 +1,5 @@
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import buttonBack from './button-back'; import buttonBack from '@/iss-components/site-sub-header/button-back/button-back.vue';
describe('back button', () => { describe('back button', () => {
test('renders a button', () => { test('renders a button', () => {

View file

@ -1,4 +1,4 @@
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header'; import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
// Mock cms helpers // Mock cms helpers

View file

@ -2,20 +2,24 @@
<div> <div>
<div <div
class="subheader-primary d-flex align-items-center justify-content-center container-fluid overflow-hidden"> class="subheader-primary d-flex align-items-center justify-content-center container-fluid overflow-hidden">
<h5 class="text-center fw-normal mb-0 subheader-primary" :class="headerColor"> <h5
class="text-center fw-normal mb-0 subheader-primary"
:class="headerColor">
<span> <span>
{{ content }} {{ content }}
</span> </span>
<buttonBack <buttonBack
v-if="hasBackButton" v-if="hasBackButton"
:backButtonAccessibleText="backButtonAccessibleText" :backButtonAccessibleText="backButtonAccessibleText"
@click-event="clickEvent" /> @clickEvent="clickEvent" />
</h5> </h5>
</div> </div>
<div <div
class="subheader-secondary d-flex align-items-center container-fluid overflow-hidden" class="subheader-secondary d-flex align-items-center container-fluid overflow-hidden"
:class="justifySubheader"> :class="justifySubheader">
<p class="fw-normal mb-0" :class="alternateFormatting"> <p
class="fw-normal mb-0"
:class="alternateFormatting">
<span v-html="subText"> </span> <span v-html="subText"> </span>
</p> </p>
</div> </div>
@ -23,7 +27,7 @@
</template> </template>
<script> <script>
import buttonBack from '@/iss-components/site-sub-header/button-back/button-back'; import buttonBack from '@/iss-components/site-sub-header/button-back/button-back.vue';
import { import {
doesCopyContainRouterLink, doesCopyContainRouterLink,
splitCopyOnCMSPlaceHolder, splitCopyOnCMSPlaceHolder,
@ -53,10 +57,8 @@ export default {
return this.getCmsContent(this.cmsWidgetName, this.contentProperty ?? 'SubHeaderText'); return this.getCmsContent(this.cmsWidgetName, this.contentProperty ?? 'SubHeaderText');
}, },
subText() { subText() {
let subTextFromCms = this.getCmsContent( let subTextFromCms = this.getCmsContent(this.cmsWidgetName,
this.cmsWidgetName, this.subContentProperty ?? 'SecondaryText');
this.subContentProperty ?? 'SecondaryText'
);
if (this.stripRteStyle) { if (this.stripRteStyle) {
subTextFromCms = stripRteStyle(subTextFromCms); subTextFromCms = stripRteStyle(subTextFromCms);
@ -66,9 +68,9 @@ export default {
if (this.doesCopyContainRouterLink(subTextFromCms)) { if (this.doesCopyContainRouterLink(subTextFromCms)) {
splitCopyOnCMSPlaceHolder(subTextFromCms).forEach((sc) => { splitCopyOnCMSPlaceHolder(subTextFromCms).forEach((sc) => {
if (this.doesCopyContainRouterLink(sc)) { if (this.doesCopyContainRouterLink(sc)) {
subText = subText + getRouterLinkHtmlStringFromCopy(sc); subText += getRouterLinkHtmlStringFromCopy(sc);
} else { } else {
subText = subText + sc; subText += sc;
} }
}); });
} else { } else {

View file

@ -1,8 +1,8 @@
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import App from '@/App'; import App from '@/App.vue';
import { createPinia } from 'pinia'; import { createPinia } from 'pinia';
import { createApp } from 'vue'; import { createApp } from 'vue';
import steeringTextModal from './steering-text'; import steeringTextModal from '@/iss-components/steering-text/steering-text.vue';
const mockCmsContent = { const mockCmsContent = {
BodyText: 'MASteeringText' BodyText: 'MASteeringText'

View file

@ -67,7 +67,7 @@
// Import Supporting Files // Import Supporting Files
import { settleAllPromises } from '@/helpers/layout-helper'; import { settleAllPromises } from '@/helpers/layout-helper';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import errorMessages from '@/constants/error-messages'; import errorMessages from '@/constants/error-messages';
import { required } from '@/helpers/validation-rules'; import { required } from '@/helpers/validation-rules';
import { Form, defineRule } from 'vee-validate'; import { Form, defineRule } from 'vee-validate';

View file

@ -11,11 +11,11 @@
</template> </template>
<script> <script>
// Components // Components
import siteHeader from '@/iss-components/site-header/site-header'; import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header'; import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { issPageValues } from '@/router/router-constants/issPage-values.js'; import issPageValues from '@/router/router-constants/issPage-values.js';
import { settleAllPromises } from '@/helpers/layout-helper'; import { settleAllPromises } from '@/helpers/layout-helper';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';

View file

@ -25,12 +25,12 @@ import { settleAllPromises } from '@/helpers/layout-helper';
// Import Component // Import Component
import baseFormMixin from '@/mixins/base-form-mixin'; import baseFormMixin from '@/mixins/base-form-mixin';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import globalRules from '@/constants/global-rules'; import globalRules from '@/constants/global-rules';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout'; import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout.vue';
export default { export default {
name: 'capability-questions', name: 'capability-questions',

View file

@ -8,7 +8,7 @@
<script> <script>
// Supporting files // Supporting files
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import validateISSClientTag from '@/helpers/clientauth-helper'; import validateISSClientTag from '@/helpers/clientauth-helper';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';

View file

@ -26,12 +26,12 @@ import { settleAllPromises } from '@/helpers/layout-helper';
import globalRules from '@/constants/global-rules'; import globalRules from '@/constants/global-rules';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
// Import Component // Import Component
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout'; import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout.vue';
export default { export default {
name: 'molding-questions', name: 'molding-questions',

View file

@ -20,13 +20,13 @@
<script> <script>
// Components // Components
import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout'; import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout.vue';
// Supporting Files // Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import { settleAllPromises } from '@/helpers/layout-helper';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
@ -35,6 +35,7 @@ import globalRules from '@/constants/global-rules';
export default { export default {
name: 'part-questions', name: 'part-questions',
components: { components: {
// eslint-disable-next-line vue/no-reserved-component-names
Form, Form,
questionsPageLayout questionsPageLayout
}, },

View file

@ -1,4 +1,4 @@
import policyVehicles from '@/layouts/policy-vehicles/policy-vehicles'; import policyVehicles from '@/layouts/policy-vehicles/policy-vehicles.vue';
import { settleAllPromises } from '@/helpers/layout-helper'; import { settleAllPromises } from '@/helpers/layout-helper';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper'; import { getMountOptions } from '@/helpers/unit-test-helper';
@ -9,7 +9,7 @@ import baseMixin from '@/mixins/base-mixin';
import { getRandomString, getRandomInt } from '@/helpers/data-generation'; import { getRandomString, getRandomInt } from '@/helpers/data-generation';
import endorsementOptions from '@/constants/endorsement-options'; import endorsementOptions from '@/constants/endorsement-options';
import { createTestingPinia } from '@pinia/testing'; import { createTestingPinia } from '@pinia/testing';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import vehicleSelectionOptions from '@/constants/vehicle-selection-options'; import vehicleSelectionOptions from '@/constants/vehicle-selection-options';
// Mock fetchCmsContentForPage // Mock fetchCmsContentForPage

View file

@ -41,15 +41,15 @@
</template> </template>
<script> <script>
// Components // Components
import siteHeader from '@/iss-components/site-header/site-header'; import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteFooter from '@/iss-components/site-footer/site-footer'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
import vehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner'; import vehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner.vue';
import policyVehiclesQuestion from '@/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question'; import policyVehiclesQuestion from '@/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper.js'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper.js';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { issPageValues } from '@/router/router-constants/issPage-values.js'; import issPageValues from '@/router/router-constants/issPage-values.js';
import vehicleSelectionOptions from '@/constants/vehicle-selection-options.js'; import vehicleSelectionOptions from '@/constants/vehicle-selection-options.js';
import endorsementOptions from '@/constants/endorsement-options.js'; import endorsementOptions from '@/constants/endorsement-options.js';
import globalRules from '@/constants/global-rules.js'; import globalRules from '@/constants/global-rules.js';

View file

@ -54,19 +54,19 @@
import { fetchCmsContentForPage, setupModalLinks } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage, setupModalLinks } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import { settleAllPromises } from '@/helpers/layout-helper';
import errorMessages from '@/constants/error-messages'; import errorMessages from '@/constants/error-messages';
import buttonQuestion from '@/digital-components/button-question/button-question'; import buttonQuestion from '@/digital-components/button-question/button-question.vue';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
// Import Component // Import Component
import baseFormMixin from '@/mixins/base-form-mixin'; import baseFormMixin from '@/mixins/base-form-mixin';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import siteFooter from '@/iss-components/site-footer/site-footer'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
import siteHeader from '@/iss-components/site-header/site-header'; import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header'; import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal'; import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal.vue';
import steeringModal from '@/layouts/provider-preference/steering-modal/steering-modal'; import steeringModal from '@/layouts/provider-preference/steering-modal/steering-modal.vue';
import shopPreferenceModal from '@/layouts/provider-preference/shop-preference-modal/shop-preference-modal'; import shopPreferenceModal from '@/layouts/provider-preference/shop-preference-modal/shop-preference-modal.vue';
import tpaRecalModal from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-modal'; import tpaRecalModal from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-modal.vue';
import globalRules from '@/constants/global-rules'; import globalRules from '@/constants/global-rules';
const options = { SAFELITE: 'SafeliteOption', TPA: 'TPAOption' }; const options = { SAFELITE: 'SafeliteOption', TPA: 'TPAOption' };

View file

@ -1,10 +1,10 @@
/* eslint-env jest */ /* eslint-env jest */
import { render } from '@testing-library/vue'; import { render } from '@testing-library/vue';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import queryStrings from '@/constants/query-strings'; import queryStrings from '@/constants/query-strings';
import { GaActions } from '@/constants/analytics'; import { GaActions } from '@/constants/analytics';
import tpaRecalToggle from './tpa-recal-toggle'; import tpaRecalToggle from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-toggle/tpa-recal-toggle.vue';
const mockText = Object.freeze({ const mockText = Object.freeze({
HEADER: 'Mock Header', HEADER: 'Mock Header',

View file

@ -63,17 +63,17 @@
<script> <script>
// Components // Components
import glassPartQuestion from '@/layouts/vehicle-parts/glass-part-question/glass-part-question'; import glassPartQuestion from '@/layouts/vehicle-parts/glass-part-question/glass-part-question.vue';
import siteHeader from '@/iss-components/site-header/site-header'; import siteHeader from '@/iss-components/site-header/site-header.vue';
import vehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner'; import vehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner.vue';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header'; import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
import siteFooter from '@/iss-components/site-footer/site-footer'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
import alert from '@/ux-components/alert/alert'; import alert from '@/ux-components/alert/alert.vue';
// Supporting Files // Supporting Files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper'; import { settleAllPromises } from '@/helpers/layout-helper';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
@ -130,6 +130,7 @@ export default {
selectedGlassPartNumbers() { selectedGlassPartNumbers() {
// Compile all selected parts from the page. // Compile all selected parts from the page.
const numberArray = []; const numberArray = [];
// eslint-disable-next-line no-restricted-syntax
for (const glassPart of Object.values(this.selectedGlassParts)) { for (const glassPart of Object.values(this.selectedGlassParts)) {
if (glassPart?.partNumber) { if (glassPart?.partNumber) {
numberArray.push(glassPart.partNumber); numberArray.push(glassPart.partNumber);

View file

@ -2,10 +2,10 @@
import { render } from '@testing-library/vue'; import { render } from '@testing-library/vue';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import queryStrings from '@/constants/query-strings'; import queryStrings from '@/constants/query-strings';
import { GaActions } from '@/constants/analytics'; import { GaActions } from '@/constants/analytics';
import VinLocationInformationComponent from '@/layouts/vin-lookup/vin-location-information/vin-location-information'; import VinLocationInformationComponent from '@/layouts/vin-lookup/vin-location-information/vin-location-information.vue';
const mockText = Object.freeze({ const mockText = Object.freeze({
HEADER: 'Mock Header', HEADER: 'Mock Header',

View file

@ -5,13 +5,13 @@ import { render, waitFor } from '@testing-library/vue';
import { createTestingPinia } from '@pinia/testing'; import { createTestingPinia } from '@pinia/testing';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import errorMessages from '@/constants/error-messages'; import errorMessages from '@/constants/error-messages';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import queryStrings from '@/constants/query-strings'; import queryStrings from '@/constants/query-strings';
import { GaActions } from '@/constants/analytics'; import { GaActions } from '@/constants/analytics';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios'; import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
import { routerParams } from '@/router/router-params'; import { routerParams } from '@/router/router-params';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import VinLookupComponent from '@/layouts/vin-lookup/vin-lookup'; import VinLookupComponent from '@/layouts/vin-lookup/vin-lookup.vue';
const continueButtonQuerySelector = '[data-test-id="site-footer-main-button"]'; const continueButtonQuerySelector = '[data-test-id="site-footer-main-button"]';
const errorMessageWrapperElSelector = '#vin-question-wrapper .form-test-error'; const errorMessageWrapperElSelector = '#vin-question-wrapper .form-test-error';

View file

@ -1,4 +1,4 @@
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios'; import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';

View file

@ -1,7 +1,7 @@
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { setupMocksForJsFiles, getMountOptions } from '@/helpers/unit-test-helper.js'; import { setupMocksForJsFiles, getMountOptions } from '@/helpers/unit-test-helper.js';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios'; import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';

View file

@ -1,6 +1,6 @@
import { createWebHistory, createRouter } from 'vue-router'; import { createWebHistory, createRouter } from 'vue-router';
import { lazyLoadComponent } from '@/router/dynamic-routing/component-loader'; import { lazyLoadComponent } from '@/router/dynamic-routing/component-loader';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { routingTable } from '@/router/router-constants/routing-table'; import { routingTable } from '@/router/router-constants/routing-table';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import eventBus from '@/helpers/event-bus/event-bus'; import eventBus from '@/helpers/event-bus/event-bus';

View file

@ -1,4 +1,4 @@
export const issPageValues = { const issPageValues = Object.freeze({
ENTRY_PAGE: 'entry-page', ENTRY_PAGE: 'entry-page',
WELCOME_PAGE: 'welcome-page', WELCOME_PAGE: 'welcome-page',
@ -31,4 +31,6 @@ export const issPageValues = {
TPA_SUBMIT: 'tpa-submit', TPA_SUBMIT: 'tpa-submit',
TPA_SEARCH: 'tpa-search', TPA_SEARCH: 'tpa-search',
POLICY_VEHICLES: 'policy-vehicles' POLICY_VEHICLES: 'policy-vehicles'
}; });
export default issPageValues;

View file

@ -1,4 +1,4 @@
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios'; import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
// Get store from router/index.js instead of importing it here to get updated values // Get store from router/index.js instead of importing it here to get updated values

View file

@ -1,6 +1,6 @@
import router from '@/router/'; import router from '@/router/';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios'; import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { createApp } from 'vue'; import { createApp } from 'vue';
import { createPinia } from 'pinia'; import { createPinia } from 'pinia';
import App from '@/App.vue'; import App from '@/App.vue';

View file

@ -7,7 +7,7 @@ import { getDateForSavedSessionTimeout } from '@/helpers/session-helper';
import globalMethods from '@/global-methods'; import globalMethods from '@/global-methods';
import { experimentTriggers } from '@/constants/experiments'; import { experimentTriggers } from '@/constants/experiments';
import applicationConfig from '@/constants/application-config'; import applicationConfig from '@/constants/application-config';
import { issPageValues } from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import damageLocationsSelected from '@/constants/damage-locations-selected'; import damageLocationsSelected from '@/constants/damage-locations-selected';
import coverageStatuses from '@/constants/coverage-statuses'; import coverageStatuses from '@/constants/coverage-statuses';

View file

@ -1,7 +1,51 @@
/* eslint-disable max-len */
import { shallowMount, RouterLinkStub } from '@vue/test-utils'; import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import alert from './alert'; import alert from '@/ux-components/alert/alert.vue';
const mockMixin = {
methods: {
getCmsContent: jest.fn(),
getFooterInfoBoxHeight: jest.fn(() => 50)
},
computed: {
dynamicStrings: jest.fn(() => ({ ROUTER_LINK: 'routerLink:' })),
cssClassNameForCmsWidget() {
return 'widget-name-';
}
}
};
/** @ignore */
function setUpViewPort(height) {
Object.defineProperty(global.window, 'innerHeight', {
writable: true,
configurable: true,
value: height
});
Object.defineProperty(window.document.documentElement, 'clientHeight', {
writable: true,
configurable: true,
value: height
});
}
/** @ignore */
function setupMocks(mountOptionsMockData = {}) {
const defaultMountOptions = {
propsData: {
manualHeadline: 'testHeader',
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
},
mixins: [mockMixin]
};
const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
return allMountOptions;
}
describe('alert.vue', () => { describe('alert.vue', () => {
it("Should add class 'alert-dismissible' if isDismissible is true", async () => { it("Should add class 'alert-dismissible' if isDismissible is true", async () => {
@ -88,7 +132,7 @@ describe('alert.vue', () => {
Element.prototype.scrollIntoView = mockScrollIntoView; Element.prototype.scrollIntoView = mockScrollIntoView;
// Act // Act
const wrapper = shallowMount(alert, setupMocks({})); shallowMount(alert, setupMocks({}));
// Assert // Assert
// This is an implementation detail - we just need to test that the final step of snapping // This is an implementation detail - we just need to test that the final step of snapping
@ -108,7 +152,7 @@ describe('alert.vue', () => {
Element.prototype.scrollIntoView = mockScrollIntoView; Element.prototype.scrollIntoView = mockScrollIntoView;
// Act // Act
const wrapper = shallowMount(alert, setupMocks({})); shallowMount(alert, setupMocks({}));
// Assert // Assert
// This is an implementation detail - we just need to test that the final step of snapping // This is an implementation detail - we just need to test that the final step of snapping
@ -128,7 +172,7 @@ describe('alert.vue', () => {
Element.prototype.scrollIntoView = mockScrollIntoView; Element.prototype.scrollIntoView = mockScrollIntoView;
// Act // Act
const wrapper = shallowMount(alert, shallowMount(alert,
setupMocks({ setupMocks({
propsData: { propsData: {
shouldScrollToOnMount: false, shouldScrollToOnMount: false,
@ -156,7 +200,7 @@ describe('alert.vue', () => {
Element.prototype.scrollIntoView = mockScrollIntoView; Element.prototype.scrollIntoView = mockScrollIntoView;
// Act // Act
const wrapper = shallowMount(alert, setupMocks({})); shallowMount(alert, setupMocks({}));
// Assert // Assert
// This is an implementation detail - we just need to test that the final step of snapping // This is an implementation detail - we just need to test that the final step of snapping
@ -165,52 +209,3 @@ describe('alert.vue', () => {
expect(mockScrollIntoView).not.toHaveBeenCalled(); expect(mockScrollIntoView).not.toHaveBeenCalled();
}); });
}); });
const mockMixin = {
methods: {
getCmsContent: jest.fn(),
getFooterInfoBoxHeight: jest.fn(() => 50)
},
computed: {
dynamicStrings: jest.fn(() => ({ ROUTER_LINK: 'routerLink:' })),
cssClassNameForCmsWidget() {
return 'widget-name-';
}
}
};
/**
*
* @param height
*/
function setUpViewPort(height) {
Object.defineProperty(global.window, 'innerHeight', {
writable: true,
configurable: true,
value: height
});
Object.defineProperty(window.document.documentElement, 'clientHeight', {
writable: true,
configurable: true,
value: height
});
}
/**
*
* @param mountOptionsMockData
*/
function setupMocks(mountOptionsMockData = {}) {
const defaultMountOptions = {
propsData: {
manualHeadline: 'testHeader',
manualCopy: 'testCopy',
cmsWidgetName: 'alert'
},
mixins: [mockMixin]
};
const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
return allMountOptions;
}

View file

@ -78,7 +78,7 @@ export default {
type: String, type: String,
default(rawProps) { default(rawProps) {
if (!rawProps.cmsWidgetName) { if (!rawProps.cmsWidgetName) {
console.log('Error: Missing a CMS Widget Name (required field)'); window.console.log('Error: Missing a CMS Widget Name (required field)');
} }
return 'widgetUndefined'; return 'widgetUndefined';
} }

View file

@ -1,7 +1,16 @@
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import buttonMain from './button-main'; import buttonMain from '@/ux-components/button-main/button-main.vue';
/** @ignore */
function setupMocks(mountOptionsMockData = {}) {
const defaultMountOptions = { route: { query: { issPage: 'page-name' } } };
const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
return allMountOptions;
}
describe('buttonMain.vue', () => { describe('buttonMain.vue', () => {
it('Should return btn-primary class', async () => { it('Should return btn-primary class', async () => {
@ -48,8 +57,6 @@ describe('buttonMain.vue', () => {
// Assert // Assert
const label = wrapper.find('label');
wrapper.vm.clicked(); wrapper.vm.clicked();
await nextTick(); await nextTick();
@ -71,8 +78,6 @@ describe('buttonMain.vue', () => {
// Assert // Assert
const label = wrapper.find('label');
wrapper.vm.clicked(); wrapper.vm.clicked();
await nextTick(); await nextTick();
@ -82,15 +87,3 @@ describe('buttonMain.vue', () => {
expect(loader.attributes('class')).toContain('right'); expect(loader.attributes('class')).toContain('right');
}); });
}); });
/**
*
* @param mountOptionsMockData
*/
function setupMocks(mountOptionsMockData = {}) {
const defaultMountOptions = { route: { query: { issPage: 'page-name' } } };
const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
return allMountOptions;
}

View file

@ -17,7 +17,7 @@
</template> </template>
<script> <script>
import loader from '@/ux-components/loader/loader'; import loader from '@/ux-components/loader/loader.vue';
export default { export default {
name: 'button-main', name: 'button-main',

View file

@ -1,5 +1,5 @@
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import checkbox from './checkbox'; import checkbox from '@/ux-components/checkbox/checkbox.vue';
describe('checkbox.vue', () => { describe('checkbox.vue', () => {
it('Should return checkbox name', async () => { it('Should return checkbox name', async () => {

View file

@ -1,6 +1,22 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin'; import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin';
import listButtonHorizontal from './list-button-horizontal'; import listButtonHorizontal from '@/ux-components/list-button-horizontal/list-button-horizontal.vue';
/** @ignore */
function setupMocks({ mockData }) {
const wrapper = mount(listButtonHorizontal, {
...mockData,
propsData: {
...mockData.propsData,
groupName: 'my-group',
modelValue: mockData.propsData?.isMultiSelect ? ['5'] : '5',
value: mockData.propsData?.isMultiSelect ? ['4'] : '4'
},
mixins: [inputButtonWrapperMixin]
});
return { wrapper };
}
describe('list-button-horizontal.vue', () => { describe('list-button-horizontal.vue', () => {
describe('styling/UI', () => { describe('styling/UI', () => {
@ -122,23 +138,3 @@ describe('list-button-horizontal.vue', () => {
}); });
}); });
}); });
/**
*
* @param root0
* @param root0.mockData
*/
function setupMocks({ mockData }) {
const wrapper = mount(listButtonHorizontal, {
...mockData,
propsData: {
...mockData.propsData,
groupName: 'my-group',
modelValue: mockData.propsData?.isMultiSelect ? ['5'] : '5',
value: mockData.propsData?.isMultiSelect ? ['4'] : '4'
},
mixins: [inputButtonWrapperMixin]
});
return { wrapper };
}

View file

@ -29,7 +29,7 @@
</template> </template>
<script> <script>
import baseInputButton from '@/digital-components/base-input-button/base-input-button'; import baseInputButton from '@/digital-components/base-input-button/base-input-button.vue';
import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin'; import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin';
export default { export default {

View file

@ -1,7 +1,17 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GaActions } from '@/constants/analytics'; import { GaActions } from '@/constants/analytics';
import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin'; import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin';
import listButton from './list-button'; import listButton from '@/ux-components/list-button/list-button.vue';
/** @ignore */
function setupMocks({ mockData }) {
const wrapper = mount(listButton, {
...mockData,
mixins: [inputButtonWrapperMixin]
});
return { wrapper };
}
describe('list-button.vue', () => { describe('list-button.vue', () => {
describe('loader', () => { describe('loader', () => {
@ -293,17 +303,3 @@ describe('list-button.vue', () => {
}); });
}); });
}); });
/**
*
* @param root0
* @param root0.mockData
*/
function setupMocks({ mockData }) {
const wrapper = mount(listButton, {
...mockData,
mixins: [inputButtonWrapperMixin]
});
return { wrapper };
}

View file

@ -30,8 +30,8 @@
</template> </template>
<script> <script>
import loader from '@/ux-components/loader/loader'; import loader from '@/ux-components/loader/loader.vue';
import baseInputButton from '@/digital-components/base-input-button/base-input-button'; import baseInputButton from '@/digital-components/base-input-button/base-input-button.vue';
import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin'; import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin';
export default { export default {

View file

@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import listCard from './list-card'; import listCard from '@/ux-components/list-card/list-card.vue';
describe('list-card.vue', () => { describe('list-card.vue', () => {
it('Should return input type checkbox if isMultiSelect is true', () => { it('Should return input type checkbox if isMultiSelect is true', () => {

View file

@ -42,7 +42,7 @@
</template> </template>
<script> <script>
import baseInputButton from '@/digital-components/base-input-button/base-input-button'; import baseInputButton from '@/digital-components/base-input-button/base-input-button.vue';
import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin'; import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin';
export default { export default {

View file

@ -1,7 +1,16 @@
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import modalButtonMain from './modal-button-main'; import modalButtonMain from '@/ux-components/modal-button-main/modal-button-main.vue';
/** @ignore */
function setupMocks(mountOptionsMockData = {}) {
const defaultMountOptions = { route: { query: { issPage: 'page-name' } } };
const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
return allMountOptions;
}
describe('modal-button-main.vue', () => { describe('modal-button-main.vue', () => {
it('Should return btn-primary class', () => { it('Should return btn-primary class', () => {
@ -90,7 +99,6 @@ describe('modal-button-main.vue', () => {
await nextTick(); await nextTick();
// Assert // Assert
const loader = wrapper.find('loader-stub');
expect(wrapper.vm.isLoaderDisplayed).toBe(false); expect(wrapper.vm.isLoaderDisplayed).toBe(false);
}); });
@ -160,15 +168,3 @@ describe('modal-button-main.vue', () => {
expect(wrapper.emitted('click-event')).toBeFalsy(); expect(wrapper.emitted('click-event')).toBeFalsy();
}); });
}); });
/**
*
* @param mountOptionsMockData
*/
function setupMocks(mountOptionsMockData = {}) {
const defaultMountOptions = { route: { query: { issPage: 'page-name' } } };
const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
return allMountOptions;
}

View file

@ -18,7 +18,7 @@
</template> </template>
<script> <script>
import loader from '@/ux-components/loader/loader'; import loader from '@/ux-components/loader/loader.vue';
export default { export default {
name: 'modal-button-main', name: 'modal-button-main',

View file

@ -1,5 +1,5 @@
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import radio from './radio'; import radio from '@/ux-components/radio/radio.vue';
describe('radio.vue', () => { describe('radio.vue', () => {
it('Should return group name', async () => { it('Should return group name', async () => {

View file

@ -1,5 +1,5 @@
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import textLink from './text-link'; import textLink from '@/ux-components/text-link/text-link.vue';
describe('text-link.vue', () => { describe('text-link.vue', () => {
it('Should return class navigation-link', async () => { it('Should return class navigation-link', async () => {