add tests for pagination on multiple list views (#97)

This commit is contained in:
Adina Parpalita 2017-11-28 23:29:07 +02:00 committed by Cilibiu Bogdan
parent c1e9001c38
commit f6f7b0bdf3
2 changed files with 566 additions and 64 deletions

View File

@ -45,6 +45,7 @@ export class DataTable extends Component {
head: ElementFinder = this.component.element(by.css(DataTable.selectors.head)); head: ElementFinder = this.component.element(by.css(DataTable.selectors.head));
body: ElementFinder = this.component.element(by.css(DataTable.selectors.body)); body: ElementFinder = this.component.element(by.css(DataTable.selectors.body));
cell = by.css(DataTable.selectors.cell);
emptyList: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer)); emptyList: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer));
emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop)); emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop));
emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle)); emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle));

View File

@ -15,9 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { browser } from 'protractor'; import { browser, protractor, promise } from 'protractor';
import { SIDEBAR_LABELS, SITE_VISIBILITY } from '../../configs';
import { APP_ROUTES } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils'; import { Utils } from '../../utilities/utils';
import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client'; import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client';
@ -29,138 +28,640 @@ describe('Pagination', () => {
admin: new RepoClient(), admin: new RepoClient(),
user: new RepoClient(username, username) user: new RepoClient(username, username)
}; };
const {
nodes: nodesApi,
trashcan: trashApi,
favorites: favoritesApi,
shared: sharedApi,
sites: sitesApi
} = apis.user;
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const logoutPage = new LogoutPage(); const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesIds;
const filesForDelete = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesDeletedIds;
function resetToDefaultPageSize(): promise.Promise<any> {
return pagination.openMaxItemsMenu()
.then(menu => menu.clickMenuItem('25'))
.then(() => dataTable.waitForHeader());
}
function resetToDefaultPageNumber(): promise.Promise<any> {
return pagination.openCurrentPageMenu()
.then(menu => menu.clickMenuItem('1'))
.then(() => dataTable.waitForHeader());
}
beforeAll(done => { beforeAll(done => {
apis.admin.people apis.admin.people.createUser(username)
.createUser(username) .then(() => nodesApi.createFiles(files, parent))
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id))
.then(() => sharedApi.shareFilesByIds(filesIds))
.then(() => favoritesApi.addFavoritesByIds('file', filesIds))
.then(() => nodesApi.createFiles(filesForDelete))
.then(resp => filesDeletedIds = resp.data.list.entries.map(entries => entries.entry.id))
.then(() => nodesApi.deleteNodesById(filesDeletedIds, false))
.then(done); .then(done);
}); });
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
trashApi.emptyTrash()
])
.then(done);
});
xit(''); xit('');
describe(`on Personal Files`, () => { describe(`on Personal Files`, () => {
const personalFilesPage = new BrowsingPage(APP_ROUTES.PERSONAL_FILES);
const { dataTable, pagination } = personalFilesPage;
// Generate files
const content: NodeContentTree = {
name: `user-folder-${Utils.random()}`,
files: Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`)
};
const { nodes: nodesApi } = apis.user;
beforeAll(done => { beforeAll(done => {
nodesApi.createContent(content) loginPage.load()
.then(() => loginPage.load() .then(() => loginPage.loginWith(username))
.then(() => loginPage.loginWith(username)) .then(done);
.then(done));
}); });
beforeEach(done => { beforeEach(done => {
personalFilesPage.load() page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(content.name)) .then(() => dataTable.doubleClickOnItemName(parent))
.then(() => dataTable.sortByColumn('Name'))
.then(done); .then(done);
}); });
afterEach(done => {
browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
});
afterAll(done => { afterAll(done => {
logoutPage.load() logoutPage.load().then(done);
.then(() => {
nodesApi.deleteNodes([ content.name ]);
})
.then(done);
}); });
it('has default details', () => { it('default values', () => {
expect(pagination.range.getText()).toContain('1-25 of 101', 'Range'); expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25', 'Items per page'); expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1', 'Current page'); expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5', 'Total pages'); expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button'); expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button'); expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
}); });
it('has page sizes', () => { it('page sizes', () => {
pagination.openMaxItemsMenu() pagination.openMaxItemsMenu()
.then(menu => { .then(menu => {
const [ first, second, third ] = [1, 2, 3] const [ first, second, third ] = [1, 2, 3]
.map(nth => menu.getNthItem(nth).getText()); .map(nth => menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(first).toBe('25', 'Items per page'); expect(second).toBe('50');
expect(second).toBe('50', 'Items per page'); expect(third).toBe('100');
expect(third).toBe('100', 'Items per page');
}); });
}); });
it('changes the page size', () => { it('change the page size', () => {
pagination.openMaxItemsMenu() pagination.openMaxItemsMenu()
.then(menu => menu.clickMenuItem('50')) .then(menu => menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(() => { .then(() => {
expect(pagination.maxItems.getText()).toContain('50', 'Items per page'); expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3', 'Total pages'); expect(pagination.totalPages.getText()).toContain('of 3');
}); })
.then(() => resetToDefaultPageSize());
}); });
it('has page items', () => { it('current page menu items', () => {
pagination.openCurrentPageMenu() pagination.openCurrentPageMenu()
.then(menu => { .then(menu => {
expect(menu.items.count()).toBe(5); expect(menu.getItemsCount()).toBe(5);
}); });
}); });
it('changes the current page from menu', () => { it('change the current page from menu', () => {
pagination.openCurrentPageMenu() pagination.openCurrentPageMenu()
.then(menu => menu.clickNthItem(3)) .then(menu => menu.clickNthItem(3))
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(() => { .then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101', 'Range'); expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3', 'Current page'); expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button'); expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button'); expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowByContainingText('file-60.txt').isPresent()) expect(dataTable.getRowByContainingText('file-60.txt').isPresent())
.toBe(true, 'File not found on page'); .toBe(true, 'File not found on page');
}); })
.then(() => resetToDefaultPageNumber());
}); });
it('navigates to next page', () => { it('navigate to next page', () => {
pagination.nextButton.click() pagination.nextButton.click()
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(() => { .then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101', 'Range'); expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByContainingText('file-30.txt').isPresent()) expect(dataTable.getRowByContainingText('file-30.txt').isPresent())
.toBe(true, 'File not found on page'); .toBe(true, 'File not found on page');
}); })
.then(() => resetToDefaultPageNumber());
}); });
it('navigates to previous page', () => { it('navigate to previous page', () => {
pagination.openCurrentPageMenu() pagination.openCurrentPageMenu()
.then(menu => menu.clickNthItem(2)) .then(menu => menu.clickNthItem(2))
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click()) .then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(() => { .then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101', 'Range'); expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowByContainingText('file-12.txt').isPresent()) expect(dataTable.getRowByContainingText('file-12.txt').isPresent())
.toBe(true, 'File not found on page'); .toBe(true, 'File not found on page');
}); })
.then(() => resetToDefaultPageNumber());
}); });
it('has one item on the last page', () => { it('last page', () => {
pagination.openCurrentPageMenu() pagination.openCurrentPageMenu()
.then(menu => menu.clickNthItem(5)) .then(menu => menu.clickNthItem(5))
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(() => { .then(() => {
expect(dataTable.countRows()).toBe(1, 'Single item on the last page'); expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5', 'Last page'); expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is not enabled'); expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled');
});
});
});
describe(`on Recent Files`, () => {
beforeAll(done => {
loginPage.load()
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('default values', () => {
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('page sizes', () => {
pagination.openMaxItemsMenu()
.then(menu => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
});
});
it('change the page size', () => {
pagination.openMaxItemsMenu()
.then(menu => menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(menu => {
expect(menu.getItemsCount()).toBe(5);
});
});
it('change the current page from menu', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-40.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to next page', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByContainingText('file-70.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to previous page', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('last page', () => {
pagination.openCurrentPageMenu()
.then(menu => menu.clickNthItem(5))
.then(() => dataTable.waitForHeader())
.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');
});
});
});
describe(`on Favorites`, () => {
beforeAll(done => {
loginPage.load()
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('default values', () => {
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('page sizes', () => {
pagination.openMaxItemsMenu()
.then(menu => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
});
});
it('change the page size', () => {
pagination.openMaxItemsMenu()
.then(menu => menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(menu => {
expect(menu.getItemsCount()).toBe(5);
});
});
it('change the current page from menu', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-40.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to next page', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByContainingText('file-70.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to previous page', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('last page', () => {
pagination.openCurrentPageMenu()
.then(menu => menu.clickNthItem(5))
.then(() => dataTable.waitForHeader())
.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');
});
});
});
describe(`on Shared Files`, () => {
beforeAll(done => {
loginPage.load()
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('default values', () => {
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('page sizes', () => {
pagination.openMaxItemsMenu()
.then(menu => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
});
});
it('change the page size', () => {
pagination.openMaxItemsMenu()
.then(menu => menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(menu => {
expect(menu.getItemsCount()).toBe(5);
});
});
it('change the current page from menu', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-40.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to next page', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByContainingText('file-70.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to previous page', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('last page', () => {
pagination.openCurrentPageMenu()
.then(menu => menu.clickNthItem(5))
.then(() => dataTable.waitForHeader())
.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');
});
});
});
describe(`on Trash`, () => {
beforeAll(done => {
loginPage.load()
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('default values', () => {
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('page sizes', () => {
pagination.openMaxItemsMenu()
.then(menu => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
});
});
it('change the page size', () => {
pagination.openMaxItemsMenu()
.then(menu => menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(menu => {
expect(menu.getItemsCount()).toBe(5);
});
});
it('change the current page from menu', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-40.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to next page', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowByContainingText('file-70.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('navigate to previous page', () => {
pagination.openCurrentPageMenu()
.then(menu => 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.getRowByContainingText('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => resetToDefaultPageNumber());
});
it('last page', () => {
pagination.openCurrentPageMenu()
.then(menu => menu.clickNthItem(5))
.then(() => dataTable.waitForHeader())
.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');
}); });
}); });
}); });