diff --git a/app/modules/projects/components/sort-projects.directive.coffee b/app/modules/projects/components/sort-projects.directive.coffee index b25d4573..476e0db9 100644 --- a/app/modules/projects/components/sort-projects.directive.coffee +++ b/app/modules/projects/components/sort-projects.directive.coffee @@ -8,7 +8,7 @@ SortProjectsDirective = (currentUserService) -> axis: "y" opacity: .95 placeholder: 'placeholder' - cancel: '.project-name' + cancel: '.project-name' }) el.on "sortstop", (event, ui) -> diff --git a/integration/full/home.integrationSpec.js b/integration/full/home.integrationSpec.js index bc2c0716..16f59217 100644 --- a/integration/full/home.integrationSpec.js +++ b/integration/full/home.integrationSpec.js @@ -7,5 +7,79 @@ chai.use(chaiAsPromised); var expect = chai.expect; describe('home', function() { + before(function(){ + browser.get('http://localhost:9001/'); + return utils.common.waitLoader().then(function() { + return utils.common.takeScreenshot("home", "dashboard"); + }); + }); + + it('working on filled', function() { + return expect($$('.working-on div[tg-duty]').count()).to.be.eventually.above(0); + }); + + it('watching filled', function() { + return expect($$('.watching div[tg-duty]').count()).to.be.eventually.above(0); + }); + + it('project list filled', function() { + return expect($$('.home-project-list-single').count()).to.be.eventually.above(0); + }); + + describe('projects list', function() { + before(function() { + browser.get('http://localhost:9001/projects/'); + + return utils.common.waitLoader().then(function() { + return utils.common.takeScreenshot("home", "projects"); + }); + }); + + it('open create project lightbox', function() { + $('.master .create-project-btn').click(); + + return expect(utils.lightbox.open('div[tg-lb-create-project]')).to.be.eventually.equal(true); + }); + + it('close create project lightbox', function() { + $('div[tg-lb-create-project] .icon-delete').click(); + + return expect(utils.lightbox.close('div[tg-lb-create-project]')).to.be.eventually.equal(true); + }); + }); + + describe("project drag and drop", function() { + var draggedElementText; + + before(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')); + + return utils.common.waitLoader() + .then(function() { + return dragElementLink.getText() + }) + .then(function(_draggedElementText_) { + draggedElementText = _draggedElementText_; + + return utils.common.drag(dragElement, dragableElements.get(0)) + }); + }); + + it('projects list has the new order', function() { + var firstElement = $$('.project-list-single a').first().getText(); + + expect(firstElement).to.be.eventually.equal(draggedElementText); + }); + + it('projects menu has the new order', function() { + var firstElementText = $$('div[tg-dropdown-project-list] ul a').first().getInnerHtml(); + + expect(firstElementText).to.be.eventually.equal(draggedElementText); + }); + }); }); diff --git a/integration/utils/common.js b/integration/utils/common.js index fd9bed66..7695ee71 100644 --- a/integration/utils/common.js +++ b/integration/utils/common.js @@ -75,3 +75,22 @@ common.prepare = function() { return common.closeCookies() } + +common.dragEnd = function(elm) { + return browser.wait(function() { + return element.all(by.css('.ui-sortable-helper')).count() + .then(function(count) { + return count === 0; + }); + }, 1000); +}; + +common.drag = function(elm, location) { + return browser + .actions() + .dragAndDrop(elm, location) + .perform() + .then(function() { + return common.dragEnd(); + }) +}; diff --git a/integration/utils/lightbox.js b/integration/utils/lightbox.js index 949d3660..10c9ccba 100644 --- a/integration/utils/lightbox.js +++ b/integration/utils/lightbox.js @@ -6,18 +6,14 @@ var transition = 300; lightbox.open = function(el) { var deferred = protractor.promise.defer(); - if (typeof el == 'string' || el instanceof String) { - el = $(el); - } - browser .wait(function() { - return common.hasClass(el, 'open') + return common.hasClass($(el), 'open') }, 2000) .then(function(open) { return browser.sleep(transition).then(function() { if (open) { - deferred.fulfill(open); + deferred.fulfill(true); } else { deferred.reject(new Error('Lightbox doesn\'t open')); } @@ -28,13 +24,24 @@ lightbox.open = function(el) { }; lightbox.close = function(el) { - if (typeof el == 'string' || el instanceof String) { - el = $(el); - } + var deferred = protractor.promise.defer(); - return browser.wait(function() { - return common.hasClass(el, 'open').then(function(open) { - return !open; - }); - }, 2000); + $(el).isPresent().then(function(present) { + if (!present) { + deferred.fulfill(true); + } else { + return browser.wait(function() { + return common.hasClass($(el), 'open').then(function(open) { + return !open; + }); + }, 2000) + .then(function() { + return deferred.fulfill(true); + }, function() { + deferred.reject(new Error('Lightbox doesn\'t close')); + }); + } + }) + + return deferred.promise; };