Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using protractor as test tools Signed-off-by: David Desurmont <david.desurmont@gmail.com> Signed-off-by: desurd <david.desurmont@gmail.com>
- Loading branch information
Showing
8 changed files
with
213 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# this file will contains the different generic functions which | ||
# will be called by the different tests | ||
# inspired by this methodology | ||
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/ | ||
|
||
class builderPage | ||
constructor: (builder, forcename) -> | ||
@builderID = { | ||
"runtest" : 1 | ||
"slowruntest": 2 | ||
}[builder] | ||
@forceName=forcename | ||
|
||
goDefault: -> | ||
browser.get('#/builders') | ||
|
||
go: () -> | ||
browser.get('#/builders/#{@builderID}/') | ||
|
||
goForce: (forcename) -> | ||
browser.get("#/builders/#{@builderID}/force/#{@forceName}") | ||
|
||
getBuildCount: () -> | ||
return element.all(By.css('span.badge-status.results_SUCCESS')).count() | ||
|
||
waitNextBuildFinished: (reference) -> | ||
self = this | ||
buildCountIncrement = () -> | ||
self.getBuildCount().then (currentBuildCount) -> | ||
return +currentBuildCount == +reference + 1 | ||
browser.wait(buildCountIncrement, 2000) | ||
|
||
module.exports = builderPage |
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,43 @@ | ||
# this file will contains the different generic functions which | ||
# will be called by the different tests | ||
# inspired by this methodology | ||
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/ | ||
|
||
class forcePage | ||
constructor: -> | ||
browser.get('#/builders') | ||
|
||
setInputText: (cssLabel, value) -> | ||
setInputValue = element(By.css("forcefield label[for=#{cssLabel}] + div input")) | ||
setInputValue.clear() | ||
setInputValue.sendKeys(value) | ||
expect(setInputValue.getAttribute('value')).toBe(value) | ||
|
||
setReason: (reason) -> | ||
return @setInputText("reason", reason) | ||
|
||
setYourName: (yourName) -> | ||
return @setInputText("username", yourName) | ||
|
||
setProjectName: (projectName) -> | ||
return @setInputText("project", projectName) | ||
|
||
setBranchName: (branchName) -> | ||
return @setInputText("branch", branchName) | ||
|
||
setRepo: (repo) -> | ||
return @setInputText("repository", repo) | ||
|
||
setRevisionName: (RevisionName) -> | ||
return @setInputText("revision", RevisionName) | ||
|
||
getStartButton: -> | ||
element(By.buttonText('Start Build')) | ||
|
||
getCancelButton: -> | ||
return element(By.buttonText('Cancel')) | ||
|
||
getCancelWholeQueue: -> | ||
element(By.buttonText('Cancel Whole Queue')) | ||
|
||
module.exports = forcePage |
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 |
---|---|---|
@@ -1,16 +1,29 @@ | ||
describe 'force', () -> | ||
it 'should create a build', () -> | ||
browser.get('#/builders/1') | ||
lastbuild = element.all(By.css('span.badge-status.results_SUCCESS')).count() | ||
browser.get('#/builders/1/force/force') | ||
browser.waitForAngular() | ||
element(By.buttonText('Start Build')).click() | ||
browser.get('#/builders/1') | ||
successBuildIncrease = -> | ||
lastbuild.then (lastbuild)-> | ||
element.all(By.css('span.badge-status.results_SUCCESS')) | ||
.count().then (nextbuild)-> | ||
return +nextbuild == +lastbuild + 1 | ||
browser.wait(successBuildIncrease, 20000) | ||
browser.get('#/waterfall') | ||
expect(element.all(By.css('rect.success')).count()).toBeGreaterThan(0) | ||
# coffee script | ||
# test goal: checks the capability to define a reason and to cancel/start the build | ||
|
||
forcePage = require('./force.coffee') | ||
builderPage = require('./builder.coffee') | ||
|
||
describe('', () -> | ||
force = null | ||
builder = null | ||
|
||
beforeEach(() -> | ||
builder = new builderPage('runtest', 'force') | ||
force = new forcePage() | ||
builder.goDefault() | ||
) | ||
|
||
lastbuild = null | ||
describe 'force', () -> | ||
it 'should create a build', () -> | ||
|
||
lastbuild = 0 | ||
builder.go() | ||
builder.getBuildCount().then (lastbuild) -> | ||
builder.goForce() | ||
force.getStartButton().click() | ||
builder.go() | ||
builder.waitNextBuildFinished(lastbuild) | ||
expect(element.all(By.css('rect.success')).count()).toBeGreaterThan(0) | ||
) |
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,47 @@ | ||
# coffee script | ||
# test goal: checks the capability to define a reason and to cancel/start the build | ||
|
||
|
||
forcePage = require('./force.coffee') | ||
builderPage = require('./builder.coffee') | ||
|
||
describe('', () -> | ||
force = null | ||
builder = null | ||
|
||
beforeEach(() -> | ||
builder = new builderPage('runtest', 'force') | ||
force = new forcePage() | ||
builder.goDefault() | ||
) | ||
|
||
describe 'force', () -> | ||
it 'should create a build', () -> | ||
builder.go() | ||
builder.getBuildCount().then (lastbuild) -> | ||
builder.goForce() | ||
force.getStartButton().click() | ||
builder.go() | ||
builder.waitNextBuildFinished(lastbuild) | ||
|
||
describe 'forceandcancel', () -> | ||
it 'should create a build with a dedicated reason and cancel it', () -> | ||
|
||
builder.go() | ||
builder.goForce() | ||
force.getCancelButton().click() | ||
|
||
describe 'forceandstart', () -> | ||
it 'should create a build with a dedicated reason and Start it', () -> | ||
|
||
builder.go() | ||
builder.goForce() | ||
force.setReason("New Test Reason") | ||
force.setYourName("FaceLess User") | ||
force.setProjectName("BBOT9") | ||
force.setBranchName("Gerrit Branch") | ||
force.setRepo("http//name.com") | ||
force.setRevisionName("12345") | ||
force.getStartButton().click() | ||
|
||
) |
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,13 @@ | ||
# this file will contains the different generic functions which | ||
# will be called by the different tests | ||
# inspired by this methodology | ||
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/ | ||
|
||
class waterfallPage | ||
constructor: -> | ||
browser.get('#/builders') | ||
|
||
go: -> | ||
browser.get('#/waterfall') | ||
|
||
module.exports = waterfallPage |
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 |
---|---|---|
@@ -1,16 +1,28 @@ | ||
{ | ||
"name": "smokes", | ||
"version": "1.0.0", | ||
"description": "smoke tests for buildbot with protractor", | ||
"main": "index.js", | ||
"dependencies": { | ||
"coffee-script": "^1.11.1", | ||
"protractor": "^4.0.3" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
"name": "smokes", | ||
"version": "1.0.0", | ||
"description": "smoke tests for buildbot with protractor", | ||
"main": "index.js", | ||
"dependencies": { | ||
"coffee-script": "^1.11.1", | ||
"protractor": "^4.0.3" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"coffeelintConfig": { | ||
"indentation": { | ||
"level": "error", | ||
"value": 4 | ||
}, | ||
"max_line_length": { | ||
"value": 110, | ||
"level": "error", | ||
"limitComments": true | ||
} | ||
|
||
}, | ||
"license": "ISC" | ||
} |
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