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

[RFR] fix back method on batchDeleteController #503

Merged
merged 2 commits into from
Jun 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define(function () {
BatchDeleteController.prototype.back = function () {

this.$state.go(this.$state.get('list'), angular.extend({
entity: this.entity().name()
entity: this.entity.name()
}, this.$state.params));
};

Expand Down
83 changes: 74 additions & 9 deletions src/javascripts/test/e2e/ListViewSpec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*global xdescribe,xit,expect,$$,element,browser,by*/
xdescribe('ListView', function () {
/*global describe,it,expect,$$,element,browser,by*/
describe('ListView', function () {
'use strict';

beforeEach(function () {
browser.get(browser.baseUrl + '#/posts/list');
});

xdescribe('Edition link', function () {
xit('should allow edition of an entity', function () {
describe('Edition link', function () {
it('should allow edition of an entity', function () {
// Retrieve first edit button
$('table tr:nth-child(1) ma-edit-button a').click();

Expand All @@ -18,8 +18,8 @@ xdescribe('ListView', function () {
});
});

xdescribe('Show link', function () {
xit('should allow display of an entity', function () {
describe('Show link', function () {
it('should allow display of an entity', function () {
// Retrieve first edit button
$('table tr:nth-child(1) ma-show-button a').click();

Expand All @@ -30,15 +30,15 @@ xdescribe('ListView', function () {
});
});

xdescribe('ma-list-button', function () {
describe('ma-list-button', function () {
var listUrl;

beforeEach(function() {
listUrl = encodeURI(browser.baseUrl + '/#/comments/list?search={"post_id":"9"}&page=1');
browser.get(listUrl);
});

xit('should restore the list with filter when used from edit', function () {
it('should restore the list with filter when used from edit', function () {
browser.executeScript('window.scrollTo(810, 481)').then(function () {
$$('ma-edit-button a').then(function (elements) {
expect(elements[0].getText()).toBe(' Edit');
Expand All @@ -52,7 +52,7 @@ xdescribe('ListView', function () {
});
});

xit('should restore the list with filter when used from delete', function () {
it('should restore the list with filter when used from delete', function () {
browser.get(listUrl);
browser.executeScript('window.scrollTo(810, 481)').then(function () {

Expand All @@ -73,4 +73,69 @@ xdescribe('ListView', function () {
});
});
});

function selectItemAndGoToBatchDelete() {
return $$('ma-view-batch-actions button')
.then(function (elements) {
expect(elements.length).toBe(0);
return $$('ma-datagrid-item-selector');
})
.then(function (elements) {
// expect(elements.length).toBe(numComments);
elements[0].click();

return $$('ma-view-batch-actions button');
})
.then(function (elements) {
expect(elements.length).toBe(1);
elements[0].click();
return $$('ma-batch-delete-button');
})
.then(function (elements) {
expect(elements.length).toBe(1);
elements[0].click();
expect(browser.getCurrentUrl()).toMatch(browser.baseUrl + '/#/comments/batch-delete/');

return $$('button');
});
}

describe('ma-batch-delete-button', function () {
it('should show the batch delete button only when at least one line is selected', function () {
browser.get('/#/comments/list');
var numComments;
$$('tbody tr').then(function (elements) {
numComments = elements.length;
return selectItemAndGoToBatchDelete();
})
.then(function (elements) {
expect(elements[1].getText()).toBe('No');
elements[1].click();
expect(browser.getCurrentUrl()).toMatch(browser.baseUrl + '/#/comments/list');
return $$('tbody tr');
})
.then(function (elements) {
expect(elements.length).toBe(numComments);
});
});

// @TODO allow to delete item without broking other test
xit('should show the batch delete button only when at least one line is selected', function () {
browser.get('/#/comments/list');
var numComments;
$$('tbody tr').then(function (elements) {
numComments = elements.length;
return selectItemAndGoToBatchDelete();
})
.then(function (elements) {
expect(elements[0].getText()).toBe('Yes');
elements[0].click();
expect(browser.getCurrentUrl()).toMatch(browser.baseUrl + '/#/comments/list');
return $$('tbody tr');
})
.then(function (elements) {
expect(elements.length).toBe(numComments - 1);
});
});
});
});