Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): platform component import exceptions #386

Merged
merged 1 commit into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});