Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
fix: child suites retries not called
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy-kiselyov committed Mar 23, 2018
1 parent 02079da commit a141462
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
6 changes: 4 additions & 2 deletions lib/runner/suite-runner/insistent-suite-runner.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';

const _ = require('lodash');

const SuiteRunner = require('./suite-runner');
const RegularSuiteRunner = require('./regular-suite-runner');
const SuiteCollection = require('../../suite-collection');
const Events = require('../../constants/events');
const NoRefImageError = require('../../errors/no-ref-image-error');
const _ = require('lodash');

module.exports = class InsistentSuiteRunner extends SuiteRunner {
static create(suite, browserAgent, config) {
Expand Down Expand Up @@ -67,8 +68,9 @@ module.exports = class InsistentSuiteRunner extends SuiteRunner {
return;
}

const collection = new SuiteCollection([suite]).disableAll();
const browser = this._browserAgent.browserId;
const collection = new SuiteCollection([suite]);
suite.states.forEach((state) => collection.disable(suite, {state: state.name}));
this._statesToRetry.forEach((state) => collection.enable(suite, {state, browser}));
}

Expand Down
40 changes: 30 additions & 10 deletions test/unit/runner/suite-runner/insistent-suite-runner.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
'use strict';

const Promise = require('bluebird');
const _ = require('lodash');

const {BrowserAgent} = require('gemini-core');
const Events = require('lib/constants/events');
const InsistentSuiteRunner = require('lib/runner/suite-runner/insistent-suite-runner');
const RegularSuiteRunner = require('lib/runner/suite-runner/regular-suite-runner');
const CancelledError = require('lib/errors/cancelled-error');
const NoRefImageError = require('lib/errors/no-ref-image-error');
const makeStateStub = require('../../../util').makeStateStub;
const makeSuiteStub = require('../../../util').makeSuiteStub;
const makeSuiteTree = require('../../../util').makeSuiteTree;
const BrowserAgent = require('gemini-core').BrowserAgent;
const Promise = require('bluebird');
const _ = require('lodash');
const {makeStateStub, makeSuiteStub, makeSuiteTree} = require('../../../util');

describe('runner/suite-runner/insistent-suite-runner', () => {
const sandbox = sinon.sandbox.create();
Expand Down Expand Up @@ -453,17 +452,16 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
});

it('should retry only failed states', () => {
const tree = makeSuiteTree({suite: ['1st', '2nd', '3rd']}, {browsers: ['bro']});
sandbox.spy(RegularSuiteRunner, 'create');

const suite = makeSuiteTree({suite: ['1st', '2nd', '3rd']}, {browsers: ['bro', 'firefox']}).suite;
stubWrappedRun_((runner) => {
runner.emit(Events.TEST_RESULT, {state: {name: '1st'}, equal: true});
runner.emit(Events.ERROR, {state: {name: '2nd'}});
runner.emit(Events.TEST_RESULT, {state: {name: '3rd'}, equal: false});
});

sandbox.spy(RegularSuiteRunner, 'create');

return mkRunnerWithRetries_({suite: tree.suite, browserAgent: mkBrowserAgentStub_('bro')})
return mkRunnerWithRetries_({suite, browserAgent: mkBrowserAgentStub_('bro')})
.run()
.then(() => {
const retriedSuite = RegularSuiteRunner.create.secondCall.args[0];
Expand All @@ -472,6 +470,28 @@ describe('runner/suite-runner/insistent-suite-runner', () => {
assert.deepEqual(retriedSuite.states[2].browsers, ['bro']);
});
});

it('should not affect child states', () => {
sandbox.spy(RegularSuiteRunner, 'create');

const suite = makeSuiteTree({
suite: {
child: ['childState']
}
}, {browsers: ['bro', 'firefox']}).suite;
makeStateStub(suite, {name: 'rootState'});

stubWrappedRun_((runner) => {
runner.emit(Events.TEST_RESULT, {state: {name: 'rootState'}, equal: false});
});

return mkRunnerWithRetries_({suite, browserAgent: mkBrowserAgentStub_('bro')})
.run()
.then(() => {
const childState = suite.children[0].states[0];
assert.deepEqual(childState.browsers, ['bro', 'firefox']);
});
});
});

describe('cancel', () => {
Expand Down

0 comments on commit a141462

Please sign in to comment.