[ACA-1762] async await pagination (#687)

* use async / await in pagination tests

* add catch in waitForApi
This commit is contained in:
Adina Parpalita 2018-10-05 14:51:53 +03:00 committed by Denys Vuika
parent ac99f5397d
commit 4f4a69338f
13 changed files with 975 additions and 1131 deletions

View File

@ -0,0 +1,112 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on empty page', () => {
const username = `user-${Utils.random()}`;
const adminApi = new RepoClient();
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { pagination } = page;
beforeAll(async (done) => {
await adminApi.people.createUser({ username });
await loginPage.loginWith(username);
done();
});
afterAll(async (done) => {
await logoutPage.load();
done();
});
it('Favorites - pagination controls not displayed - [C280111]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES);
expect(await pagination.range.isPresent()).toBe(false);
expect(await pagination.maxItems.isPresent()).toBe(false);
expect(await pagination.currentPage.isPresent()).toBe(false);
expect(await pagination.totalPages.isPresent()).toBe(false);
expect(await pagination.previousButton.isPresent()).toBe(false);
expect(await pagination.nextButton.isPresent()).toBe(false);
});
it('File Libraries - pagination controls not displayed - [C280084]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES);
expect(await pagination.range.isPresent()).toBe(false);
expect(await pagination.maxItems.isPresent()).toBe(false);
expect(await pagination.currentPage.isPresent()).toBe(false);
expect(await pagination.totalPages.isPresent()).toBe(false);
expect(await pagination.previousButton.isPresent()).toBe(false);
expect(await pagination.nextButton.isPresent()).toBe(false);
});
it('Personal Files - pagination controls not displayed - [C280075]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES);
expect(await pagination.range.isPresent()).toBe(false);
expect(await pagination.maxItems.isPresent()).toBe(false);
expect(await pagination.currentPage.isPresent()).toBe(false);
expect(await pagination.totalPages.isPresent()).toBe(false);
expect(await pagination.previousButton.isPresent()).toBe(false);
expect(await pagination.nextButton.isPresent()).toBe(false);
});
it('Recent Files - pagination controls not displayed - [C280102]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES);
expect(await pagination.range.isPresent()).toBe(false);
expect(await pagination.maxItems.isPresent()).toBe(false);
expect(await pagination.currentPage.isPresent()).toBe(false);
expect(await pagination.totalPages.isPresent()).toBe(false);
expect(await pagination.previousButton.isPresent()).toBe(false);
expect(await pagination.nextButton.isPresent()).toBe(false);
});
it('Shared Files - pagination controls not displayed - [C280094]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES);
expect(await pagination.range.isPresent()).toBe(false);
expect(await pagination.maxItems.isPresent()).toBe(false);
expect(await pagination.currentPage.isPresent()).toBe(false);
expect(await pagination.totalPages.isPresent()).toBe(false);
expect(await pagination.previousButton.isPresent()).toBe(false);
expect(await pagination.nextButton.isPresent()).toBe(false);
});
it('Trash - pagination controls not displayed - [C280120]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH);
expect(await pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});

View File

@ -29,210 +29,141 @@ import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Favorites', () => {
const username = `user-${Utils.random()}`;
describe('Pagination on multiple pages on Favorites', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, favorites: favoritesApi } = apis.user;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const parent = `parent-${Utils.random()}`; let parentId;
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesIds;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}-${Utils.random()}.txt`);
let filesIds;
const file = `file-${Utils.random()}.txt`; let fileId;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
beforeAll(done => {
apis.admin.people.createUser({ username }).then(done);
});
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
filesIds = (await apis.user.nodes.createFiles(files, parent)).list.entries.map(entries => entries.entry.id);
await apis.user.favorites.addFavoritesByIds('file', filesIds);
await apis.user.favorites.waitForApi({ expect: 101 });
await loginPage.loginWith(username);
done();
});
xit('');
beforeEach(async (done) => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES);
await dataTable.waitForHeader();
done();
});
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterEach(async (done) => {
await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
done();
});
afterAll(done => {
logoutPage.load().then(done);
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
await logoutPage.load();
await apis.user.favorites.waitForApi({ expect: 0 });
done();
});
it('pagination controls not displayed - [C280111]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
it('Pagination control default values - [C280113]', async () => {
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await pagination.maxItems.getText()).toContain('25');
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.totalPages.getText()).toContain('of 5');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => favoritesApi.addFavoriteById('file', fileId))
.then(() => loginPage.loginWith(username))
.then(done);
});
it('Items per page values - [C280114]', 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();
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
it('current page menu items - [C280115]', async () => {
await pagination.openMaxItemsMenu()
await pagination.menu.clickMenuItem('25');
expect(await pagination.getText(pagination.maxItems)).toContain('25');
expect(await pagination.getText(pagination.totalPages)).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();
it('page selector not displayed when having a single page - [C280112]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getText(pagination.maxItems)).toContain('50');
expect(await pagination.getText(pagination.totalPages)).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(resp => filesIds = resp.list.entries.map(entries => entries.entry.id))
.then(() => favoritesApi.addFavoritesByIds('file', filesIds))
.then(() => favoritesApi.waitForApi({ expect: 101 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getText(pagination.maxItems)).toContain('100');
expect(await pagination.getText(pagination.totalPages)).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
await pagination.resetToDefaultPageSize();
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
it('change the current page from menu - [C280116]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
expect(await pagination.getText(pagination.range)).toContain('51-75 of 101');
expect(await pagination.getText(pagination.currentPage)).toContain('Page 3');
expect(await pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.getRowByName('file-40').isPresent()).toBe(true, 'File not found on page');
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
await pagination.resetToDefaultPageNumber();
});
it('Pagination control default values - [C280113]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('navigate to next and previous pages - [C280119]', async () => {
await pagination.nextButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('26-50 of 101');
expect(await dataTable.getRowByName('file-70').isPresent()).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
it('Items per page values - [C280114]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.previousButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await dataTable.getRowByName('file-88').isPresent()).toBe(true, 'File not found on page');
it('current page menu items - [C280115]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('25'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('25');
expect(pagination.getText(pagination.totalPages)).toContain('of 5');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu())
await pagination.resetToDefaultPageNumber();
});
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('50');
expect(pagination.getText(pagination.totalPages)).toContain('of 3');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(3))
.then(() => pagination.menu.closeMenu())
it('Previous button is disabled on first page - [C280117]', async () => {
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(2))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.resetToDefaultPageSize());
});
it('change the current page from menu - [C280116]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => {
expect(pagination.getText(pagination.range)).toContain('51-75 of 101');
expect(pagination.getText(pagination.currentPage)).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowByName('file-40.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next and previous pages - [C280119]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber())
.then(() => pagination.openCurrentPageMenu())
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowByName('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page - [C280117]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page - [C280118]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
it('Next button is disabled on last page - [C280118]', 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.currentPage.getText()).toContain('Page 5');
expect(await pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

View File

@ -29,189 +29,137 @@ import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on File Libraries', () => {
const username = `user-${Utils.random()}`;
describe('Pagination on multiple pages on File Libraries', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const sites = Array(101)
.fill('site')
.map((name, index): string => `${name}-${index + 1}-${Utils.random()}`);
const sites = Array(101)
.fill('site')
.map((name, index): string => `${name}-${index + 1}`);
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
await apis.user.sites.createSites(sites, SITE_VISIBILITY.PRIVATE);
await apis.user.sites.waitForApi({ expect: 101 });
await loginPage.loginWith(username);
done();
});
const site = `userSite-${Utils.random()}`; let siteId;
beforeEach(async (done) => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES);
await dataTable.waitForHeader();
done();
});
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
done();
});
afterEach(async (done) => {
await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
done();
});
xit('');
afterAll(async (done) => {
await Promise.all([
apis.user.sites.deleteSites(sites),
logoutPage.load()
]);
done();
})
describe('on empty page', () => {
beforeAll(async (done) => {
await loginPage.loginWith(username);
done();
});
it('Pagination control default values - [C280086]', async () => {
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await pagination.maxItems.getText()).toContain('25');
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.totalPages.getText()).toContain('of 5');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
afterAll(async (done) => {
await logoutPage.load();
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();
});
it('pagination controls not displayed - [C280084]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES);
expect(await pagination.range.isPresent()).toBe(false);
expect(await pagination.maxItems.isPresent()).toBe(false);
expect(await pagination.currentPage.isPresent()).toBe(false);
expect(await pagination.totalPages.isPresent()).toBe(false);
expect(await pagination.previousButton.isPresent()).toBe(false);
expect(await pagination.nextButton.isPresent()).toBe(false);
});
});
it('current page menu items - [C280088]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getText(pagination.maxItems)).toContain('25');
expect(await pagination.getText(pagination.totalPages)).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();
describe('on single page', () => {
beforeAll(async (done) => {
siteId = (await apis.user.sites.createSite(site)).entry.id;
await loginPage.loginWith(username);
done();
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getText(pagination.maxItems)).toContain('50');
expect(await pagination.getText(pagination.totalPages)).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();
afterAll(async (done) => {
await apis.user.sites.deleteSite(siteId);
await logoutPage.load();
done();
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getText(pagination.maxItems)).toContain('100');
expect(await pagination.getText(pagination.totalPages)).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();
it('page selector not displayed when having a single page - [C280085]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES);
await dataTable.waitForHeader();
expect(await pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed');
});
});
await pagination.resetToDefaultPageSize();
});
describe('on multiple pages', () => {
beforeAll(async (done) => {
await apis.user.sites.createSites(sites, SITE_VISIBILITY.PUBLIC);
await apis.user.sites.waitForApi({ expect: 101 });
await loginPage.loginWith(username);
done();
});
it('change the current page from menu - [C280089]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('51-75 of 101');
expect(await pagination.currentPage.getText()).toContain('Page 3');
expect(await pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.getRowByName('site-60').isPresent()).toBe(true, 'Site-60 not found on page');
beforeEach(async (done) => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES);
await dataTable.waitForHeader();
done();
});
await pagination.resetToDefaultPageNumber();
});
afterEach(async (done) => {
await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
done();
});
it('navigate to next and previous pages - [C280092]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('26-50 of 101');
expect(await dataTable.getRowByName('site-31').isPresent()).toBe(true, 'Site-31 not found on page');
await pagination.resetToDefaultPageNumber();
afterAll(async (done) => {
await apis.user.sites.deleteSites(sites);
await logoutPage.load();
done();
});
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.previousButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await dataTable.getRowByName('site-12').isPresent()).toBe(true, 'Site-12 not found on page');
it('Pagination control default values - [C280086]', async () => {
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await pagination.maxItems.getText()).toContain('25');
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.totalPages.getText()).toContain('of 5');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
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('Previous button is disabled on first page - [C280090]', async () => {
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('current page menu items - [C280088]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getText(pagination.maxItems)).toContain('25');
expect(await pagination.getText(pagination.totalPages)).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.getText(pagination.maxItems)).toContain('50');
expect(await pagination.getText(pagination.totalPages)).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.getText(pagination.maxItems)).toContain('100');
expect(await pagination.getText(pagination.totalPages)).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.range.getText()).toContain('51-75 of 101');
expect(await pagination.currentPage.getText()).toContain('Page 3');
expect(await pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.getRowByName('site-60').isPresent()).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.range.getText()).toContain('26-50 of 101');
expect(await dataTable.getRowByName('site-30').isPresent()).toBe(true, 'Site-30 not found on page');
await pagination.resetToDefaultPageNumber();
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.previousButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await dataTable.getRowByName('site-12').isPresent()).toBe(true, 'Site-12 not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280090]', async () => {
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.previousButton.isEnabled()).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.currentPage.getText()).toContain('Page 5');
expect(await pagination.nextButton.isEnabled()).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.currentPage.getText()).toContain('Page 5');
expect(await pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

View File

@ -29,209 +29,140 @@ import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Personal Files', () => {
const username = `user-${Utils.random()}`;
describe('Pagination on multiple pages on Personal Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi } = apis.user;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const parent = `parent-${Utils.random()}`; let parentId;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFiles(files, parent);
await loginPage.loginWith(username);
done();
});
beforeAll(done => {
apis.admin.people.createUser({ username }).then(done);
});
beforeEach(async (done) => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES);
await dataTable.waitForHeader();
await dataTable.doubleClickOnRowByName(parent);
done();
});
xit('');
afterEach(async (done) => {
await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
done();
});
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(async (done) => {
await Promise.all([
apis.user.nodes.deleteNodeById(parentId),
logoutPage.load()
]);
done();
});
afterAll(done => {
logoutPage.load().then(done);
});
it('Pagination control default values - [C280077]', async () => {
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await pagination.maxItems.getText()).toContain('25');
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.totalPages.getText()).toContain('of 5');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('pagination controls not displayed - [C280075]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
it('Items per page values - [C280078]', 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();
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => loginPage.loginWith(username))
.then(done);
});
it('current page menu items - [C280079]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getText(pagination.maxItems)).toContain('25');
expect(await pagination.getText(pagination.totalPages)).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getText(pagination.maxItems)).toContain('50');
expect(await pagination.getText(pagination.totalPages)).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();
it('page selector not displayed when having a single page - [C280076]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getText(pagination.maxItems)).toContain('100');
expect(await pagination.getText(pagination.totalPages)).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(() => loginPage.loginWith(username))
.then(done);
});
await pagination.resetToDefaultPageSize();
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnRowByName(parent))
.then(done);
});
it('change the current page from menu - [C280080]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('51-75 of 101');
expect(await pagination.currentPage.getText()).toContain('Page 3');
expect(await pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.getRowByName('file-60').isPresent()).toBe(true, 'File not found on page');
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
await pagination.resetToDefaultPageNumber();
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('navigate to next and previous pages - [C280083]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('26-50 of 101');
expect(await dataTable.getRowByName('file-31').isPresent()).toBe(true, 'file-31 not found on page');
await pagination.resetToDefaultPageNumber();
it('Pagination control default values - [C280077]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.previousButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await dataTable.getRowByName('file-12').isPresent()).toBe(true, 'file-12 not found on page');
it('Items per page values - [C280078]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
await pagination.resetToDefaultPageNumber();
});
it('current page menu items - [C280079]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('25'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('25');
expect(pagination.getText(pagination.totalPages)).toContain('of 5');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu())
it('Previous button is disabled on first page - [C280081]', async () => {
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('50');
expect(pagination.getText(pagination.totalPages)).toContain('of 3');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(3))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(2))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.resetToDefaultPageSize());
});
it('change the current page from menu - [C280080]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowByName('file-60.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next and previous pages - [C280083]', () => {
pagination.clickNext()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByName('file-30.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber())
.then(() => pagination.openCurrentPageMenu())
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowByName('file-12.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page - [C280081]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page - [C280082]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
it('Next button is disabled on last page - [C280082]', 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.currentPage.getText()).toContain('Page 5');
expect(await pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

View File

@ -29,211 +29,140 @@ import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Recent Files', () => {
const username = `user-${Utils.random()}`;
describe('Pagination on multiple pages on Recent Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, search: searchApi } = apis.user;
const parent = `parent-${Utils.random()}`; let parentId;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFiles(files, parent);
await apis.user.search.waitForApi(username, { expect: 101 });
await loginPage.loginWith(username);
done();
});
beforeAll(done => {
apis.admin.people.createUser({ username }).then(done);
});
beforeEach(async (done) => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES);
await dataTable.waitForHeader();
done();
});
xit('');
afterEach(async (done) => {
await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
done();
});
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(async (done) => {
await Promise.all([
apis.user.nodes.deleteNodeById(parentId),
logoutPage.load()
]);
done();
});
afterAll(done => {
logoutPage.load().then(done);
});
it('Pagination control default values - [C280104]', async () => {
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await pagination.maxItems.getText()).toContain('25');
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.totalPages.getText()).toContain('of 5');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('pagination controls not displayed - [C280102]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
it('Items per page values - [C280105]', 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();
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => searchApi.waitForApi(username, { expect: 1 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
it('current page menu items - [C280106]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getText(pagination.maxItems)).toContain('25');
expect(await pagination.getText(pagination.totalPages)).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getText(pagination.maxItems)).toContain('50');
expect(await pagination.getText(pagination.totalPages)).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();
it('page selector not displayed when having a single page - [C280103]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getText(pagination.maxItems)).toContain('100');
expect(await pagination.getText(pagination.totalPages)).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(() => searchApi.waitForApi(username, { expect: 101 }))
await pagination.resetToDefaultPageSize();
});
.then(() => loginPage.loginWith(username))
.then(done);
});
it('change the current page from menu - [C280107]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('51-75 of 101');
expect(await pagination.currentPage.getText()).toContain('Page 3');
expect(await pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.getRowByName('file-40').isPresent()).toBe(true, 'File not found on page');
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
await pagination.resetToDefaultPageNumber();
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
it('navigate to next and previous pages - [C280110]', async () => {
await pagination.nextButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('26-50 of 101');
expect(await dataTable.getRowByName('file-70').isPresent()).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.previousButton.click();
await dataTable.waitForHeader();
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowByName('file-88').isPresent()).toBe(true, 'File not found on page');
it('Pagination control default values - [C280104]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
await pagination.resetToDefaultPageNumber();
});
it('Items per page values - [C280105]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
it('Previous button is disabled on first page - [C280108]', async () => {
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('current page menu items - [C280106]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('25'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('25');
expect(pagination.getText(pagination.totalPages)).toContain('of 5');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('50');
expect(pagination.getText(pagination.totalPages)).toContain('of 3');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(3))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(2))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.resetToDefaultPageSize());
});
it('change the current page from menu - [C280107]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowByName('file-40.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next and previous pages - [C280110]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber())
.then(() => pagination.openCurrentPageMenu())
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowByName('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page - [C280108]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page - [C280109]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
it('Next button is disabled on last page - [C280109]', 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.currentPage.getText()).toContain('Page 5');
expect(await pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

View File

@ -29,217 +29,144 @@ import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Shared Files', () => {
const username = `user-${Utils.random()}`;
describe('Pagination on multiple pages on Shared Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, shared: sharedApi } = apis.user;
const parent = `parent-${Utils.random()}`; let parentId;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesIds;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesIds;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
filesIds = (await apis.user.nodes.createFiles(files, parent)).list.entries.map(entries => entries.entry.id);
beforeAll(done => {
apis.admin.people.createUser({ username }).then(done);
});
await apis.user.shared.shareFilesByIds(filesIds);
await apis.user.shared.waitForApi({ expect: 101 });
await loginPage.loginWith(username);
done();
});
xit('');
beforeEach(async (done) => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES);
await dataTable.waitForHeader();
done();
});
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterEach(async (done) => {
await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
done();
});
afterAll(done => {
logoutPage.load().then(done);
});
afterAll(async (done) => {
await Promise.all([
apis.user.nodes.deleteNodeById(parentId),
logoutPage.load()
]);
done();
});
it('pagination controls not displayed - [C280094]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
it('Pagination control default values - [C280095]', async () => {
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await pagination.maxItems.getText()).toContain('25');
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.totalPages.getText()).toContain('of 5');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => sharedApi.shareFileById(fileId))
.then(() => sharedApi.waitForApi({ expect: 1 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
it('Items per page values - [C280096]', 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');
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
await pagination.menu.closeMenu();
});
it('page selector not displayed when having a single page - [C280094]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
it('current page menu items - [C280097]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getText(pagination.maxItems)).toContain('25');
expect(await pagination.getText(pagination.totalPages)).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(resp => filesIds = resp.list.entries.map(entries => entries.entry.id))
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getText(pagination.maxItems)).toContain('50');
expect(await pagination.getText(pagination.totalPages)).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();
.then(() => sharedApi.shareFilesByIds(filesIds))
.then(() => sharedApi.waitForApi({ expect: 101 }))
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getText(pagination.maxItems)).toContain('100');
expect(await pagination.getText(pagination.totalPages)).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();
.then(() => loginPage.loginWith(username))
.then(done);
});
await pagination.resetToDefaultPageSize();
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
it('change the current page from menu - [C280098]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('51-75 of 101');
expect(await pagination.currentPage.getText()).toContain('Page 3');
expect(await pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.getRowByName('file-40').isPresent()).toBe(true, 'File not found on page');
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
await pagination.resetToDefaultPageNumber();
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('navigate to next and previous pages - [C280101]', async () => {
await pagination.nextButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('26-50 of 101');
expect(await dataTable.getRowByName('file-70').isPresent()).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
it('Pagination control default values - [C280095]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.previousButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await dataTable.getRowByName('file-88').isPresent()).toBe(true, 'File not found on page');
it('Items per page values - [C280096]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
await pagination.resetToDefaultPageNumber();
});
it('current page menu items - [C280097]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('25'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('25');
expect(pagination.getText(pagination.totalPages)).toContain('of 5');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu())
it('Previous button is disabled on first page - [C280099]', async () => {
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('50');
expect(pagination.getText(pagination.totalPages)).toContain('of 3');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(3))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(2))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.resetToDefaultPageSize());
});
it('change the current page from menu - [C280098]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowByName('file-40.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next and previous pages - [C280101]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber())
.then(() => pagination.openCurrentPageMenu())
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowByName('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page - [C280099]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page - [C280100]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
it('Next button is disabled on last page - [C280100]', 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.currentPage.getText()).toContain('Page 5');
expect(await pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

View File

@ -0,0 +1,120 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on single page', () => {
const username = `user-${Utils.random()}`;
const siteName = `site-${Utils.random()}`; let siteId;
const file = `file-${Utils.random()}.txt`; let fileId;
const fileInTrash = `fileInTrash-${Utils.random()}.txt`; let fileInTrashId;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
const [fileP, fileInTrashP, siteP] = await Promise.all([
apis.user.nodes.createFile(file),
apis.user.nodes.createFile(fileInTrash),
apis.user.sites.createSite(siteName)
]);
fileId = fileP.entry.id;
fileInTrashId = fileInTrashP.entry.id;
siteId = siteP.entry.id;
await apis.user.nodes.deleteNodeById(fileInTrashId, false);
await apis.user.favorites.addFavoriteById('file', fileId);
await apis.user.shared.shareFileById(fileId);
await apis.user.favorites.waitForApi({ expect: 2 });
await apis.user.search.waitForApi(username, { expect: 1 });
await apis.user.shared.waitForApi({ expect: 1 });
await apis.user.trashcan.waitForApi({ expect: 1 });
await loginPage.loginWith(username);
done();
});
afterAll(async (done) => {
await Promise.all([
apis.user.nodes.deleteNodeById(fileId),
apis.user.sites.deleteSite(siteId),
apis.user.trashcan.emptyTrash(),
logoutPage.load()
]);
done();
});
it('page selector not displayed on Favorites - [C280112]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES);
await dataTable.waitForHeader();
expect(await pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed');
});
it('page selector not displayed on File Libraries - [C280085]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES);
await dataTable.waitForHeader();
expect(await pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed');
});
it('page selector not displayed on Personal Files - [C280076]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES);
await dataTable.waitForHeader();
expect(await pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed');
});
it('page selector not displayed on Recent Files - [C280103]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES);
await dataTable.waitForHeader();
expect(await pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed');
});
it('page selector not displayed on Shared Files - [C280094]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES);
await dataTable.waitForHeader();
expect(await pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed');
});
it('page selector not displayed on Trash - [C280121]', async () => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH);
await dataTable.waitForHeader();
expect(await pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed');
});
});

View File

@ -29,214 +29,139 @@ import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Trash', () => {
const username = `user-${Utils.random()}`;
describe('Pagination on multiple pages on Trash', () => {
const username = `user-${Utils.random()}`;
const filesForDelete = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesDeletedIds;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, trashcan: trashApi } = apis.user;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const filesForDelete = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesDeletedIds;
beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
filesDeletedIds = (await apis.user.nodes.createFiles(filesForDelete)).list.entries.map(entries => entries.entry.id);
await apis.user.nodes.deleteNodesById(filesDeletedIds, false);
await apis.user.trashcan.waitForApi({expect: 101});
await loginPage.loginWith(username);
done();
});
const file = `file-${Utils.random()}.txt`; let fileId;
beforeEach(async (done) => {
await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH);
await dataTable.waitForHeader();
done();
});
beforeAll(done => {
apis.admin.people.createUser({ username }).then(done);
});
afterEach(async (done) => {
await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
done();
});
xit('');
afterAll(async (done) => {
await Promise.all([
apis.user.trashcan.emptyTrash(),
logoutPage.load()
]);
done();
});
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
it('Pagination control default values - [C280122]', async () => {
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await pagination.maxItems.getText()).toContain('25');
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.totalPages.getText()).toContain('of 5');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
afterAll(done => {
logoutPage.load().then(done);
});
it('Items per page values - [C280123]', 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('pagination controls not displayed - [C280120]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
it('current page menu items - [C280124]', async () => {
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('25');
expect(await pagination.getText(pagination.maxItems)).toContain('25');
expect(await pagination.getText(pagination.totalPages)).toContain('of 5');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(5);
await pagination.menu.closeMenu();
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => nodesApi.deleteNodeById(fileId, false))
.then(() => trashApi.waitForApi({ expect: 1 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('50');
expect(await pagination.getText(pagination.maxItems)).toContain('50');
expect(await pagination.getText(pagination.totalPages)).toContain('of 3');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(3);
await pagination.menu.closeMenu();
afterAll(done => {
Promise.all([
trashApi.emptyTrash(),
logoutPage.load()
])
.then(done);
});
await pagination.openMaxItemsMenu();
await pagination.menu.clickMenuItem('100');
expect(await pagination.getText(pagination.maxItems)).toContain('100');
expect(await pagination.getText(pagination.totalPages)).toContain('of 2');
await pagination.openCurrentPageMenu();
expect(await pagination.menu.getItemsCount()).toBe(2);
await pagination.menu.closeMenu();
it('page selector not displayed when having a single page - [C280121]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
await pagination.resetToDefaultPageSize();
});
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(filesForDelete)
.then(resp => filesDeletedIds = resp.list.entries.map(entries => entries.entry.id))
.then(() => nodesApi.deleteNodesById(filesDeletedIds, false))
.then(() => trashApi.waitForApi({expect: 101}))
it('change the current page from menu - [C280125]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('51-75 of 101');
expect(await pagination.currentPage.getText()).toContain('Page 3');
expect(await pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(await pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(await dataTable.getRowByName('file-40').isPresent()).toBe(true, 'File not found on page');
.then(() => loginPage.loginWith(username))
.then(done);
});
await pagination.resetToDefaultPageNumber();
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
it('navigate to next and previous pages - [C280128]', async () => {
await pagination.nextButton.click();
await dataTable.waitForHeader();
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByName('file-70').isPresent()).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForHeader();
await pagination.previousButton.click();
await dataTable.waitForHeader();
expect(await pagination.range.getText()).toContain('1-25 of 101');
expect(await dataTable.getRowByName('file-88').isPresent()).toBe(true, 'File not found on page');
afterAll(done => {
Promise.all([
trashApi.emptyTrash(),
logoutPage.load()
])
.then(done);
});
await pagination.resetToDefaultPageNumber();
});
it('Pagination control default values - [C280122]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('Previous button is disabled on first page - [C280126]', async () => {
expect(await pagination.currentPage.getText()).toContain('Page 1');
expect(await pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Items per page values - [C280123]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
it('current page menu items - [C280124]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('25'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('25');
expect(pagination.getText(pagination.totalPages)).toContain('of 5');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('50');
expect(pagination.getText(pagination.totalPages)).toContain('of 3');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(3))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.openCurrentPageMenu())
.then(() => expect(pagination.menu.getItemsCount()).toBe(2))
.then(() => pagination.menu.closeMenu())
.then(() => pagination.resetToDefaultPageSize());
});
it('change the current page from menu - [C280125]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowByName('file-40.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next and previous pages - [C280128]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber())
.then(() => pagination.openCurrentPageMenu())
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowByName('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page - [C280126]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page - [C280127]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
it('Next button is disabled on last page - [C280127]', 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.currentPage.getText()).toContain('Page 5');
expect(await pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});

View File

@ -90,15 +90,20 @@ export class FavoritesApi extends RepoApi {
}
async waitForApi(data) {
try {
const favoriteFiles = async () => {
const totalItems = (await this.getFavorites()).list.pagination.totalItems;
if ( totalItems < data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
const totalItems = (await this.getFavorites()).list.pagination.totalItems;
if ( totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(favoriteFiles);
} catch (error) {
console.log('-----> catch favorites: ', error);
}
}
}

View File

@ -51,15 +51,19 @@ export class SearchApi extends RepoApi {
}
async waitForApi(username, data) {
try {
const recentFiles = async () => {
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
if ( totalItems < data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
if ( totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(recentFiles);
return await Utils.retryCall(recentFiles);
} catch (error) {
console.log('-----> catch search: ', error);
}
}
}

View File

@ -62,15 +62,19 @@ export class SharedLinksApi extends RepoApi {
}
async waitForApi(data) {
try {
const sharedFiles = async () => {
const totalItems = (await this.getSharedLinks()).list.pagination.totalItems;
if ( totalItems < data.expect ) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
const totalItems = (await this.getSharedLinks()).list.pagination.totalItems;
if ( totalItems !== data.expect ) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(sharedFiles);
return await Utils.retryCall(sharedFiles);
} catch (error) {
console.log('-----> catch shared: ', error);
}
}
}

View File

@ -105,9 +105,10 @@ export class SitesApi extends RepoApi {
}
async waitForApi(data) {
const sites = async () => {
try {
const sites = async () => {
const totalItems = (await this.getSites()).list.pagination.totalItems;
if ( totalItems < data.expect ) {
if ( totalItems !== data.expect ) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
@ -115,5 +116,8 @@ export class SitesApi extends RepoApi {
};
return await Utils.retryCall(sites);
} catch (error) {
console.log('-----> catch sites: ', error);
}
}
}

View File

@ -60,9 +60,10 @@ export class TrashcanApi extends RepoApi {
}
async waitForApi(data) {
const deletedFiles = async () => {
try {
const deletedFiles = async () => {
const totalItems = (await this.getDeletedNodes()).list.pagination.totalItems;
if ( totalItems < data.expect) {
if ( totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
@ -70,5 +71,8 @@ export class TrashcanApi extends RepoApi {
};
return await Utils.retryCall(deletedFiles);
} catch (error) {
console.log('-----> catch trash: ', error);
}
}
}