-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: retry button retries multiple times
- Loading branch information
1 parent
70c701c
commit 63f2555
Showing
4 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
'use strict'; | ||
|
||
const _ = require('lodash'); | ||
const Promise = require('bluebird'); | ||
|
||
const App = require('lib/gui/app'); | ||
const ToolRunnerFactory = require('lib/gui/tool-runner-factory'); | ||
const {stubTool, stubConfig} = require('../../utils'); | ||
|
||
describe('lib/gui/app', () => { | ||
const sandbox = sinon.createSandbox().usingPromise(Promise); | ||
let tool; | ||
let toolRunner; | ||
|
||
const mkApp_ = (opts = {}) => { | ||
opts = _.defaults(opts, { | ||
paths: 'paths', | ||
tool: stubTool(), | ||
configs: {program: {name: () => 'tool'}} | ||
}); | ||
|
||
return new App(opts.paths, opts.tool, opts.configs); | ||
}; | ||
|
||
const mkToolRunner_ = (tool = {}) => { | ||
return { | ||
run: sandbox.stub().named('run').resolves(), | ||
config: tool.config | ||
}; | ||
}; | ||
|
||
beforeEach(() => { | ||
const browserConfigs = { | ||
bro1: {id: 'bro1', retry: 1}, | ||
bro2: {id: 'bro2', retry: 2} | ||
}; | ||
tool = stubTool(stubConfig(browserConfigs)); | ||
toolRunner = mkToolRunner_(tool); | ||
|
||
sandbox.stub(ToolRunnerFactory, 'create').returns(toolRunner); | ||
}); | ||
|
||
afterEach(() => sandbox.restore()); | ||
|
||
describe('run', () => { | ||
it('should run all tests with retries from config', () => { | ||
let retryBeforeRun; | ||
toolRunner.run.callsFake(() => { | ||
retryBeforeRun = tool.config.forBrowser('bro1').retry; | ||
return Promise.resolve(); | ||
}); | ||
|
||
return mkApp_({tool}) | ||
.run() | ||
.then(() => assert.equal(retryBeforeRun, 1)); | ||
}); | ||
|
||
it('should run specified tests with no retries', () => { | ||
let bro1RetryBeforeRun; | ||
let bro2RetryBeforeRun; | ||
toolRunner.run.callsFake(() => { | ||
bro1RetryBeforeRun = tool.config.forBrowser('bro1').retry; | ||
bro2RetryBeforeRun = tool.config.forBrowser('bro2').retry; | ||
return Promise.resolve(); | ||
}); | ||
|
||
return mkApp_({tool}) | ||
.run(['test']) | ||
.then(() => { | ||
assert.equal(bro1RetryBeforeRun, 0); | ||
assert.equal(bro2RetryBeforeRun, 0); | ||
}); | ||
}); | ||
|
||
it('should restore config retry values after run', () => { | ||
return mkApp_({tool}) | ||
.run(['test']) | ||
.then(() => { | ||
assert.equal(tool.config.forBrowser('bro1').retry, 1); | ||
assert.equal(tool.config.forBrowser('bro2').retry, 2); | ||
}); | ||
}); | ||
|
||
it('should restore config retry values even after error', () => { | ||
toolRunner.run.rejects(); | ||
|
||
return mkApp_({tool}) | ||
.run(['test']) | ||
.catch(() => { | ||
assert.equal(tool.config.forBrowser('bro1').retry, 1); | ||
assert.equal(tool.config.forBrowser('bro2').retry, 2); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters