diff --git a/integration-test-conf.js b/integration-test-conf.js index 1d037acf..d6013ba8 100644 --- a/integration-test-conf.js +++ b/integration-test-conf.js @@ -1,3 +1,7 @@ +require("babel/register")({ + stage: 1 +}); + var utils = require('./integration/utils'); exports.config = { diff --git a/integration/auth/auth.integrationSpec.js b/integration/auth/auth.integrationSpec.js index 161b2048..59082059 100644 --- a/integration/auth/auth.integrationSpec.js +++ b/integration/auth/auth.integrationSpec.js @@ -7,34 +7,34 @@ chai.use(chaiAsPromised); var expect = chai.expect; describe('auth', function() { - it('login', function() { + it('login', async function() { browser.get('http://localhost:9001/login'); - return utils.common.waitLoader().then(function() { - utils.common.takeScreenshot("auth", "login"); + await utils.common.waitLoader(); - var username = $('input[name="username"]'); - username.sendKeys('admin'); + utils.common.takeScreenshot("auth", "login"); - var password = $('input[name="password"]'); - password.sendKeys('123123'); + var username = $('input[name="username"]'); + username.sendKeys('admin'); - $('.submit-button').click(); + var password = $('input[name="password"]'); + password.sendKeys('123123'); - return expect(browser.getCurrentUrl()).to.be.eventually.equal('http://localhost:9001/'); - }); + $('.submit-button').click(); + + expect(browser.getCurrentUrl()).to.be.eventually.equal('http://localhost:9001/'); }); describe("user", function() { var user = {}; describe("register", function() { - it('screenshot', function() { + it('screenshot', async function() { browser.get('http://localhost:9001/register'); - utils.common.waitLoader().then(function() { - utils.common.takeScreenshot("auth", "register"); - }); + await utils.common.waitLoader(); + + utils.common.takeScreenshot("auth", "register"); }); it('register validation', function() { @@ -44,7 +44,7 @@ describe('auth', function() { utils.common.takeScreenshot("auth", "register-validation"); - return expect($$('.checksley-required').count()).to.be.eventually.equal(4); + expect($$('.checksley-required').count()).to.be.eventually.equal(4); }); it('register ok', function() { @@ -62,16 +62,15 @@ describe('auth', function() { $('.submit-button').click(); - return expect(browser.getCurrentUrl()).to.be.eventually.equal('http://localhost:9001/'); + expect(browser.getCurrentUrl()).to.be.eventually.equal('http://localhost:9001/'); }); }); describe("change password", function() { - beforeEach(function(done) { - utils.common.login(user.username, user.password).then(function() { - browser.get('http://localhost:9001/user-settings/user-change-password'); - done(); - }); + beforeEach(async function() { + await utils.common.login(user.username, user.password); + + browser.get('http://localhost:9001/user-settings/user-change-password'); }); it("error", function() { @@ -81,7 +80,7 @@ describe('auth', function() { $('.submit-button').click(); - return expect(utils.notifications.error.open()).to.be.eventually.equal(true); + expect(utils.notifications.error.open()).to.be.eventually.equal(true); }); it("success", function() { @@ -91,7 +90,7 @@ describe('auth', function() { $('.submit-button').click(); - return expect(utils.notifications.success.open()).to.be.eventually.equal(true); + expect(utils.notifications.success.open()).to.be.eventually.equal(true); }); }); @@ -100,61 +99,57 @@ describe('auth', function() { browser.get('http://localhost:9001/forgot-password'); }); - it ("screenshot", function() { - utils.common.waitLoader().then(function() { - utils.common.takeScreenshot("auth", "remember-password"); - }); + it ("screenshot", async function() { + await utils.common.waitLoader(); + + utils.common.takeScreenshot("auth", "remember-password"); }); it ("error", function() { $('input[name="username"]').sendKeys("xxxxxxxx"); $('.submit-button').click(); - return expect(utils.notifications.errorLight.open()).to.be.eventually.equal(true); + expect(utils.notifications.errorLight.open()).to.be.eventually.equal(true); }); - it ("success", function() { + it ("success", async function() { $('input[name="username"]').sendKeys(user.username); $('.submit-button').click(); - return utils.lightbox.open('.lightbox-generic-success').then(function() { - utils.common.takeScreenshot('auth', 'remember-password-success'); + await utils.lightbox.open('.lightbox-generic-success'); - $('.lightbox-generic-success .button-green').click(); + utils.common.takeScreenshot('auth', 'remember-password-success'); - return expect(utils.lightbox.close('.lightbox-generic-success')).to.be.eventually.equal(true); - }); + $('.lightbox-generic-success .button-green').click(); + + expect(utils.lightbox.close('.lightbox-generic-success')).to.be.eventually.equal(true); }); }); describe("", function() { - it("logout", function() { - return utils.common.login(user.username, user.password) - .then(function() { - browser.actions().mouseMove($('div[tg-dropdown-user]')).perform(); - $$('.dropdown-user li a').last().click(); + it("logout", async function() { + await utils.common.login(user.username, user.password); - return expect(browser.getCurrentUrl()).to.be.eventually.equal('http://localhost:9001/login'); - }) + browser.actions().mouseMove($('div[tg-dropdown-user]')).perform(); + $$('.dropdown-user li a').last().click(); + + expect(browser.getCurrentUrl()).to.be.eventually.equal('http://localhost:9001/login'); }); - it("delete account", function() { - return utils.common.login(user.username, user.password) - .then(function() { - browser.get('http://localhost:9001/user-settings/user-profile'); - $('.delete-account').click(); + it("delete account", async function() { + await utils.common.login(user.username, user.password); - return utils.lightbox.open('.lightbox-delete-account'); - }) - .then(function() { - utils.common.takeScreenshot("auth", "delete-account"); + browser.get('http://localhost:9001/user-settings/user-profile'); + $('.delete-account').click(); - $('#unsuscribe').click(); - $('.lightbox-delete-account .button-green').click(); + await utils.lightbox.open('.lightbox-delete-account'); - return expect(browser.getCurrentUrl()) - .to.be.eventually.equal('http://localhost:9001/login'); - }); + utils.common.takeScreenshot("auth", "delete-account"); + + $('#unsuscribe').click(); + $('.lightbox-delete-account .button-green').click(); + + expect(browser.getCurrentUrl()).to.be.eventually.equal('http://localhost:9001/login'); }); }); }); diff --git a/integration/full/backlog.integrationSpec.js b/integration/full/backlog.integrationSpec.js new file mode 100644 index 00000000..4ebdef1f --- /dev/null +++ b/integration/full/backlog.integrationSpec.js @@ -0,0 +1,25 @@ +var utils = require('../utils'); + +var chai = require('chai'); +var chaiAsPromised = require('chai-as-promised'); + +chai.use(chaiAsPromised); +var expect = chai.expect; + +describe.skip('backlog', function() { + before(function(){ + browser.get('http://localhost:9001/project/user7-project-example-0/'); + + return utils.common.waitLoader().then(function() { + return utils.common.takeScreenshot('backlog', 'backlog'); + }); + }); + + it('create US', function() { + $('.new-us a').click(); + + lightbox.open('div[tg-lb-create-edit-userstory]').then(function() { + + }); + }); +}); diff --git a/integration/full/home.integrationSpec.js b/integration/full/home.integrationSpec.js index 16f59217..ea7b4911 100644 --- a/integration/full/home.integrationSpec.js +++ b/integration/full/home.integrationSpec.js @@ -7,12 +7,11 @@ chai.use(chaiAsPromised); var expect = chai.expect; describe('home', function() { - before(function(){ + before(async function(){ browser.get('http://localhost:9001/'); - return utils.common.waitLoader().then(function() { - return utils.common.takeScreenshot("home", "dashboard"); - }); + await utils.common.waitLoader(); + utils.common.takeScreenshot("home", "dashboard"); }); it('working on filled', function() { @@ -28,12 +27,11 @@ describe('home', function() { }); describe('projects list', function() { - before(function() { + before(async function() { browser.get('http://localhost:9001/projects/'); - return utils.common.waitLoader().then(function() { - return utils.common.takeScreenshot("home", "projects"); - }); + await utils.common.waitLoader(); + utils.common.takeScreenshot("home", "projects"); }); it('open create project lightbox', function() { @@ -52,22 +50,19 @@ describe('home', function() { describe("project drag and drop", function() { var draggedElementText; - before(function() { + before(async function() { browser.get('http://localhost:9001/projects/'); - var dragableElements = element.all(by.css('.project-list-single')); - var dragElement = dragableElements.get(3); - var dragElementLink = dragElement.element(by.css('a')); + let dragableElements = element.all(by.css('.project-list-single')); + let dragElement = dragableElements.get(3); + let dragElementLink = dragElement.element(by.css('a')); - return utils.common.waitLoader() - .then(function() { - return dragElementLink.getText() - }) - .then(function(_draggedElementText_) { - draggedElementText = _draggedElementText_; + await utils.common.waitLoader(); - return utils.common.drag(dragElement, dragableElements.get(0)) - }); + draggedElementText = await dragElementLink.getText(); + + await utils.common.drag(dragElement, dragableElements.get(0)); + await browser.waitForAngular(); }); it('projects list has the new order', function() { @@ -81,5 +76,6 @@ describe('home', function() { expect(firstElementText).to.be.eventually.equal(draggedElementText); }); + }); }); diff --git a/integration/full/project-home.integrationSpec.js b/integration/full/project-home.integrationSpec.js index 8e253d21..b19cdf62 100644 --- a/integration/full/project-home.integrationSpec.js +++ b/integration/full/project-home.integrationSpec.js @@ -7,12 +7,11 @@ chai.use(chaiAsPromised); var expect = chai.expect; describe('project home', function() { - before(function(){ + before(async function(){ browser.get('http://localhost:9001/'); - return utils.common.waitLoader().then(function() { - return utils.common.takeScreenshot("project", "home"); - }); + await utils.common.waitLoader(); + await utils.common.takeScreenshot("project", "home"); }); it('go to project', function() { @@ -24,26 +23,17 @@ describe('project home', function() { return expect($$('div[tg-user-timeline-item]').count()).to.be.eventually.above(0); }); - it('timeline pagination', function(done) { - $$('div[tg-user-timeline-item]') - .count() - .then(function(startTotal) { - return browser.executeScript('window.scrollTo(0,document.body.scrollHeight)') - .then(function() { - return browser.waitForAngular(); - }) - .then(function() { - return $$('div[tg-user-timeline-item]').count(); - }) - .then(function(endTotal) { - return startTotal < endTotal; - }); - }) - .then(function(hasMoreItems) { - expect(hasMoreItems).to.be.equal(true); + it('timeline pagination', async function() { + let startTotal = await $$('div[tg-user-timeline-item]').count(); - done(); - }); + await browser.executeScript('window.scrollTo(0,document.body.scrollHeight)'); + await browser.waitForAngular(); + + let endTotal = await $$('div[tg-user-timeline-item]').count(); + + let hasMoreItems = startTotal < endTotal; + + expect(hasMoreItems).to.be.equal(true); }); it('team filled', function() { diff --git a/integration/utils/common.js b/integration/utils/common.js index 7695ee71..575aa450 100644 --- a/integration/utils/common.js +++ b/integration/utils/common.js @@ -2,41 +2,41 @@ var common = module.exports; var fs = require('fs'); -common.hasClass = function (element, cls) { - return element.getAttribute('class').then(function (classes) { - return classes.split(' ').indexOf(cls) !== -1; - }); +common.hasClass = async function (element, cls) { + let classes = await element.getAttribute('class'); + + return classes.split(' ').indexOf(cls) !== -1; }; common.waitLoader = function () { - var el = $(".loader"); + let el = $(".loader"); - return browser.wait(function() { - return common.hasClass(el, 'active').then(function(active) { - return !active; - }); + return browser.wait(async function() { + let active = await common.hasClass(el, 'active'); + + return !active; }, 5000); }; -common.takeScreenshot = function (section, filename) { - var screenshotsFolder = __dirname + "/../screenshots/"; - var dir = screenshotsFolder + section + "/"; +common.takeScreenshot = async function (section, filename) { + let screenshotsFolder = __dirname + "/../screenshots/"; + let dir = screenshotsFolder + section + "/"; if (!fs.existsSync(screenshotsFolder)) { fs.mkdirSync(screenshotsFolder); } - return browser.takeScreenshot().then(function (data) { - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } + let data = await browser.takeScreenshot(); - var path = dir + filename + ".png"; - var stream = fs.createWriteStream(path); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } - stream.write(new Buffer(data, 'base64')); - stream.end(); - }); + let path = dir + filename + ".png"; + let stream = fs.createWriteStream(path); + + stream.write(new Buffer(data, 'base64')); + stream.end(); }; common.closeCookies = function() { @@ -45,16 +45,6 @@ common.closeCookies = function() { }); }; -// common.waitLoad = function() { -// var deferred = protractor.promise.defer(); - -// common.waitLoader().then(function() { -// deferred.fulfill(); -// }); - -// return deferred.promise; -// }; - common.login = function(username, password) { browser.get('http://localhost:9001/login'); @@ -63,10 +53,10 @@ common.login = function(username, password) { $('.submit-button').click(); - return browser.driver.wait(function() { - return browser.driver.getCurrentUrl().then(function(url) { - return url === 'http://localhost:9001/'; - }); + return browser.driver.wait(async function() { + let url = await browser.driver.getCurrentUrl(); + + return url === 'http://localhost:9001/'; }, 10000); }; @@ -77,11 +67,10 @@ common.prepare = function() { } common.dragEnd = function(elm) { - return browser.wait(function() { - return element.all(by.css('.ui-sortable-helper')).count() - .then(function(count) { - return count === 0; - }); + return browser.wait(async function() { + let count = await element.all(by.css('.ui-sortable-helper')).count() + + return count === 0; }, 1000); }; diff --git a/integration/utils/lightbox.js b/integration/utils/lightbox.js index 10c9ccba..df5d0e82 100644 --- a/integration/utils/lightbox.js +++ b/integration/utils/lightbox.js @@ -3,22 +3,20 @@ var common = require('./common') var lightbox = module.exports; var transition = 300; -lightbox.open = function(el) { +lightbox.open = async function(el) { var deferred = protractor.promise.defer(); - browser - .wait(function() { - return common.hasClass($(el), 'open') - }, 2000) - .then(function(open) { - return browser.sleep(transition).then(function() { - if (open) { - deferred.fulfill(true); - } else { - deferred.reject(new Error('Lightbox doesn\'t open')); - } - }); - }); + let open = await browser.wait(function() { + return common.hasClass($(el), 'open') + }, 2000); + + await browser.sleep(transition); + + if (open) { + deferred.fulfill(true); + } else { + deferred.reject(new Error('Lightbox doesn\'t open')); + } return deferred.promise; }; diff --git a/package.json b/package.json index 6b518ffd..5280d7b9 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "devDependencies": { "angular-mocks": "^1.3.15", + "babel": "^5.6.5", "chai": "^2.2.0", "chai-as-promised": "^5.1.0", "chai-jquery": "^2.0.0",