Skip to content

Commit

Permalink
[ACA-2222] add e2e tests for pagination on Favorite Libraries (Alfres…
Browse files Browse the repository at this point in the history
…co#969)

* add tests for pagination on Favorite Libraries

* add TestRail ids
add tests for pagination for empty page and single page

* Delete package-lock.json

* Revert "Delete package-lock.json"

This reverts commit 41eba0c.

* restore package-lock
  • Loading branch information
adinapitul authored and dhrn committed Apr 30, 2019
1 parent afc2953 commit f3e8d09
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 97 deletions.
14 changes: 12 additions & 2 deletions e2e/suites/list-views/empty-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,18 @@ describe('Empty list views', () => {
expect(await pagination.isNextButtonPresent()).toBe(false, 'Next button is present');
});

it('File Libraries - pagination controls not displayed - [C280084]', async () => {
await page.clickFileLibraries();
it('My Libraries - pagination controls not displayed - [C280084]', async () => {
await page.goToMyLibraries();
expect(await pagination.isRangePresent()).toBe(false, 'Range is present');
expect(await pagination.isMaxItemsPresent()).toBe(false, 'Max items is present');
expect(await pagination.isCurrentPagePresent()).toBe(false, 'Current page is present');
expect(await pagination.isTotalPagesPresent()).toBe(false, 'Total pages is present');
expect(await pagination.isPreviousButtonPresent()).toBe(false, 'Previous button is present');
expect(await pagination.isNextButtonPresent()).toBe(false, 'Next button is present');
});

it('Favorite Libraries - pagination controls not displayed - [C291873]', async () => {
await page.goToFavoriteLibraries();
expect(await pagination.isRangePresent()).toBe(false, 'Range is present');
expect(await pagination.isMaxItemsPresent()).toBe(false, 'Max items is present');
expect(await pagination.isCurrentPagePresent()).toBe(false, 'Current page is present');
Expand Down
292 changes: 199 additions & 93 deletions e2e/suites/pagination/pag-file-libraries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';

describe('Pagination on multiple pages on File Libraries', () => {
describe('Pagination on multiple pages', () => {
const username = `user-${Utils.random()}`;

const apis = {
Expand All @@ -51,109 +51,215 @@ describe('Pagination on multiple pages on File Libraries', () => {
done();
});

beforeEach(async (done) => {
await page.goToMyLibrariesAndWait();
done();
});

afterEach(async (done) => {
await Utils.pressEscape();
done();
});

afterAll(async (done) => {
await apis.user.sites.deleteSites(sites);
done();
})

it('Pagination control default values - [C280086]', async () => {
expect(await pagination.getRange()).toContain('1-25 of 101');
expect(await pagination.getMaxItems()).toContain('25');
expect(await pagination.getCurrentPage()).toContain('Page 1');
expect(await pagination.getTotalPages()).toContain('of 5');
expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.isNextEnabled()).toBe(true, 'Next button is not enabled');
});
describe('on My Libraries', () => {
beforeEach(async (done) => {
await page.goToMyLibrariesAndWait();
done();
});

it('Items per page values - [C280087]', async () => {
await pagination.openMaxItemsMenu();
const [ first, second, third ] = [1, 2, 3]
.map(async nth => await pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
await pagination.menu.closeMenu();
});
afterEach(async (done) => {
await Utils.pressEscape();
done();
});

it('current page menu items - [C280088]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getMaxItems()).toContain('25');
expect(await pagination.getTotalPages()).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();

await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getMaxItems()).toContain('50');
expect(await pagination.getTotalPages()).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();

await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getMaxItems()).toContain('100');
expect(await pagination.getTotalPages()).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();

await pagination.resetToDefaultPageSize();
});
it('Pagination control default values - [C280086]', async () => {
expect(await pagination.getRange()).toContain('1-25 of 101');
expect(await pagination.getMaxItems()).toContain('25');
expect(await pagination.getCurrentPage()).toContain('Page 1');
expect(await pagination.getTotalPages()).toContain('of 5');
expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.isNextEnabled()).toBe(true, 'Next button is not enabled');
});

it('change the current page from menu - [C280089]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('51-75 of 101');
expect(await pagination.getCurrentPage()).toContain('Page 3');
expect(await pagination.isPreviousEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.isNextEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.isItemPresent('site-60')).toBe(true, 'Site-60 not found on page');

await pagination.resetToDefaultPageNumber();
});
it('Items per page values - [C280087]', async () => {
await pagination.openMaxItemsMenu();
const [ first, second, third ] = [1, 2, 3]
.map(async nth => await pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
await pagination.menu.closeMenu();
});

it('navigate to next and previous pages - [C280092]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('site-31')).toBe(true, 'Site-31 not found on page');
await pagination.resetToDefaultPageNumber();

await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.clickPrevious();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('1-25 of 101');
expect(await dataTable.isItemPresent('site-12')).toBe(true, 'Site-12 not found on page');

await pagination.resetToDefaultPageNumber();
});
it('current page menu items - [C280088]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getMaxItems()).toContain('25');
expect(await pagination.getTotalPages()).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();

await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getMaxItems()).toContain('50');
expect(await pagination.getTotalPages()).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();

await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getMaxItems()).toContain('100');
expect(await pagination.getTotalPages()).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();

await pagination.resetToDefaultPageSize();
});

it('change the current page from menu - [C280089]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('51-75 of 101');
expect(await pagination.getCurrentPage()).toContain('Page 3');
expect(await pagination.isPreviousEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.isNextEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.isItemPresent('site-60')).toBe(true, 'Site-60 not found on page');

await pagination.resetToDefaultPageNumber();
});

it('navigate to next and previous pages - [C280092]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('site-31')).toBe(true, 'Site-31 not found on page');
await pagination.resetToDefaultPageNumber();

await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.clickPrevious();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('1-25 of 101');
expect(await dataTable.isItemPresent('site-12')).toBe(true, 'Site-12 not found on page');

it('Previous button is disabled on first page - [C280090]', async () => {
expect(await pagination.getCurrentPage()).toContain('Page 1');
expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled on first page');
await pagination.resetToDefaultPageNumber();
});

it('Previous button is disabled on first page - [C280090]', async () => {
expect(await pagination.getCurrentPage()).toContain('Page 1');
expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled on first page');
});

it('Next button is disabled on last page - [C280091]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

it('Next button is disabled on last page - [C280091]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
describe('on Favorite Libraries', () => {
beforeEach(async (done) => {
await page.goToFavoriteLibrariesAndWait();
done();
});

afterEach(async (done) => {
await Utils.pressEscape();
done();
});

it('Pagination control default values - [C291875]', async () => {
expect(await pagination.getRange()).toContain('1-25 of 101');
expect(await pagination.getMaxItems()).toContain('25');
expect(await pagination.getCurrentPage()).toContain('Page 1');
expect(await pagination.getTotalPages()).toContain('of 5');
expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.isNextEnabled()).toBe(true, 'Next button is not enabled');
});

it('Items per page values - [C291876]', async () => {
await pagination.openMaxItemsMenu();
const [ first, second, third ] = [1, 2, 3]
.map(async nth => await pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
await pagination.menu.closeMenu();
});

it('current page menu items - [C291877]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getMaxItems()).toContain('25');
expect(await pagination.getTotalPages()).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();

await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getMaxItems()).toContain('50');
expect(await pagination.getTotalPages()).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();

await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getMaxItems()).toContain('100');
expect(await pagination.getTotalPages()).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();

await pagination.resetToDefaultPageSize();
});

it('change the current page from menu - [C291878]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('51-75 of 101');
expect(await pagination.getCurrentPage()).toContain('Page 3');
expect(await pagination.isPreviousEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.isNextEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.isItemPresent('site-40')).toBe(true, 'Site-60 not found on page');

await pagination.resetToDefaultPageNumber();
});

it('navigate to next and previous pages - [C291881]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('site-70')).toBe(true, 'Site-31 not found on page');
await pagination.resetToDefaultPageNumber();

await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.clickPrevious();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('1-25 of 101');
expect(await dataTable.isItemPresent('site-88')).toBe(true, 'Site-12 not found on page');

await pagination.resetToDefaultPageNumber();
});

it('Previous button is disabled on first page - [C291879]', async () => {
expect(await pagination.getCurrentPage()).toContain('Page 1');
expect(await pagination.isPreviousEnabled()).toBe(false, 'Previous button is enabled on first page');
});

it('Next button is disabled on last page - [C291880]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

});
9 changes: 7 additions & 2 deletions e2e/suites/pagination/pag-single-page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ describe('Pagination on single page', () => {
expect(await pagination.isPagesButtonPresent()).toBe(false, 'page selector displayed');
});

it('page selector not displayed on File Libraries - [C280085]', async () => {
await page.clickFileLibrariesAndWait();
it('page selector not displayed on My Libraries - [C280085]', async () => {
await page.goToMyLibrariesAndWait();
expect(await pagination.isPagesButtonPresent()).toBe(false, 'page selector displayed');
});

it('page selector not displayed on Favorite Libraries - [C291874]', async () => {
await page.goToFavoriteLibrariesAndWait();
expect(await pagination.isPagesButtonPresent()).toBe(false, 'page selector displayed');
});

Expand Down

0 comments on commit f3e8d09

Please sign in to comment.