From 138b8341eb82dcb678238c1ee09b6b4548b8929c Mon Sep 17 00:00:00 2001 From: adriancofie Date: Fri, 6 Sep 2024 11:45:53 -0400 Subject: [PATCH] (#102) Prettier changes from #102 Formatting changes. --- cypress/e2e/common/MetaTags.js | 17 ++-- cypress/e2e/common/analytics.js | 76 +++++++++--------- cypress/e2e/common/index.js | 3 +- .../atomic/InputLabel/InputLabel.jsx | 6 +- .../InputLabel/__tests__/InputLabel.tests.js | 16 +--- src/components/atomic/Radio/Radio.jsx | 10 +-- .../atomic/RemovableTag/RemovableTag.jsx | 18 +---- .../__tests__/RemovableTag.tests.js | 4 +- src/components/atomic/TextInput/TextInput.jsx | 78 ++----------------- .../TextInput/__tests__/TextInput.test.js | 3 +- .../__tests__/audio-player.test.js | 26 +++---- .../atomic/audio-player/audio-player.jsx | 19 +---- .../__tests__/youtube-video-player.test.js | 8 +- .../youtube-video-player.jsx | 29 ++----- .../__tests__/figure-cgov-image.test.js | 28 ++----- .../molecules/figures/figure-cgov-image.jsx | 16 +--- .../molecules/figures/figure-cgov-video.jsx | 6 +- .../molecules/pager/__tests__/pager.test.js | 62 +++------------ src/components/molecules/pager/pager.jsx | 31 ++------ .../__tests__/pronunciation.test.js | 8 +- .../molecules/pronunciation/pronunciation.jsx | 4 +- src/hooks/__tests__/customFetch.test.js | 10 +-- src/hooks/customFetch.js | 6 +- src/hooks/routing.js | 5 +- src/index.js | 15 +--- src/serviceWorker.js | 23 ++---- .../__tests__/buildAxiosRequest.test.js | 4 +- src/services/api/common/buildAxiosRequest.js | 5 +- .../api/common/replacingRequestInterceptor.js | 30 ++++--- src/store/store.js | 6 +- .../__tests__/eddl-analytics-provider.test.js | 11 +-- src/tracking/eddl-analytics-handler.js | 14 +--- src/tracking/eddl-analytics-provider.jsx | 14 +--- src/tracking/mock-analytics-provider.jsx | 6 +- src/utils/__tests__/number.test.js | 10 +-- src/utils/__tests__/replaceTokens.test.js | 15 ++-- src/utils/__tests__/url.test.js | 10 +-- src/utils/eddl-analytics-handler.js | 14 +--- src/utils/replaceTokens.js | 6 +- src/utils/url.js | 4 +- src/views/ErrorBoundary/ErrorPage.jsx | 4 +- src/views/ErrorBoundary/PageNotFound.jsx | 38 ++------- src/views/Home/Home.jsx | 29 ++----- 43 files changed, 161 insertions(+), 586 deletions(-) diff --git a/cypress/e2e/common/MetaTags.js b/cypress/e2e/common/MetaTags.js index b6a82b8..1eec48d 100644 --- a/cypress/e2e/common/MetaTags.js +++ b/cypress/e2e/common/MetaTags.js @@ -12,17 +12,14 @@ Then('the page contains meta tags with the following names', (dataTable) => { }); }); -Then( - 'the page contains meta tags with the following properties', - (dataTable) => { - for (const { property, content } of dataTable.hashes()) { - const locator = `META[property='${property}']`; - //find element, ensure it has attribute content - //compare content's value with expected one - cy.get(locator).should('have.attr', 'content').and('be.eq', content); - } +Then('the page contains meta tags with the following properties', (dataTable) => { + for (const { property, content } of dataTable.hashes()) { + const locator = `META[property='${property}']`; + //find element, ensure it has attribute content + //compare content's value with expected one + cy.get(locator).should('have.attr', 'content').and('be.eq', content); } -); +}); Then('there is a canonical link with the href {string}', (href) => { cy.get("link[rel='canonical']") diff --git a/cypress/e2e/common/analytics.js b/cypress/e2e/common/analytics.js index b5e08c4..186a9ba 100644 --- a/cypress/e2e/common/analytics.js +++ b/cypress/e2e/common/analytics.js @@ -70,8 +70,7 @@ const convertAnalyticsDatatableObject = (obj) => { return Object.entries(objPass1).reduce((ac, [key, val] = {}) => { return { ...ac, - [key]: - typeof val === 'object' ? convertAnalyticsDatatableObject(val) : val, + [key]: typeof val === 'object' ? convertAnalyticsDatatableObject(val) : val, }; }, {}); }; @@ -82,9 +81,7 @@ const convertAnalyticsDatatableObject = (obj) => { * @param {string} event The name of the event */ const getEventFromEDDL = (win, type, event) => { - return win.NCIDataLayer.filter( - (evt) => evt.type === type && evt.event === event - ); + return win.NCIDataLayer.filter((evt) => evt.type === type && evt.event === event); }; When('the NCIDataLayer is cleared', () => { @@ -100,44 +97,41 @@ When('the NCIDataLayer is cleared', () => { // basically build up an object from the data table for comparison to the // matched event. Note we do not just look at the page here since in the // future we could have additional data points. -Then( - 'there should be an analytics event with the following details', - (datatable) => { - cy.window().then((win) => { - console.log('finding analytics event for analytics step'); - // First convert the datatable into nested object. - const rawDataObj = convertAnalyticsDatatableObject(datatable.rowsHash()); - // Gotta strip the header row. (key/value) - const dataObj = Object.entries(rawDataObj).reduce((ac, [key, val]) => { - if (key === 'key') { - return ac; - } - return { - ...ac, - [key]: val, - }; - }, {}); - - if (!dataObj.event) { - throw new Error('Datatable is missing the event name'); +Then('there should be an analytics event with the following details', (datatable) => { + cy.window().then((win) => { + console.log('finding analytics event for analytics step'); + // First convert the datatable into nested object. + const rawDataObj = convertAnalyticsDatatableObject(datatable.rowsHash()); + // Gotta strip the header row. (key/value) + const dataObj = Object.entries(rawDataObj).reduce((ac, [key, val]) => { + if (key === 'key') { + return ac; } + return { + ...ac, + [key]: val, + }; + }, {}); - if (!dataObj.type) { - throw new Error('Datatable is missing the event type'); - } + if (!dataObj.event) { + throw new Error('Datatable is missing the event name'); + } - // Find the matching events, this should be only one. - const matchedEvents = getEventFromEDDL(win, dataObj.type, dataObj.event); - expect(matchedEvents).to.have.length(1); + if (!dataObj.type) { + throw new Error('Datatable is missing the event type'); + } - const eventData = matchedEvents[0]; - console.log(eventData); + // Find the matching events, this should be only one. + const matchedEvents = getEventFromEDDL(win, dataObj.type, dataObj.event); + expect(matchedEvents).to.have.length(1); - // This is a cheat. For the most part we know all the values so this - // is ok. We won't support regex matching this way. - // TODO: add regex matching, and when that is added make sure you - // also add a check to make sure there are not unexpected props. - expect(eventData).to.eql(dataObj); - }); - } -); + const eventData = matchedEvents[0]; + console.log(eventData); + + // This is a cheat. For the most part we know all the values so this + // is ok. We won't support regex matching this way. + // TODO: add regex matching, and when that is added make sure you + // also add a check to make sure there are not unexpected props. + expect(eventData).to.eql(dataObj); + }); +}); diff --git a/cypress/e2e/common/index.js b/cypress/e2e/common/index.js index fea617d..f4df67b 100644 --- a/cypress/e2e/common/index.js +++ b/cypress/e2e/common/index.js @@ -93,8 +93,7 @@ And('the following links and texts exist on the page', (dataTable) => { And('the system returns the no results found page', () => { cy.window().then((win) => { if (win.INT_TEST_APP_PARAMS) { - const noResultsPageTitle = - i18n.nciSearchResults[win.INT_TEST_APP_PARAMS.language]; + const noResultsPageTitle = i18n.nciSearchResults[win.INT_TEST_APP_PARAMS.language]; cy.get('h1').should('contain', noResultsPageTitle); } }); diff --git a/src/components/atomic/InputLabel/InputLabel.jsx b/src/components/atomic/InputLabel/InputLabel.jsx index 472773b..b7c194d 100755 --- a/src/components/atomic/InputLabel/InputLabel.jsx +++ b/src/components/atomic/InputLabel/InputLabel.jsx @@ -8,11 +8,7 @@ const InputLabel = ({ label, labelHint, htmlFor, required, hasError }) => { classes += required ? ' ncids-label--required' : ''; classes += hasError ? ' ncids-label--error' : ''; return ( -