From 1b879a22052e50f3ed6b0da3c5cc549a098cefb7 Mon Sep 17 00:00:00 2001 From: Adina Parpalita <Adina.Parpalita@ness.com> Date: Tue, 14 Nov 2017 11:14:22 +0200 Subject: [PATCH] add tests for empty pages --- e2e/components/data-table/data-table.ts | 53 ++++++++++++- e2e/suites/list-views/empty-list.test.ts | 99 ++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 e2e/suites/list-views/empty-list.test.ts diff --git a/e2e/components/data-table/data-table.ts b/e2e/components/data-table/data-table.ts index 43040b3d8..7bce349e2 100644 --- a/e2e/components/data-table/data-table.ts +++ b/e2e/components/data-table/data-table.ts @@ -31,11 +31,21 @@ export class DataTable extends Component { `, body: 'table > tbody', - row: 'tr' + row: 'tr', + + emptyListContainer: 'td.adf-no-content-container', + emptyFolderDragAndDrop: '.adf-empty-list_template .adf-empty-folder', + + emptyListTitle: 'div .empty-list__title', + emptyListText: 'div .empty-list__text' }; - private head: ElementFinder = this.component.element(by.css(DataTable.selectors.head)); - private body: ElementFinder = this.component.element(by.css(DataTable.selectors.body)); + head: ElementFinder = this.component.element(by.css(DataTable.selectors.head)); + body: ElementFinder = this.component.element(by.css(DataTable.selectors.body)); + emptyList: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer)); + emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop)); + emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle)); + emptyListText: ElementArrayFinder = this.component.all(by.css(DataTable.selectors.emptyListText)); constructor(ancestor?: ElementFinder) { super(DataTable.selectors.root, ancestor); @@ -46,7 +56,9 @@ export class DataTable extends Component { return browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT); } - // waitForEmptyState() {} + waitForEmptyState() { + return browser.wait(EC.presenceOf(this.emptyList), BROWSER_WAIT_TIMEOUT); + } // Header/Column methods getColumnHeaders(): ElementArrayFinder { @@ -107,4 +119,37 @@ export class DataTable extends Component { return click.perform(); } + + // empty state methods + isEmptyList(): promise.Promise<boolean> { + return this.emptyList.isPresent(); + } + + isEmptyWithDragAndDrop(): promise.Promise<boolean> { + return this.emptyFolderDragAndDrop.isDisplayed(); + } + + getEmptyDragAndDropText(): promise.Promise<string> { + return this.isEmptyWithDragAndDrop() + .then(() => { + return this.emptyFolderDragAndDrop.getText(); + }) + .catch(() => ''); + } + + getEmptyStateTitle(): promise.Promise<string> { + return this.isEmptyList() + .then(() => { + return this.emptyListTitle.getText(); + }) + .catch(() => ''); + } + + getEmptyStateText(): promise.Promise<string> { + return this.isEmptyList() + .then(() => { + return this.emptyListText.getText(); + }) + .catch(() => ''); + } } diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts new file mode 100644 index 000000000..f344e0662 --- /dev/null +++ b/e2e/suites/list-views/empty-list.test.ts @@ -0,0 +1,99 @@ +/*! + * @license + * Copyright 2017 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { browser, by } from 'protractor'; + +import { APP_ROUTES, SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs'; +import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; +import { Utils } from '../../utilities/utils'; +import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client'; + +fdescribe('Empty list views', () => { + const username = `user-${Utils.random()}`; + const password = username; + + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, password) + }; + + const loginPage = new LoginPage(); + const logoutPage = new LogoutPage(); + const page = new BrowsingPage(); + const { dataTable } = page; + + beforeAll(done => { + apis.admin.people.createUser(username) + .then(() => loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done)); + }); + + it('empty Personal Files', () => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES) + .then(() => { + expect(dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(dataTable.getEmptyDragAndDropText()).toContain('Drag and drop'); + }); + }); + + it('empty File Libraries', () => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES) + .then(() => { + expect(dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(dataTable.getEmptyStateTitle()).toContain(`You aren't a member of any File Libraries yet`); + expect(dataTable.getEmptyStateText()).toContain('Join sites to upload, view, and share files.'); + }); + }); + + it('empty Shared Files', () => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES) + .then(() => { + expect(dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(dataTable.getEmptyStateTitle()).toContain('No shared files or folders'); + expect(dataTable.getEmptyStateText()).toContain('Items you share using the Share option are shown here.'); + }); + }); + + it('empty Recent Files', () => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES) + .then(() => { + expect(dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(dataTable.getEmptyStateTitle()).toContain('No recent files'); + expect(dataTable.getEmptyStateText()).toContain('Items you upload or edit in the last 30 days are shown here.'); + }); + }); + + it('empty Favorites', () => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES) + .then(() => { + expect(dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(dataTable.getEmptyStateTitle()).toContain('No favorite files or folders'); + expect(dataTable.getEmptyStateText()).toContain('Favorite items that you want to easily find later.'); + }); + }); + + it('empty Trash', () => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH) + .then(() => { + expect(dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(dataTable.getEmptyStateTitle()).toContain('Trash is empty'); + expect(dataTable.getEmptyStateText()).toContain('Items you delete are moved to the Trash.'); + expect(dataTable.getEmptyStateText()).toContain('Empty Trash to permanently delete items.'); + }); + }); +});