Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the smoke tests for reason form #2448

Merged
merged 1 commit into from
Dec 8, 2016
Merged

Conversation

desurd
Copy link
Contributor

@desurd desurd commented Oct 13, 2016

using protractor as test tools

@mention-bot
Copy link

@desurd, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tardyp to be a potential reviewer.

browser.waitForAngular()
element(By.buttonText('Start Build')).click()
browser.get('#/builders/1')
reasonForce.getLink('1/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This api name is not clear to me.

goToURL might be clearer

browser.get('#/builders/1')
reasonForce.getLink('1/')
reasonForce.getLink('1/force/force')
reasonForce.getStart()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getStart is not clear to me.

clickStartButton() would be more meaningful.

actually, what would be better is to say

forcePage.getStartButton().click()


describe('', () ->
beforeEach(() ->
reasonForce = new forceSchedulerPage()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forcePage = new forceSchedulerPage()
forcePage.go()

describe 'force', () ->
it 'should create a build', () ->
browser.get('#/builders/1')
reasonForce = new forceSchedulerPage()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forcePage = new forceSchedulerPage(builderid:1, forceschedulername: 'force')

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')
reasonForce.getWaterfall()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waterfallPage = new WaterfallPage()
waterfallPage.go()

#return @

getLink: (link) ->
browser.get('#/builders/'+ link)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded

@@ -0,0 +1,88 @@
# this file will contains the different generic functions which
# will be called by the different tests
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to add that this is inspired by this methodology

http://www.lindstromhenrik.com/using-protractor-with-coffeescript/

Copy link
Member

@tardyp tardyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts. Its much better, but there are still some improvments


lastbuild = element.all(By.css('span.badge-status.results_SUCCESS')).count();
forcePage.goToURL('#/builders/1/');
forcePage.goToURL('#/builders/1/force/force');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goToURL is better. but actually I think it is better to hardcode the URL in the page classes.
So that would be

forcePage.go()

without the need to first go to the builders page


describe('', () ->
beforeEach(() ->
forcePage = new forceSchedulerPage();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is the need to parametrise the page

    forcePage =  new forceSchedulerPage(builder:1, schedulername: 'force');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be manage in a second time

forcePage = null;
waterfallPage = null;

describe('', () ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will not need that describe, but rather put the beforeEach into the describe 'force' test

forceSchedulerPage = require('./reason_force.coffee')
waterFallPage = require('./waterfall.coffee')

forcePage = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put those variables inside the describe scope




describe 'force', () ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you dont need that second level of describe. Only one level is needed

element.all(By.css('span.badge-status.results_SUCCESS'));
.count().then (nextbuild)->
return +nextbuild == +lastbuild + 1;
browser.wait(successBuildIncrease, 20000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole wait loop might abstracted inside the builderpage.

builderPage.waitNextBuildFinished(lastbuild)

goToURL: (link) ->
browser.get(link);

clickOnStartButton: ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those 3 functions are getters, so they need to be called e.g. getStartButton

forcePage.writeAndCheckBranchName("Gerrit Branch");
forcePage.writeAndCheckRepo("http//name.com");
forcePage.writeAndCheckRevisionName("12345");
forcePage.clickOnCancelButton().click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should make sure this did not create a build?
make sure it goes back to the builder page?

constructor: ->
browser.get('#/waterfall');

goToWaterfall: ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go is enough. as it is supposed to be called as

waterfallPage.go()

return +nextbuild == +lastbuild + 1;
browser.wait(successBuildIncrease, 20000);
waterfallPage.goToWaterfall();
expect(element.all(By.css('rect.success')).count()).toBeGreaterThan(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we should read:

expect(waterfallPage.countSuccess()).toBeGreaterThan(0)

@codecov-io
Copy link

codecov-io commented Oct 26, 2016

Current coverage is 86.75% (diff: 100%)

No coverage report found for master at 5f980ec.

Powered by Codecov. Last update 5f980ec...fcd8791

@desurd
Copy link
Contributor Author

desurd commented Nov 21, 2016

task is on going
some evolutions have been requested by Tardyp to have a solid & correct base before to add any new tests

# inspired by this methodology
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/

class builderSchedulerPage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BuilderPage ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BuilderPage ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new patchset on going


go: () ->
builderID = @builderID
browser.get('#/builders/#{builderID}/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify by saying:

    browser.get('#/builders/#{@builderID}/')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new patchset on going

goForce: (forcename) ->
builderID = @builderID
forceName=@forceName
browser.get("#/builders/#{builderID}/force/#{forceName}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem


class waterfallPage
constructor: ->
browser.get('#/waterfall');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont go to waterfall when you instanciate the class

c['change_source'] = []
c['change_source'].append(changes.GitPoller(
'https://github.com/buildbot/pyflakes.git',
'git://github.com/buildbot/pyflakes.git',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep http as this is easier to go through the proxy

# run the tests (note that this will require that 'trial' is installed)
factory.addStep(steps.ShellCommand(command=["trial", "pyflakes"]))


#slowfactory = util.BuildFactory()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please no commented code

@@ -2,7 +2,7 @@ exports.config = {
allScriptsTimeout: 11000,

specs: [
'e2e/*.scenarios.coffee'
'e2e/force.scenarios.coffee'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep *.scenarios

@desurd desurd force-pushed the mysmokes branch 4 times, most recently from 9293162 to 0276633 Compare December 5, 2016 15:37
it 'should create a build', () ->
builder.go()
builder.getBuildCount().then (lastbuild) ->
#forcePage = builderPage.goForce()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove comment

}[builder]
@forceName=forcename

#@loglink = element(By.id('logLink'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code


class forcePage
constructor: ->
#@loglink = element(By.id('logLink'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

expect(reasonElement.getAttribute('value')).toBe(reason)

setYourName: (yourName) ->
reasonElement = element(By.css("forcefield label[for='username'] + div input"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not anymore the reasonElement. call it element in all the methods, and this will be fine

reasonElement.sendKeys(projectName)
expect(reasonElement.getAttribute('value')).toBe(projectName)

setBranchName: (branchName) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could factorize this code. the last four lines are the same for every methods

@desurd desurd force-pushed the mysmokes branch 2 times, most recently from b67683d to ec73486 Compare December 7, 2016 15:24
using protractor as test tools

Signed-off-by: David Desurmont <david.desurmont@gmail.com>
Signed-off-by: desurd <david.desurmont@gmail.com>
@tardyp tardyp closed this Dec 7, 2016
@tardyp tardyp reopened this Dec 7, 2016
@tardyp tardyp merged commit c86127c into buildbot:master Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants