From e9a73af645a6a68eaf738d1c016d66d4c0d6a4ff Mon Sep 17 00:00:00 2001 From: Jonathan Petitcolas Date: Mon, 14 Sep 2015 15:39:21 +0200 Subject: [PATCH] Fix tests --- .../ng-admin/Crud/delete/DeleteController.js | 8 ++++++-- src/javascripts/test/e2e/ListViewSpec.js | 20 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/javascripts/ng-admin/Crud/delete/DeleteController.js b/src/javascripts/ng-admin/Crud/delete/DeleteController.js index a9e2781d..bb22dc29 100644 --- a/src/javascripts/ng-admin/Crud/delete/DeleteController.js +++ b/src/javascripts/ng-admin/Crud/delete/DeleteController.js @@ -22,7 +22,7 @@ define(function () { $scope.$on('$destroy', this.destroy.bind(this)); this.previousStateParametersDeferred = $q.defer(); - $scope.$once('$stateChangeSuccess', (event, to, toParams, from, fromParams) => { + $scope.$on('$stateChangeSuccess', (event, to, toParams, from, fromParams) => { this.previousStateParametersDeferred.resolve(fromParams); }); }; @@ -41,7 +41,7 @@ define(function () { entity: entityName }, this.$state.params)); } else { - this.$window.history.back(); + this.back(); } notification.log('Element successfully deleted.', { addnCls: 'humane-flatty-success' }); @@ -59,6 +59,10 @@ define(function () { ); }; + DeleteController.prototype.back = function() { + this.$window.history.back(); + }; + DeleteController.prototype.destroy = function () { this.$scope = undefined; this.WriteQueries = undefined; diff --git a/src/javascripts/test/e2e/ListViewSpec.js b/src/javascripts/test/e2e/ListViewSpec.js index d5a00598..15c67bb5 100644 --- a/src/javascripts/test/e2e/ListViewSpec.js +++ b/src/javascripts/test/e2e/ListViewSpec.js @@ -1,4 +1,4 @@ -/*global describe,it,expect,$$,element,browser,by*/ +/*global describe,it,expect,$,$$,element,browser,by*/ describe('ListView', function () { 'use strict'; @@ -54,7 +54,23 @@ describe('ListView', function () { }); }); - it('should restore the list with filter when used from delete', function () { + it('should restore the list with filter after delete confirmation', function () { + browser.executeScript('window.scrollTo(810, 481)').then(function () { + return $$('ma-delete-button a'); + }).then(function (elements) { + expect(elements[0].getText()).toBe(' Delete'); + return elements[0].click(); + }).then(function() { + expect(browser.getCurrentUrl()).toBe(browser.baseUrl + '/#/comments/delete/2'); + return $$('button.btn-danger'); + }).then(function (elements) { + return elements[0].click(); + }).then(function() { + expect(browser.getCurrentUrl()).toBe(listUrl); + }); + }); + + it('should restore the list with filter after delete cancel', function () { browser.executeScript('window.scrollTo(810, 481)').then(function () { return $$('ma-delete-button a'); }).then(function (elements) {