Skip to content

Commit

Permalink
fix(gui): do not run all tests on restart successful suite
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Apr 6, 2018
1 parent 2ffd437 commit 1470355
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
12 changes: 6 additions & 6 deletions lib/static/components/section/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ class SectionBrowserBody extends Component {
this.setState({retry: index});
}

onSuiteAccept = () => {
onTestAccept = () => {
const {result, suite} = this.props;

this.props.actions.acceptSuite(suite, result.name, this.state.retry);
this.props.actions.acceptTest(suite, result.name, this.state.retry);
}

onSuiteRetry = () => {
onTestRetry = () => {
const {result, suite} = this.props;

this.props.actions.retrySuite(suite, result.name);
this.props.actions.retryTest(suite, result.name);
}

_addExtraButtons(activeResult) {
Expand All @@ -67,13 +67,13 @@ class SectionBrowserBody extends Component {
label="✔ Accept"
isSuiteControl={true}
isDisabled={acceptDisabled}
handler={this.onSuiteAccept}
handler={this.onTestAccept}
/>
<ControlButton
label="↻ Retry"
isSuiteControl={true}
isDisabled={retryDisabled}
handler={this.onSuiteRetry}
handler={this.onTestRetry}
/>
</div>
)
Expand Down
5 changes: 3 additions & 2 deletions lib/static/modules/action-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
export default {
RUN_ALL_TESTS: 'RUN_ALL_TESTS',
RUN_FAILED_TESTS: 'RUN_FAILED_TESTS',
RETRY_SUITE: 'RETRY_SUITE',
RETRY_TEST: 'RETRY_TEST',
SUITE_BEGIN: 'SUITE_BEGIN',
TEST_BEGIN: 'TEST_BEGIN',
TEST_RESULT: 'TEST_RESULT',
TESTS_END: 'TEST_END',
UPDATE_RESULT: 'UPDATE_RESULT',
ACCEPT_ALL: 'ACCEPT_ALL',
ACCEPT_SUITE: 'ACCEPT_SUITE',
RETRY_SUITE: 'RETRY_SUITE',
ACCEPT_TEST: 'ACCEPT_TEST',
VIEW_INITIAL: 'VIEW_INITIAL',
VIEW_EXPAND_ALL: 'VIEW_EXPAND_ALL',
VIEW_EXPAND_ERRORS: 'VIEW_EXPAND_ERRORS',
Expand Down
45 changes: 23 additions & 22 deletions lib/static/modules/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,36 @@ export const initial = () => {
};
};

export const runAllTests = () => {
const runTests = ({tests = [], action = {}} = {}) => {
return async (dispatch) => {
try {
await axios.post('/run');
dispatch({
type: actionNames.RUN_ALL_TESTS,
payload: {status: QUEUED}
});
await axios.post('/run', tests);
dispatch(action);
} catch (e) {
console.error('Failed to run all tests:', e);
console.error('Error while running tests:', e);
}
};
};

export const runFailedTests = (fails) => {
export const runAllTests = () => {
return runTests({action: {
type: actionNames.RUN_ALL_TESTS,
payload: {status: QUEUED}
}});
};

export const runFailedTests = (fails, actionName = actionNames.RUN_FAILED_TESTS) => {
fails = filterFailedBrowsers([].concat(fails));

return async (dispatch) => {
try {
await axios.post('/run', fails);
dispatch({type: actionNames.RUN_FAILED_TESTS});
} catch (e) {
console.error('Error while running failed tests:', e);
}
};
return runTests({tests: fails, action: {type: actionName}});
};

export const retrySuite = (suite) => {
return runTests({tests: [suite], action: {type: actionNames.RETRY_SUITE}});
};

export const retrySuite = (suite, browserId = null) => {
return runFailedTests(assign({browserId}, suite));
export const retryTest = (suite, browserId = null) => {
return runFailedTests(assign({browserId}, suite), actionNames.RETRY_TEST);
};

export const acceptAll = (fails, actionName = actionNames.ACCEPT_ALL) => {
Expand All @@ -66,8 +67,8 @@ export const acceptAll = (fails, actionName = actionNames.ACCEPT_ALL) => {
};
};

export const acceptSuite = (suite, browserId, attempt) => {
return acceptAll(assign({browserId}, suite, {acceptSuiteAttempt: attempt}), actionNames.ACCEPT_SUITE);
export const acceptTest = (suite, browserId, attempt) => {
return acceptAll(assign({browserId}, suite, {acceptTestAttempt: attempt}), actionNames.ACCEPT_TEST);
};

export const suiteBegin = (suite) => ({type: actionNames.SUITE_BEGIN, payload: suite});
Expand Down Expand Up @@ -106,7 +107,7 @@ function formatTests(test) {
test.browsers = filter(test.browsers, {name: test.browserId});
}

const {suitePath, name, acceptSuiteAttempt} = test;
const {suitePath, name, acceptTestAttempt} = test;

return flatMap(test.browsers, (browser) => {
const {metaInfo, assertViewState, attempt} = browser.result;
Expand All @@ -117,7 +118,7 @@ function formatTests(test) {
browserId: browser.name,
metaInfo,
assertViewState,
attempt: acceptSuiteAttempt >= 0 ? acceptSuiteAttempt : attempt
attempt: acceptTestAttempt >= 0 ? acceptTestAttempt : attempt
};
});
}
Expand Down

0 comments on commit 1470355

Please sign in to comment.