Skip to content

Commit

Permalink
fix(gui): using grep with reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Mar 22, 2018
1 parent 5306c37 commit 4e3c66d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/gui/tool-runner-factory/base-tool-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ module.exports = class ToolRunner {
}

_applyReuseData(testSuites) {
if (!testSuites) {
return;
}

const reuseData = this._loadReuseData();

if (_.isEmpty(reuseData.suites)) {
Expand Down
19 changes: 9 additions & 10 deletions lib/static/components/controls/gui-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ import RunButton from './run-button';

class ControlButtons extends Component {
_runFailedTests = () => {
const {actions, failed} = this.props;
const {actions, suites} = this.props;

return actions.runFailedTests(failed);
return actions.runFailedTests(suites.failed);
}

_acceptAll = () => {
const {actions, failed} = this.props;
const {actions, suites} = this.props;

return actions.acceptAll(failed);
return actions.acceptAll(suites.failed);
}

render() {
const {actions, failed, running, autoRun} = this.props;
const {actions, suites, running, autoRun} = this.props;

return (
<div className="control-buttons">
<RunButton
autoRun={autoRun}
isDisabled={running}
isDisabled={!suites.all.length || running}
handler={actions.runAllTests}
/>
<ControlButton
label="Retry failed tests"
isDisabled={running || !failed.length}
isDisabled={running || !suites.failed.length}
handler={this._runFailedTests}
/>
<ControlButton
label="Accept all"
isDisabled={running || !failed.length}
isDisabled={running || !suites.failed.length}
handler={this._acceptAll}
/>
<CommonControls/>
Expand All @@ -49,8 +49,7 @@ class ControlButtons extends Component {

export default connect(
(state) => ({
view: state.view,
failed: state.suites.failed,
suites: state.suites,
running: state.running,
autoRun: state.autoRun
}),
Expand Down
12 changes: 8 additions & 4 deletions lib/static/components/suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ class Suites extends Component {
render() {
const {suites, viewMode, expand} = this.props;

const buildSuites = () => {
return suites[viewMode].map((suite) => {
const key = uniqueId(`${suite.suitePath}-${suite.name}`);
return <SectionCommon key={key} suite={suite} expand={expand} />;
});
};

return (
<div className="sections">
{suites[viewMode].map((suite) => {
const key = uniqueId(`${suite.suitePath}-${suite.name}`);
return <SectionCommon key={key} suite={suite} expand={expand}/>;
})}
{suites[viewMode].length ? buildSuites() : 'No tests'}
</div>
);
}
Expand Down
17 changes: 17 additions & 0 deletions test/lib/gui/tool-runner-factory/base-tool-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,30 @@ describe('lib/gui/tool-runner-factory/base-tool-runner', () => {
});

describe(`reuse ${name} data`, () => {
it('should not try load data for reuse if suites are empty', () => {
const gui = initGuiReporter({configs: mkPluginConfig_({path: 'report_path'})});

return gui.initialize()
.then(() => assert.notCalled(serverUtils.require));
});

it('should try to load data for reuse', () => {
const gui = initGuiReporter({configs: mkPluginConfig_({path: 'report_path'})});
const reusePath = path.resolve(process.cwd(), 'report_path/data');

const suites = [mkSuiteTree_()];
reportBuilder.getResult.returns({suites});

return gui.initialize()
.then(() => assert.calledOnceWith(serverUtils.require, reusePath));
});

it('should not fail if data for reuse does not exist', () => {
const gui = initGuiReporter();

const suites = [mkSuiteTree_()];
reportBuilder.getResult.returns({suites});

serverUtils.require.throws(new Error('Cannot find module'));

return assert.isFulfilled(gui.initialize());
Expand All @@ -132,6 +146,9 @@ describe('lib/gui/tool-runner-factory/base-tool-runner', () => {
const gui = initGuiReporter();
serverUtils.require.throws(new Error('Cannot find module'));

const suites = [mkSuiteTree_()];
reportBuilder.getResult.returns({suites});

return gui.initialize()
.then(() => assert.calledWithMatch(serverUtils.logger.warn, 'Nothing to reuse'));
});
Expand Down

0 comments on commit 4e3c66d

Please sign in to comment.