Skip to content

Commit

Permalink
Merge pull request #2568 from desurd/mysmokes
Browse files Browse the repository at this point in the history
Add new tests for the home web page, for the navigations inside of a …
  • Loading branch information
tardyp committed Jan 26, 2017
2 parents c169d99 + 661e945 commit 3abd0ec
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 8 deletions.
42 changes: 36 additions & 6 deletions smokes/e2e/builder.coffee
Expand Up @@ -12,24 +12,54 @@ class builderPage

go: () ->
browser.get('#/builders')
element.all(By.partialLinkText(@builder)).first().click()
localBuilder = element.all(By.linkText(@builder))
localBuilder.click()

goForce: (forcename) ->
browser.get('#/builders')
element.all(By.partialLinkText(@builder)).first().click()
goForce: () ->
@go()
element.all(By.buttonText(@forceName)).first().click()

goBuild: (buildRef) ->
@go()
element.all(By.linkText(buildRef.toString())).click()

getLastSuccessBuildNumber: () ->
element.all(By.css('span.badge-status.results_SUCCESS')).then (elements)->
if elements.length == 0
return 0
return elements[0].getText()
return elements[0].getText().then (numberstr) ->
return +numberstr

waitNextBuildFinished: (reference) ->
self = this
buildCountIncrement = () ->
self.getLastSuccessBuildNumber().then (currentBuildCount) ->
return +currentBuildCount == +reference + 1
return currentBuildCount == reference + 1
browser.wait(buildCountIncrement, 10000)

waitGoToBuild: (expected_buildnumber) ->
isInBuild = () ->
browser.getLocationAbsUrl().then (buildUrl) ->
split = buildUrl.split("/")
builds_part = split[split.length-2]
number = +split[split.length-1]
if builds_part != "builds"
return false
if number != expected_buildnumber
return false
return true
browser.wait(isInBuild, 10000)

getStopButton: ->
return element(By.buttonText('Stop'))

getPreviousButton: ->
element(By.partialLinkText('Previous'))

getNextButton: ->
element(By.partialLinkText('Next'))

getRebuildButton: ->
return element(By.buttonText('Rebuild'))

module.exports = builderPage
62 changes: 62 additions & 0 deletions smokes/e2e/buildsnavigation.scenarios.coffee
@@ -0,0 +1,62 @@
# coffee script
# test goal: checks the capability to navigate in a dedicated build
# to use previous and next link


forcePage = require('./force.coffee')
builderPage = require('./builder.coffee')

describe('', () ->
force = null
builder = null

beforeEach(() ->
builder = new builderPage('runtests', 'force')
force = new forcePage()
builder.goDefault()
)


describe 'previousnextlink', () ->
it 'should navigate in the builds history by using the previous next links', () ->
builder.go()
builder.getLastSuccessBuildNumber().then (lastbuild) ->
# Build #1
builder.go()
builder.goForce()
force.getStartButton().click()
builder.go()
builder.waitNextBuildFinished(lastbuild)
# Build #2
builder.goForce()
force.getStartButton().click()
builder.go()
builder.waitNextBuildFinished(+lastbuild + 1)
builder.go()
builder.goBuild(lastbuild)
lastBuildURL = browser.getLocationAbsUrl()
builder.getPreviousButton().click()
expect(browser.getLocationAbsUrl()).not.toMatch(lastBuildURL)
builder.getNextButton().click()
expect(browser.getLocationAbsUrl()).toMatch(lastBuildURL)
)

describe('', () ->
force = null
builder = null

beforeEach(() ->
builder = new builderPage('slowruntest', 'force')
force = new forcePage()
builder.goDefault()
)

describe 'forceandstop', () ->
it 'should create a build with a dedicated reason and stop it during execution', () ->

builder.go()
builder.goForce()
force.getStartButton().click()
expect(browser.getLocationAbsUrl()).toMatch("/builders/\[1-9]/builds/\[1-9]")
builder.getStopButton().click()
)
7 changes: 5 additions & 2 deletions smokes/e2e/force.coffee
Expand Up @@ -32,12 +32,15 @@ class forcePage
return @setInputText("revision", RevisionName)

getStartButton: ->
element(By.buttonText('Start Build'))
return element(By.buttonText('Start Build'))

getCancelButton: ->
return element(By.buttonText('Cancel'))

getCancelWholeQueue: ->
element(By.buttonText('Cancel Whole Queue'))
return element(By.buttonText('Cancel Whole Queue'))

getStopButton: ->
return element(By.buttonText('Stop'))

module.exports = forcePage
17 changes: 17 additions & 0 deletions smokes/e2e/home.coffee
@@ -0,0 +1,17 @@
# 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 HomePage
#constructor: (@builder)->
constructor: ()->
browser.get('#/')

go: () ->
browser.get('#/')

getPanel: () ->
return element.all(By.css(".panel-title"))

module.exports = HomePage
34 changes: 34 additions & 0 deletions smokes/e2e/home.scenarios.coffee
@@ -0,0 +1,34 @@
# coffee script
# test goal: checks the the number of element present in home page
# to test this part: two different builds need to be started


forcePage = require('./force.coffee')
builderPage = require('./builder.coffee')
homePage = require('./home.coffee')


describe('', () ->
force = null
builder = null
home = null

beforeEach(() ->
builder = new builderPage('runtests', 'force')
force = new forcePage()
home = new homePage()
builder.goDefault()
)

describe 'manage home web page', () ->
it 'should go to the home page and check the different builder', () ->
builderName = {
"0" : "runtests"
}
builder.go()
builder.goForce()
force.getStartButton().click()
home.go()
panel0 = home.getPanel(0)
expect(panel0.getText()).toContain(builderName[0])
)
32 changes: 32 additions & 0 deletions smokes/e2e/rebuilds.scenarios.coffee
@@ -0,0 +1,32 @@
# coffee script
# test goal: checks the capability to navigate in a dedicated build
# to use previous and next link


forcePage = require('./force.coffee')
builderPage = require('./builder.coffee')

describe('', () ->
force = null
builder = null

beforeEach(() ->
builder = new builderPage('runtests', 'force')
force = new forcePage()
builder.goDefault()
)

describe 'rebuild button', () ->
it 'should navigate to a dedicated build and to use the rebuild button', () ->
builder.go()
builder.getLastSuccessBuildNumber().then (lastbuild) ->
builder.goForce()
force.getStartButton().click()
builder.go()
builder.waitNextBuildFinished(lastbuild)
builder.goBuild(lastbuild)
browser.getLocationAbsUrl().then (buildUrl) ->
builder.getRebuildButton().click()
builder.waitGoToBuild(lastbuild+2)

)

0 comments on commit 3abd0ec

Please sign in to comment.