refactor pagination e2e (#1312)

* wrap test suites in functions

* better naming and small improvements

* higher suite that calls the wrapped test functions
This commit is contained in:
Adina Parpalita 2020-01-22 07:46:57 +02:00 committed by Cilibiu Bogdan
parent 4e7595f7b2
commit 653be8bbcd
15 changed files with 832 additions and 884 deletions

View File

@ -0,0 +1,131 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
export function favoritesTests() {
const page = new BrowsingPage();
const { dataTable, pagination } = page;
describe('Pagination controls : ', () => {
beforeAll(async () => {
await page.clickFavoritesAndWait();
});
afterEach(async () => {
await Utils.pressEscape();
});
it('Pagination control default values - [C280113]', 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 - [C280114]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280115]', 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 - [C280116]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
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('my-file-40')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280119]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('my-file-70')).toBe(true, 'File 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('my-file-88')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280117]', 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 - [C280118]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});
}

View File

@ -0,0 +1,94 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { LoginPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { AdminActions } from '../../utilities/admin-actions';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { personalFilesTests } from './personal-files';
import { recentFilesTests } from './recent-files';
import { searchResultsTests } from './search-results';
import { sharedFilesTests } from './shared-files';
import { favoritesTests } from './favorites';
describe('Pagination on multiple pages : ', () => {
const random = Utils.random();
const username = `user-${random}`;
const parent = `parent-${random}`;
let parentId: string;
const files = Array(101)
.fill('my-file')
.map((name, index): string => `${name}-${index + 1}-${random}.txt`);
let filesIds: string[];
const userApi = new RepoClient(username, username);
const adminApiActions = new AdminActions();
const loginPage = new LoginPage();
beforeAll(async () => {
await adminApiActions.createUser({ username });
parentId = (await userApi.nodes.createFolder(parent)).entry.id;
filesIds = (await userApi.nodes.createFiles(files, parent)).list.entries.map(entries => entries.entry.id);
await userApi.shared.shareFilesByIds(filesIds);
await userApi.favorites.addFavoritesByIds('file', filesIds);
await Promise.all([
userApi.favorites.waitForApi({ expect: 101 }),
userApi.shared.waitForApi({ expect: 101 }),
userApi.search.waitForApi(username, { expect: 101 }),
]);
await loginPage.loginWith(username);
});
afterAll(async () => {
await userApi.nodes.deleteNodeById(parentId);
});
describe('on Personal Files', () => {
personalFilesTests(parent);
});
describe('on Recent Files', () => {
recentFilesTests();
});
describe('on Search Results', () => {
searchResultsTests();
});
describe('on Shared Files', () => {
sharedFilesTests();
});
describe('on Favorites', () => {
favoritesTests();
});
});

View File

@ -23,48 +23,45 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SITE_VISIBILITY } from '../../configs';
import { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { AdminActions } from '../../utilities/admin-actions';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on multiple pages', () => {
const username = `user-${Utils.random()}`;
const random = Utils.random();
const username = `user-${random}`;
const userApi = new RepoClient(username, username);
const adminApiActions = new AdminActions();
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const sites = Array(101)
.fill('site')
.map((name, index): string => `${name}-${index + 1}-${Utils.random()}`);
.map((name, index): string => `${name}-${index + 1}-${random}`);
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 });
beforeAll(async () => {
await adminApiActions.createUser({ username });
await userApi.sites.createSitesPrivate(sites);
await userApi.sites.waitForApi({ expect: 101 });
await loginPage.loginWith(username);
done();
});
afterAll(async (done) => {
await apis.user.sites.deleteSites(sites);
done();
afterAll(async () => {
await userApi.sites.deleteSites(sites);
})
describe('on My Libraries', () => {
beforeEach(async (done) => {
beforeAll(async () => {
await page.goToMyLibrariesAndWait();
done();
});
afterEach(async (done) => {
afterEach(async () => {
await Utils.pressEscape();
done();
});
it('Pagination control default values - [C280086]', async () => {
@ -158,14 +155,12 @@ describe('Pagination on multiple pages', () => {
});
describe('on Favorite Libraries', () => {
beforeEach(async (done) => {
beforeAll(async () => {
await page.goToFavoriteLibrariesAndWait();
done();
});
afterEach(async (done) => {
afterEach(async () => {
await Utils.pressEscape();
done();
});
it('Pagination control default values - [C291875]', async () => {

View File

@ -25,46 +25,42 @@
import { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { AdminActions } from '../../utilities/admin-actions';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on multiple pages on Trash', () => {
const username = `user-${Utils.random()}`;
const random = Utils.random();
const username = `user-${random}`;
const filesForDelete = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesDeletedIds;
.map((name, index): string => `${name}-${index + 1}-${random}.txt`);
let filesDeletedIds: string[];
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const userApi = new RepoClient(username, username);
const adminApiActions = new AdminActions();
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
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});
beforeAll(async () => {
await adminApiActions.createUser({ username });
filesDeletedIds = (await userApi.nodes.createFiles(filesForDelete)).list.entries.map(entries => entries.entry.id);
await userApi.nodes.deleteNodesById(filesDeletedIds, false);
await userApi.trashcan.waitForApi({expect: 101});
await loginPage.loginWith(username);
done();
});
beforeEach(async (done) => {
await page.clickTrashAndWait();
done();
});
afterEach(async (done) => {
afterEach(async () => {
await Utils.pressEscape();
done();
});
afterAll(async (done) => {
await apis.user.trashcan.emptyTrash();
done();
afterAll(async () => {
await userApi.trashcan.emptyTrash();
});
it('Pagination control default values - [C280122]', async () => {

View File

@ -1,162 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on multiple pages on Favorites', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const parent = `parent-${Utils.random()}`; let parentId;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}-${Utils.random()}.txt`);
let filesIds;
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
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();
});
beforeEach(async (done) => {
await page.clickFavoritesAndWait();
done();
});
afterEach(async (done) => {
await Utils.pressEscape();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
await apis.user.favorites.waitForApi({ expect: 0 });
done();
});
it('Pagination control default values - [C280113]', 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 - [C280114]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280115]', 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 - [C280116]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
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('file-40')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280119]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('file-70')).toBe(true, 'File 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('file-88')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280117]', 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 - [C280118]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});

View File

@ -1,160 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on multiple pages on Personal Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
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 page = new BrowsingPage();
const { dataTable, pagination } = page;
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();
});
beforeEach(async (done) => {
await page.clickPersonalFilesAndWait();
await dataTable.doubleClickOnRowByName(parent);
await dataTable.waitForHeader();
done();
});
afterEach(async (done) => {
await Utils.pressEscape();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
done();
});
it('Pagination control default values - [C280077]', 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 - [C280078]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280079]', 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 - [C280080]', 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('file-60')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280083]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('file-31')).toBe(true, 'file-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('file-12')).toBe(true, 'file-12 not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280081]', 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 - [C280082]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});

View File

@ -1,159 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on multiple pages on Recent Files', () => {
const username = `user-${Utils.random()}`;
const parent = `parent-${Utils.random()}`; let parentId;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
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();
});
beforeEach(async (done) => {
await page.clickRecentFilesAndWait();
done();
});
afterEach(async (done) => {
await Utils.pressEscape();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
done();
});
it('Pagination control default values - [C280104]', 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 - [C280105]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280106]', 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 - [C280107]', 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('file-40')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280110]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('file-70')).toBe(true, 'File 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('file-88')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280108]', 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 - [C280109]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});

View File

@ -1,158 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on multiple pages on Search Results', () => {
const username = `user-${Utils.random()}`;
const parent = `parent-${Utils.random()}`; let parentId;
const files = Array(101)
.fill('myFile')
.map((name, index): string => `${name}-${index + 1}.txt`);
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const { searchInput } = page.header;
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);
await searchInput.clickSearchButton();
await searchInput.checkOnlyFiles();
await searchInput.searchFor('myFile-');
await dataTable.waitForBody();
done();
});
afterEach(async (done) => {
await Utils.pressEscape();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
done();
});
it('Pagination control default values - [C290125]', 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 - [C290126]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C290127]', 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 - [C290128]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForBody();
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');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C290131]', async () => {
await pagination.clickNext();
await dataTable.waitForBody();
expect(await pagination.getRange()).toContain('26-50 of 101');
await pagination.resetToDefaultPageNumber();
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForBody();
await pagination.clickPrevious();
await dataTable.waitForBody();
expect(await pagination.getRange()).toContain('1-25 of 101');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C290129]', 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 - [C290130]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});

View File

@ -1,162 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { LoginPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on multiple pages on Shared Files', () => {
const username = `user-${Utils.random()}`;
const parent = `parent-${Utils.random()}`; let parentId;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesIds;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
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.shared.shareFilesByIds(filesIds);
await apis.user.shared.waitForApi({ expect: 101 });
await loginPage.loginWith(username);
done();
});
beforeEach(async (done) => {
await page.clickSharedFilesAndWait();
done();
});
afterEach(async (done) => {
await Utils.pressEscape();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(parentId);
done();
});
it('Pagination control default values - [C280095]', 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 - [C280096]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280097]', 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 - [C280098]', 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('file-40')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280101]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('file-70')).toBe(true, 'File 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('file-88')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280099]', 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 - [C280100]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});

View File

@ -0,0 +1,134 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
export function personalFilesTests(parentName: string) {
const page = new BrowsingPage();
const { dataTable, pagination } = page;
describe('Pagination controls : ', () => {
beforeAll(async () => {
await page.clickPersonalFilesAndWait();
await dataTable.doubleClickOnRowByName(parentName);
await dataTable.waitForHeader();
});
afterEach(async () => {
await Utils.pressEscape();
});
it('Pagination control default values - [C280077]', 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 - [C280078]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280079]', 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 - [C280080]', 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('my-file-60')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280083]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('my-file-31')).toBe(true, 'file-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('my-file-12')).toBe(true, 'my-file-12 not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280081]', 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 - [C280082]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});
}

View File

@ -0,0 +1,132 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
export function recentFilesTests() {
const page = new BrowsingPage();
const { dataTable, pagination } = page;
describe('Pagination controls : ', () => {
beforeAll(async () => {
await page.clickRecentFilesAndWait();
});
afterEach(async () => {
await Utils.pressEscape();
});
it('Pagination control default values - [C280104]', 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 - [C280105]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280106]', 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 - [C280107]', 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('my-file-40')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280110]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('my-file-70')).toBe(true, 'File 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('my-file-88')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280108]', 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 - [C280109]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});
}

View File

@ -0,0 +1,132 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
export function searchResultsTests() {
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const { searchInput } = page.header;
describe('Pagination controls : ', () => {
beforeAll(async () => {
await searchInput.clickSearchButton();
await searchInput.searchFor('my-file-');
await dataTable.waitForBody();
});
afterEach(async () => {
await Utils.pressEscape();
});
it('Pagination control default values - [C290125]', 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 - [C290126]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C290127]', 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 - [C290128]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(3);
await dataTable.waitForBody();
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');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C290131]', async () => {
await pagination.clickNext();
await dataTable.waitForBody();
expect(await pagination.getRange()).toContain('26-50 of 101');
await pagination.resetToDefaultPageNumber();
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(2);
await dataTable.waitForBody();
await pagination.clickPrevious();
await dataTable.waitForBody();
expect(await pagination.getRange()).toContain('1-25 of 101');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C290129]', 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 - [C290130]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});
}

View File

@ -0,0 +1,132 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 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 { BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
export function sharedFilesTests() {
const page = new BrowsingPage();
const { dataTable, pagination } = page;
describe('Pagination controls : ', () => {
beforeAll(async () => {
await page.clickSharedFilesAndWait();
});
afterEach(async () => {
await Utils.pressEscape();
});
it('Pagination control default values - [C280095]', 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 - [C280096]', async () => {
await pagination.openMaxItemsMenu();
expect(await pagination.menu.getNthItem(1).getText()).toBe('25');
expect(await pagination.menu.getNthItem(2).getText()).toBe('50');
expect(await pagination.menu.getNthItem(3).getText()).toBe('100');
await pagination.menu.closeMenu();
});
it('current page menu items - [C280097]', 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 - [C280098]', 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('my-file-40')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('navigate to next and previous pages - [C280101]', async () => {
await pagination.clickNext();
await dataTable.waitForHeader();
expect(await pagination.getRange()).toContain('26-50 of 101');
expect(await dataTable.isItemPresent('my-file-70')).toBe(true, 'File 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('my-file-88')).toBe(true, 'File not found on page');
await pagination.resetToDefaultPageNumber();
});
it('Previous button is disabled on first page - [C280099]', 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 - [C280100]', async () => {
await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5);
expect(await dataTable.getRowsCount()).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');
});
});
}

View File

@ -23,60 +23,60 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { LoginPage, BrowsingPage } from '../../pages/pages';
import { LoginPage, BrowsingPage, SearchResultsPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { AdminActions } from '../../utilities/admin-actions';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on single page', () => {
const username = `user-${Utils.random()}`;
const random = Utils.random();
const siteName = `site-${Utils.random()}`; let siteId;
const username = `user-${random}`;
const file = `file-${Utils.random()}.txt`; let fileId;
const fileInTrash = `fileInTrash-${Utils.random()}.txt`; let fileInTrashId;
const siteName = `site-${random}`;
let siteId: string;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const file = `file-${random}.txt`;
let fileId: string;
const fileInTrash = `fileInTrash-${random}.txt`;
let fileInTrashId: string;
const userApi = new RepoClient(username, username);
const adminApiActions = new AdminActions();
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { pagination, dataTable } = page;
const { pagination } = page;
const { searchInput } = page.header;
const searchResultsPage = new SearchResultsPage();
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)
beforeAll(async () => {
await adminApiActions.createUser({ username });
fileId = (await userApi.nodes.createFile(file)).entry.id;
fileInTrashId = (await userApi.nodes.createFile(fileInTrash)).entry.id;
siteId = (await userApi.sites.createSite(siteName)).entry.id;
await userApi.nodes.deleteNodeById(fileInTrashId, false);
await userApi.favorites.addFavoriteById('file', fileId);
await userApi.shared.shareFileById(fileId);
await Promise.all([
userApi.favorites.waitForApi({ expect: 2 }),
userApi.search.waitForApi(username, { expect: 1 }),
userApi.shared.waitForApi({ expect: 1 }),
userApi.trashcan.waitForApi({ expect: 1 })
]);
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) => {
afterAll(async () => {
await Promise.all([
apis.user.nodes.deleteNodeById(fileId),
apis.user.sites.deleteSite(siteId),
apis.user.trashcan.emptyTrash()
userApi.nodes.deleteNodeById(fileId),
userApi.sites.deleteSite(siteId),
userApi.trashcan.emptyTrash()
]);
done();
});
it('page selector not displayed on Favorites - [C280112]', async () => {
@ -116,9 +116,8 @@ describe('Pagination on single page', () => {
it('page selector not displayed on Search results - [C290124]', async () => {
await searchInput.clickSearchButton();
await searchInput.checkOnlyFiles();
await searchInput.searchFor(file);
await dataTable.waitForBody();
await searchResultsPage.waitForResults();
expect(await pagination.isPagesButtonPresent()).toBe(false, 'page selector displayed');
});

View File

@ -120,7 +120,7 @@ export class SitesApi extends RepoApi {
return this.createSite(title, SITE_VISIBILITY.MODERATED, description, siteId);
}
async createSites(titles: string[], visibility?: string) {
async createSites(titles: string[], visibility?: string): Promise<any> {
try {
return titles.reduce(async (previous: any, current: any) => {
await previous;
@ -131,6 +131,10 @@ export class SitesApi extends RepoApi {
}
}
async createSitesPrivate(siteNames: string[]): Promise<any> {
return this.createSites(siteNames, SITE_VISIBILITY.PRIVATE)
}
async deleteSite(siteId: string, permanent: boolean = true) {
try {
await this.apiAuth();