Skip to content

Commit

Permalink
fix(testing): platform component import exceptions (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Aug 25, 2020
1 parent 74ff231 commit bc355eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/authentication/authentication.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
8 changes: 5 additions & 3 deletions tests/__snapshots__/platform.test.js.snap
Original file line number Diff line number Diff line change
@@ -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': {",
Expand All @@ -19,11 +19,13 @@ 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",
"REACT_APP_CONFIG_SERVICE_LOCALES_PATH=\${UI_DEPLOY_PATH_PREFIX}/apps/subscriptions/locales/{{lng}}.json",
"",
]
`;
exports[`Platform Configuration, Build should use direct imports for platform components, with exceptions: direct import exceptions 1`] = `Array []`;
17 changes: 16 additions & 1 deletion tests/platform.test.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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');
});
});

0 comments on commit bc355eb

Please sign in to comment.