From fc67e855d963602285cf4126dd02351d069c1ed9 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Fri, 27 May 2016 22:21:52 -0700 Subject: [PATCH] Update tests to use pass/err to determine refresh --- .../components/classic/Side-Panel.jsx | 9 +------- .../components/classic/Test-Suite.jsx | 21 +++++++++++-------- common/app/routes/challenges/redux/reducer.js | 7 ++++--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/common/app/routes/challenges/components/classic/Side-Panel.jsx b/common/app/routes/challenges/components/classic/Side-Panel.jsx index f4299230a1..263f8c3760 100644 --- a/common/app/routes/challenges/components/classic/Side-Panel.jsx +++ b/common/app/routes/challenges/components/classic/Side-Panel.jsx @@ -15,21 +15,18 @@ const mapStateToProps = createSelector( state => state.app.windowHeight, state => state.app.navHeight, state => state.challengesApp.tests, - state => state.challengesApp.refresh, state => state.challengesApp.output, ( { challenge: { title, description } = {} }, windowHeight, navHeight, tests, - refresh, output ) => ({ title, description, height: windowHeight - navHeight - 20, tests, - refresh, output }) ); @@ -46,7 +43,6 @@ export class SidePanel extends PureComponent { height: PropTypes.number, tests: PropTypes.arrayOf(PropTypes.object), title: PropTypes.string, - refresh: PropTypes.bool, output: PropTypes.string }; @@ -74,7 +70,6 @@ export class SidePanel extends PureComponent { description, height, tests = [], - refresh, output } = this.props; const style = { @@ -104,9 +99,7 @@ export class SidePanel extends PureComponent {
- + ); } diff --git a/common/app/routes/challenges/components/classic/Test-Suite.jsx b/common/app/routes/challenges/components/classic/Test-Suite.jsx index dff602ab4b..ad002013e7 100644 --- a/common/app/routes/challenges/components/classic/Test-Suite.jsx +++ b/common/app/routes/challenges/components/classic/Test-Suite.jsx @@ -6,17 +6,20 @@ import { Col, Row } from 'react-bootstrap'; export default class extends PureComponent { static displayName = 'TestSuite'; static proptTypes = { - tests: PropTypes.arrayOf(PropTypes.object), - refresh: PropTypes.bool + tests: PropTypes.arrayOf(PropTypes.object) }; - renderTests(tests = [], refresh = false) { - return tests.map(({ err, text = '' }, index)=> { + renderTests(tests = []) { + // err && pass > invalid state + // err && !pass > failed tests + // !err && pass > passed tests + // !err && !pass > in-progress + return tests.map(({ err, pass = false, text = '' }, index)=> { const iconClass = classnames({ 'big-icon': true, - 'ion-close-circled error-icon': !refresh && err, - 'ion-checkmark-circled success-icon': !refresh && !err, - 'ion-refresh refresh-icon': refresh + 'ion-close-circled error-icon': err && !pass, + 'ion-checkmark-circled success-icon': !err && pass, + 'ion-refresh refresh-icon': !err && !pass }); return ( @@ -35,12 +38,12 @@ export default class extends PureComponent { } render() { - const { tests, refresh } = this.props; + const { tests } = this.props; return (
- { this.renderTests(tests, refresh) } + { this.renderTests(tests) }
); } diff --git a/common/app/routes/challenges/redux/reducer.js b/common/app/routes/challenges/redux/reducer.js index f2933d944e..5f48df4db9 100644 --- a/common/app/routes/challenges/redux/reducer.js +++ b/common/app/routes/challenges/redux/reducer.js @@ -30,7 +30,6 @@ const mainReducer = handleActions( }), [types.updateCurrentChallenge]: (state, { payload: challenge }) => ({ ...state, - refresh: true, id: challenge.id, // used mainly to find code storage legacyKey: challenge.name, @@ -40,10 +39,12 @@ const mainReducer = handleActions( }), [types.updateTests]: (state, { payload: tests }) => ({ ...state, - refresh: false, tests }), - [types.executeChallenge]: state => ({ ...state, refresh: true }), + [types.executeChallenge]: state => ({ + ...state, + tests: state.tests.map(test => ({ ...test, err: false, pass: false })) + }), // map [types.updateFilter]: (state, { payload = ''}) => ({