Skip to content

Commit

Permalink
Update to react-scripts 3 (#277)
Browse files Browse the repository at this point in the history
* Update to react-scripts 3

Fixes security vulnerabilities reported by npm audit and gives us latest
react-scripts features and updates. Update Snapshot tests to work with latest
Jest 24 required by react-scripts 3 by using the enzyme-to-json package (see
jestjs/jest#7802).

* Update eslint config

* Fix lint errors
  • Loading branch information
ryan-collingham authored Sep 12, 2019
1 parent 676077e commit 96f4c1d
Show file tree
Hide file tree
Showing 37 changed files with 8,422 additions and 67,052 deletions.
3 changes: 2 additions & 1 deletion testplan/web_ui/testing/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__tests__
__snapshots__
sampleReports.js
sampleReports.js
fakeReport.js
24 changes: 11 additions & 13 deletions testplan/web_ui/testing/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"env": {
"browser": true,
"es6": true,
"node": true,
"commonjs": true
"browser": 2,
"es6": 2,
"node": 2,
"commonjs": 2
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
"react-app"
],
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true,
"arrowFunctions": true,
"classes": true,
"modules": true,
"defaultParams": true
"experimentalObjectRestSpread": 2,
"jsx": 2,
"arrowFunctions": 2,
"classes": 2,
"modules": 2,
"defaultParams": 2
},
"sourceType": "module"
},
Expand All @@ -37,7 +36,6 @@
"no-extra-parens": [2, "functions"],
"no-self-compare": 2,
"accessor-pairs": 2,
"allowSingleLine": true,
"comma-spacing": [2, {
"before": false,
"after": true
Expand Down
30 changes: 23 additions & 7 deletions testplan/web_ui/testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testplan",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"dependencies": {
"@babel/polyfill": "7.0.0",
Expand All @@ -14,30 +14,46 @@
"bootstrap": "4.3.1",
"enzyme": "3.7.0",
"enzyme-adapter-react-16": "1.6.0",
"eslint": "5.10.0",
"eslint-plugin-react": "7.11.1",
"react": "16.6.0",
"react-copy-html-to-clipboard": "6.0.4",
"react-custom-scrollbars": "4.2.1",
"react-dom": "16.6.0",
"react-portal-tooltip": "2.4.0",
"react-scripts": "1.1.1",
"react-scripts": "3.0.1",
"react-spinners": "^0.6.0",
"react-syntax-highlighter": "^11.0.2",
"react-test-renderer": "16.6.0",
"react-vis": "^1.11.7",
"reactstrap": "6.3.0"
},
"devDependencies": {
"babel-eslint": "10.0.1",
"enzyme-to-json": "^3.3.5",
"eslint-plugin-react": "^7.14.3",
"moxios": "0.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"test": "react-scripts test",
"lint": "eslint --ext .js src",
"eject": "react-scripts eject"
},
"homepage": "/"
"homepage": "/",
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}
}
25 changes: 18 additions & 7 deletions testplan/web_ui/testing/src/AssertionPane/Assertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import NotImplementedAssertion from './AssertionTypes/NotImplementedAssertion';
import AssertionHeader from './AssertionHeader';
import AssertionGroup from './AssertionGroup';
import {BASIC_ASSERTION_TYPES} from '../Common/defaults';
import XYGraphAssertion from './AssertionTypes/GraphAssertions/XYGraphAssertion';
import DiscreteChartAssertion from './AssertionTypes/GraphAssertions/DiscreteChartAssertion';
import XYGraphAssertion
from './AssertionTypes/GraphAssertions/XYGraphAssertion';
import DiscreteChartAssertion
from './AssertionTypes/GraphAssertions/DiscreteChartAssertion';
import SummaryBaseAssertion from './AssertionSummary';

/**
* Component to render one assertion.
*/
Expand Down Expand Up @@ -79,6 +82,13 @@ class Assertion extends Component {
* @public
*/
assertionComponent(assertionType) {
let graphAssertion;
if (this.props.assertion.discrete_chart) {
graphAssertion = DiscreteChartAssertion;
} else {
graphAssertion = XYGraphAssertion;
}

const assertionMap = {
TableLog: TableLogAssertion,
TableMatch: TableMatchAssertion,
Expand All @@ -88,7 +98,7 @@ class Assertion extends Component {
DictMatch: DictMatchAssertion,
FixLog: FixLogAssertion,
FixMatch: FixMatchAssertion,
Graph: this.props.assertion.discrete_chart? DiscreteChartAssertion: XYGraphAssertion
Graph: graphAssertion,
};
if (assertionMap[assertionType]) {
return assertionMap[assertionType];
Expand Down Expand Up @@ -117,16 +127,17 @@ class Assertion extends Component {
globalIsOpen={this.props.globalIsOpen}
resetGlobalIsOpen={this.props.resetGlobalIsOpen}
filter={this.props.filter}
/>
/>;
break;
default:
let AssertionTypeComponent = this.assertionComponent(assertionType);
default: {
const AssertionTypeComponent = this.assertionComponent(assertionType);
if (AssertionTypeComponent) {
assertionType =
<AssertionTypeComponent assertion={this.props.assertion} />;
} else {
assertionType = <NotImplementedAssertion />;
}
}
}

return (
Expand Down Expand Up @@ -162,7 +173,7 @@ Assertion.propTypes = {
assertion: PropTypes.object,
/** State of the expand all/collapse all functionality */
globalIsOpen: PropTypes.bool,
/** Function to reset the expand all/collapse all state if an individual
/** Function to reset the expand all/collapse all state if an individual
* assertion's visibility is changed */
resetGlobalIsOpen: PropTypes.func,
/** Index of the assertion */
Expand Down
12 changes: 6 additions & 6 deletions testplan/web_ui/testing/src/AssertionPane/AssertionSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SummaryBaseAssertion extends Component {

// Go through categories e.g Category: DEFAULT
return summaries.map(category =>{
let category_description = category.description
let category_description = category.description;

// Go through assertion types e.g Assertion type: Equal
let assertions_types =
Expand Down Expand Up @@ -50,15 +50,15 @@ class SummaryBaseAssertion extends Component {
</Col>
</Row>
</div>
)
);

return (
<div key={assertions_types.description}>
{description}
{entries}
</div>
)
})
);
});

return (
<div key={category.description}>
Expand All @@ -73,8 +73,8 @@ class SummaryBaseAssertion extends Component {
</Col>
</Row>
</div>
)
})
);
});
}
}

Expand Down
Loading

0 comments on commit 96f4c1d

Please sign in to comment.