From 661e94563de60ed968f481fcc9889958fac09c9f Mon Sep 17 00:00:00 2001 From: desurd Date: Fri, 6 Jan 2017 16:57:43 +0100 Subject: [PATCH] Add new tests for the home web page, for the navigations inside of a build reference (previous, next functions), for the rebuild function Signed-off-by: desurd --- smokes/e2e/builder.coffee | 42 +++++++++++-- smokes/e2e/buildsnavigation.scenarios.coffee | 62 ++++++++++++++++++++ smokes/e2e/force.coffee | 7 ++- smokes/e2e/home.coffee | 17 ++++++ smokes/e2e/home.scenarios.coffee | 34 +++++++++++ smokes/e2e/rebuilds.scenarios.coffee | 32 ++++++++++ 6 files changed, 186 insertions(+), 8 deletions(-) create mode 100644 smokes/e2e/buildsnavigation.scenarios.coffee create mode 100644 smokes/e2e/home.coffee create mode 100644 smokes/e2e/home.scenarios.coffee create mode 100644 smokes/e2e/rebuilds.scenarios.coffee diff --git a/smokes/e2e/builder.coffee b/smokes/e2e/builder.coffee index 75564b9312b..ca668a588a7 100644 --- a/smokes/e2e/builder.coffee +++ b/smokes/e2e/builder.coffee @@ -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 diff --git a/smokes/e2e/buildsnavigation.scenarios.coffee b/smokes/e2e/buildsnavigation.scenarios.coffee new file mode 100644 index 00000000000..c6c3380a497 --- /dev/null +++ b/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() +) diff --git a/smokes/e2e/force.coffee b/smokes/e2e/force.coffee index cdf75106e3b..459e2a8bd1d 100644 --- a/smokes/e2e/force.coffee +++ b/smokes/e2e/force.coffee @@ -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 diff --git a/smokes/e2e/home.coffee b/smokes/e2e/home.coffee new file mode 100644 index 00000000000..804286a2705 --- /dev/null +++ b/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 diff --git a/smokes/e2e/home.scenarios.coffee b/smokes/e2e/home.scenarios.coffee new file mode 100644 index 00000000000..80b61c981cb --- /dev/null +++ b/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]) +) diff --git a/smokes/e2e/rebuilds.scenarios.coffee b/smokes/e2e/rebuilds.scenarios.coffee new file mode 100644 index 00000000000..04116d150e3 --- /dev/null +++ b/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) + +)