-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e12033
commit e976e8b
Showing
5 changed files
with
133 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,157 @@ | ||
/*global describe,it,expect,$$,element,browser,by*/ | ||
describe('Global filter', function () { | ||
describe('List filter', function () { | ||
'use strict'; | ||
|
||
var hasToLoad = true; | ||
beforeEach(function() { | ||
browser.get(browser.baseUrl + '#/comments/list'); | ||
if (hasToLoad) { | ||
browser.get(browser.baseUrl + '#/comments/list'); | ||
} | ||
hasToLoad = true; | ||
}); | ||
|
||
it('should display filters uppon the listview', function () { | ||
$$('.filters .filter input').then(function (inputs) { | ||
expect(inputs.length).toBe(4); // 2 for text filters, 2 for ui-select filter | ||
|
||
expect(inputs[0].getAttribute('placeholder')).toBe('Global Search'); | ||
expect(inputs[1].getAttribute('placeholder')).toBe('Filter by date'); | ||
describe('layout', function() { | ||
it('should display pinned filters by default in the listview', function() { | ||
$$('.filters .filter input').then(function(inputs) { | ||
expect(inputs.length).toBe(1); // Only text filter is pinned | ||
expect(inputs[0].getAttribute('placeholder')).toBe('Search'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
it('should display a filter button for adding new filters', function() { | ||
return $$('ma-view-actions button').then(function(buttons) { | ||
expect(buttons[0].getText()).toBe(' Add filter'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should filter globally', function () { | ||
// Filter globally for 'rabbit' | ||
$$('.filters .filter:nth-child(1) input').sendKeys('rabbit'); | ||
$$('.filters button[type="submit"]').click(); | ||
$$('.grid tr td:nth-child(4)').then(function (tdElements) { | ||
expect(tdElements.length).toBe(1); | ||
expect(tdElements[0].getText()).toBe('White Rabbit: it was indeed: she was out of the gr...'); | ||
describe('filter button', function() { | ||
it('should display a list of filters when clicked', function() { | ||
element(by.css('ma-filter-button button')).click(); | ||
$$('ma-filter-button ul').then(function(element) { | ||
expect(element[0].getCssValue('display')).toBe('block'); | ||
}); | ||
$$('ma-filter-button ul li').then(function(elements) { | ||
expect(elements.length).toBe(2); | ||
expect(elements[0].getText()).toBe('Posted'); | ||
expect(elements[1].getText()).toBe('Post'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
}); | ||
|
||
it('should update the pagination total', function () { | ||
// Filter globally for 'rabbit' | ||
$$('.filters .filter:nth-child(1) input').sendKeys('rabbit'); | ||
$$('.filters button[type="submit"]').click(); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 1 on 1'); | ||
it('should add a filter when filter name is clicked', function() { | ||
$$('ma-filter-button ul li:nth-child(1) a').click(); | ||
$$('.filters .filter input').then(function(inputs) { | ||
expect(inputs.length).toBe(2); | ||
expect(inputs[1].getAttribute('placeholder')).toBe('Filter by date'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
it('should hide the list of filters once clicked', function() { | ||
$$('ma-filter-button ul').then(function(element) { | ||
expect(element[0].getCssValue('display')).toBe('none'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
it('should reduce the number of filters in the dropdown once clicked', function() { | ||
element(by.css('ma-filter-button button')).click(); | ||
$$('ma-filter-button ul').then(function(element) { | ||
expect(element[0].getCssValue('display')).toBe('block'); | ||
}); | ||
$$('ma-filter-button ul li').then(function(elements) { | ||
expect(elements.length).toBe(1); | ||
expect(elements[0].getText()).toBe('Post'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
it('should disappear if all filters were added', function() { | ||
element(by.css('ma-filter-button ul li:nth-child(1) a')).click(); | ||
$$('.filters .filter input').then(function(inputs) { | ||
expect(inputs.length).toBe(4); // Post is autocomplete, so it has 2 inputs | ||
}); | ||
$$('ma-filter-button ul').then(function(elements) { | ||
expect(elements.length).toBe(0); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
it('should reappear once an unpinned filter is removed', function() { | ||
element(by.css('.filters .filter:nth-child(3) .remove_filter a')).click(); | ||
$$('ma-filter-button ul').then(function(elements) { | ||
expect(elements.length).not.toBe(0); | ||
}); | ||
element(by.css('ma-filter-button button')).click(); | ||
$$('ma-filter-button ul li').then(function(elements) { | ||
expect(elements.length).toBe(1); | ||
expect(elements[0].getText()).toBe('Post'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should reset all filters', function () { | ||
// Filter globally for 'rabbit' | ||
$$('.filters .filter:nth-child(1) input').sendKeys('rabbit'); | ||
$$('.filters button[type="submit"]').click(); | ||
|
||
browser.wait(function () { | ||
return $('.filters > button[type="button"]').isDisplayed().then(function (result) { | ||
return result; | ||
describe('text filter', function() { | ||
it('should filter globally', function () { | ||
// Filter globally for 'rabbit' | ||
$$('.filters .filter:nth-child(1) input').sendKeys('rabbit'); | ||
$$('.grid tr td:nth-child(4)').then(function (tdElements) { | ||
expect(tdElements.length).toBe(1); | ||
expect(tdElements[0].getText()).toBe('White Rabbit: it was indeed: she was out of the gr...'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
$('.filters > button[type="button"]').click(); | ||
|
||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 10 on 11'); | ||
it('should update the pagination total', function () { | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 1 on 1'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
}); | ||
|
||
it('should filter on reference', function () { | ||
// Filter on post_id '3' (Perspiciatis adipisci vero qui ipsam iure porro) | ||
element(by.css('.filters .ui-select-placeholder')).click(); | ||
element(by.css('.filters .ui-select-search')).sendKeys('Perspi'); | ||
element(by.css('#ui-select-choices-row-0-0')).click(); | ||
|
||
$$('.filters button[type="submit"]').click(); | ||
$$('.grid tr td:nth-child(4)').then(function (tdElements) { | ||
expect(tdElements.length).toBe(2); | ||
expect(tdElements[0].getText()).toBe('I\'d been the whiting,\' said the Hatter, it woke up...'); | ||
expect(tdElements[1].getText()).toBe('I\'m not Ada,\' she said, \'and see whether it\'s mark...'); | ||
it('should not filter when empty', function () { | ||
$$('.filters .filter:nth-child(1) input').clear(); | ||
$$('.grid tr td:nth-child(4)').then(function (tdElements) { | ||
expect(tdElements.length).toBe(10); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should update the pagination total', function () { | ||
// Filter on post id '3' (Perspiciatis adipisci vero qui ipsam iure porro) | ||
element(by.css('.filters .ui-select-placeholder')).click(); | ||
element(by.css('.filters .ui-select-search')).sendKeys('Perspi'); | ||
element(by.css('#ui-select-choices-row-0-0')).click(); | ||
describe('reference filter', function() { | ||
it('should filter on reference', function () { | ||
element(by.css('ma-filter-button button')).click(); | ||
$$('ma-filter-button ul li:nth-child(2) a').click(); | ||
// Filter on post_id '3' (Perspiciatis adipisci vero qui ipsam iure porro) | ||
element(by.css('.filters .ui-select-placeholder')).click(); | ||
element(by.css('.filters .ui-select-search')).sendKeys('Perspi'); | ||
element(by.css('#ui-select-choices-row-0-0')).click(); | ||
$$('.grid tr td:nth-child(4)').then(function (tdElements) { | ||
expect(tdElements.length).toBe(2); | ||
expect(tdElements[0].getText()).toBe('I\'d been the whiting,\' said the Hatter, it woke up...'); | ||
expect(tdElements[1].getText()).toBe('I\'m not Ada,\' she said, \'and see whether it\'s mark...'); | ||
}); | ||
hasToLoad = false; | ||
}); | ||
|
||
$$('.filters button[type="submit"]').click(); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 2 on 2'); | ||
it('should update the pagination total', function () { | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 2 on 2'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should reset page number', function () { | ||
// Filter globally for 'I' | ||
$$('.filters .filter:nth-child(1) input').sendKeys('I'); | ||
$$('.filters button[type="submit"]').click(); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 10 on 11'); | ||
}); | ||
$$('ma-datagrid-pagination li:nth-child(3) a').click(); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('11 - 11 on 11'); | ||
}); | ||
// Filter globally for 'be' | ||
$$('.filters .filter:nth-child(1) input').clear(); | ||
$$('.filters .filter:nth-child(1) input').sendKeys('be'); | ||
$$('.filters button[type="submit"]').click(); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 5 on 5'); | ||
describe('interaction with pagination', function() { | ||
it('should reset page number', function () { | ||
// Filter globally for 'I' | ||
$$('.filters .filter:nth-child(1) input').sendKeys('I'); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 10 on 11'); | ||
}); | ||
$$('ma-datagrid-pagination li:nth-child(3) a').click(); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('11 - 11 on 11'); | ||
}); | ||
// Filter globally for 'be' | ||
$$('.filters .filter:nth-child(1) input').clear(); | ||
$$('.filters .filter:nth-child(1) input').sendKeys('be'); | ||
$$('ma-datagrid-pagination .total').then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 5 on 5'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters