diff --git a/lib/runner/suite-runner/insistent-suite-runner.js b/lib/runner/suite-runner/insistent-suite-runner.js index 960b7438a..fab1feb30 100644 --- a/lib/runner/suite-runner/insistent-suite-runner.js +++ b/lib/runner/suite-runner/insistent-suite-runner.js @@ -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) { @@ -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})); } diff --git a/test/unit/runner/suite-runner/insistent-suite-runner.js b/test/unit/runner/suite-runner/insistent-suite-runner.js index 8ba986b0a..c84e2cf13 100644 --- a/test/unit/runner/suite-runner/insistent-suite-runner.js +++ b/test/unit/runner/suite-runner/insistent-suite-runner.js @@ -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(); @@ -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]; @@ -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', () => {