From bc355eb6f30cf70fe6f0aa2fa8fa2c5b503f7ae1 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Fri, 21 Aug 2020 15:51:01 -0400 Subject: [PATCH] fix(testing): platform component import exceptions (#386) --- src/components/authentication/authentication.js | 2 +- tests/__snapshots__/platform.test.js.snap | 8 +++++--- tests/platform.test.js | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/components/authentication/authentication.js b/src/components/authentication/authentication.js index d72abb69d..f09bba22f 100644 --- a/src/components/authentication/authentication.js +++ b/src/components/authentication/authentication.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { BinocularsIcon, LockIcon } from '@patternfly/react-icons'; -import { Maintenance } from '@redhat-cloud-services/frontend-components/components/Maintenance'; +import { Maintenance } from '@redhat-cloud-services/frontend-components/components/cjs/Maintenance'; import { connectRouter, reduxActions, reduxSelectors } from '../../redux'; import { rhsmApiTypes } from '../../types'; import { helpers } from '../../common'; diff --git a/tests/__snapshots__/platform.test.js.snap b/tests/__snapshots__/platform.test.js.snap index 573e1af6e..b4e49f6c6 100644 --- a/tests/__snapshots__/platform.test.js.snap +++ b/tests/__snapshots__/platform.test.js.snap @@ -1,13 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Platform Configuration should have a name reference that matches configuration: ui name 1`] = ` +exports[`Platform Configuration, Build should have a name reference that matches configuration: ui name 1`] = ` Array [ "REACT_APP_UI_NAME=subscriptions", "", ] `; -exports[`Platform Configuration should have a proxy configuration with path references that match configuration: proxy references 1`] = ` +exports[`Platform Configuration, Build should have a proxy configuration with path references that match configuration: proxy references 1`] = ` Array [ "'/apps/subscriptions': {", "'/beta/apps/subscriptions': {", @@ -19,7 +19,7 @@ Array [ ] `; -exports[`Platform Configuration should have path references that match configuration: path references 1`] = ` +exports[`Platform Configuration, Build should have path references that match configuration: path references 1`] = ` Array [ "PUBLIC_URL=\${UI_DEPLOY_PATH_PREFIX}/apps/subscriptions/", "REACT_APP_CONFIG_SERVICE_LOCALES=\${UI_DEPLOY_PATH_PREFIX}/apps/subscriptions/locales/locales.json", @@ -27,3 +27,5 @@ Array [ "", ] `; + +exports[`Platform Configuration, Build should use direct imports for platform components, with exceptions: direct import exceptions 1`] = `Array []`; diff --git a/tests/platform.test.js b/tests/platform.test.js index 560f776ba..0de3d5143 100644 --- a/tests/platform.test.js +++ b/tests/platform.test.js @@ -1,7 +1,7 @@ const { execSync } = require('child_process'); const packageJson = require('../package'); -describe('Platform Configuration', () => { +describe('Platform Configuration, Build', () => { it('should have a name reference that matches configuration', () => { const envFile = './.env'; const { appname } = packageJson.insights; @@ -30,4 +30,19 @@ describe('Platform Configuration', () => { .map(value => value.trim()) ).toMatchSnapshot('proxy references'); }); + + it('should use direct imports for platform components, with exceptions', () => { + const srcDir = 'src'; + const output = execSync( + `echo "$(cd ./${srcDir} && git grep -n -E "(@redhat-cloud-services/frontend-components/components/)")"` + ); + + expect( + output + .toString() + .trim() + .split(/[\n\r]/g) + .filter(str => !/\/(cjs|esm)\//.test(str)) + ).toMatchSnapshot('direct import exceptions'); + }); });