Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACA] add more e2e tests #851

Merged
merged 1 commit into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"nginx",
"docx",
"SOLR",
"simpletask",

"unshare",
"qshare",
Expand Down
6 changes: 5 additions & 1 deletion e2e/components/data-table/data-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class DataTable extends Component {
cell: '.adf-data-table-cell',
locationLink: '.aca-location-link',
nameLink: '.dl-link',
libraryRole: 'app-library-role-column',

selectedIcon: '.mat-icon',

Expand Down Expand Up @@ -199,7 +200,6 @@ export class DataTable extends Component {
async selectItem(name: string) {
try{
const item = this.getRowFirstCell(name);
// await Utils.waitUntilElementClickable(item);
await item.click();

} catch (e) {
Expand Down Expand Up @@ -315,4 +315,8 @@ export class DataTable extends Component {
const count = await this.menu.getItemsCount();
return count > 0;
}

async getLibraryRole(name: string) {
return await this.getRowByName(name).element(by.css(DataTable.selectors.libraryRole)).getText();
}
}
7 changes: 1 addition & 6 deletions e2e/components/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ export class Menu extends Component {
}

async closeMenu() {
// if (await this.backdrop.isPresent()) {
// return await this.backdrop.click();
// } else {
// return await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform();
// }
return Utils.pressEscape();
}

Expand Down Expand Up @@ -148,7 +143,7 @@ export class Menu extends Component {
}

async isMenuItemPresent(title: string) {
return await this.component.element(by.cssContainingText(Menu.selectors.item, title)).isPresent();
return await browser.element(by.cssContainingText(Menu.selectors.item, title)).isPresent();
}

async isSubMenuItemPresent(title: string) {
Expand Down
3 changes: 2 additions & 1 deletion e2e/components/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import { Component } from '../component';
export class Toolbar extends Component {
private static selectors = {
root: '.adf-toolbar',
button: '.mat-icon-button'
// button: '.mat-icon-button'
button: 'button'
};

menu: Menu = new Menu();
Expand Down
2 changes: 1 addition & 1 deletion e2e/suites/actions/context-menu-multiple-selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Context menu actions - multiple selection : ', () => {
folder2Id = (await apis.user.nodes.createFolder(folder2)).entry.id;

await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC);
const docLibId = (await apis.user.sites.getDocLibId(siteName));
const docLibId = await apis.user.sites.getDocLibId(siteName);
await apis.user.nodes.createFile(file1Site, docLibId);
await apis.user.nodes.createFile(file2Site, docLibId);
await apis.user.nodes.createFolder(folder1Site, docLibId);
Expand Down
71 changes: 60 additions & 11 deletions e2e/suites/actions/context-menu-single-selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ describe('Context menu actions - single selection : ', () => {
const fileSiteUser = `fileUser-${Utils.random()}.txt`;
const folderSiteUser = `folderUser-${Utils.random()}`;

const adminPublic = `admin-public-${Utils.random()}`;
const adminModerated = `admin-moderated-${Utils.random()}`;

const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
Expand Down Expand Up @@ -73,6 +76,12 @@ describe('Context menu actions - single selection : ', () => {
await apis.user.favorites.addFavoriteById('folder', folderUserId);
await apis.user.favorites.waitForApi({ expect: 3 });

await apis.admin.sites.createSite(adminPublic);
await apis.admin.sites.createSite(adminModerated, SITE_VISIBILITY.MODERATED);
await apis.user.favorites.addFavoriteById('site', adminPublic);
await apis.user.favorites.addFavoriteById('site', adminModerated);
await apis.user.sites.requestToJoin(adminModerated);

await loginPage.loginWith(username);
done();
});
Expand All @@ -81,6 +90,8 @@ describe('Context menu actions - single selection : ', () => {
await apis.user.nodes.deleteNodeById(fileUserId);
await apis.user.nodes.deleteNodeById(folderUserId);
await apis.user.sites.deleteSite(siteName);
await apis.admin.sites.deleteSite(adminPublic);
await apis.admin.sites.deleteSite(adminModerated);
await apis.user.trashcan.emptyTrash();
done();
});
Expand Down Expand Up @@ -125,12 +136,6 @@ describe('Context menu actions - single selection : ', () => {
await page.sidenav.getActiveLink().click();
expect(await dataTable.hasContextMenu()).toBe(false, 'Context menu is displayed');
});

it('Context menu appears for a library - [C286276]', async () => {
await page.clickFileLibrariesAndWait();
await dataTable.rightClickOnItem(siteName);
expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is displayed for a site');
});
});

describe('on Personal Files', () => {
Expand Down Expand Up @@ -171,7 +176,7 @@ describe('Context menu actions - single selection : ', () => {
});
});

describe('File Libraries', () => {
describe('on File Libraries', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickFileLibrariesAndWait();
Expand Down Expand Up @@ -210,7 +215,51 @@ describe('Context menu actions - single selection : ', () => {
});
});

describe('Shared Files', () => {
describe('on a library', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await dataTable.clearSelection();
done();
});

it('Available actions when a library is selected - My Libraries - [C290080]', async () => {
await page.goToMyLibraries();
await dataTable.rightClickOnItem(siteName);
expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed');
expect(await contextMenu.isMenuItemPresent('Leave library')).toBe(true, `Leave is not displayed for ${siteName}`);
expect(await contextMenu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${siteName}`);
expect(await contextMenu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${siteName}`);
});

it('Available actions when a library is selected - Favorite Libraries - user is a member - [C290081]', async () => {
await page.goToFavoriteLibraries();
await dataTable.rightClickOnItem(siteName);
expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed');
expect(await contextMenu.isMenuItemPresent('Leave library')).toBe(true, `Leave is not displayed for ${siteName}`);
expect(await contextMenu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${siteName}`);
expect(await contextMenu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${siteName}`);
});

it('Available actions when a library is selected - Favorite Libraries - user is not a member - [C290082]', async () => {
await page.goToFavoriteLibraries();
await dataTable.rightClickOnItem(adminPublic);
expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed');
expect(await contextMenu.isMenuItemPresent('Join')).toBe(true, `Join is not displayed for ${adminPublic}`);
expect(await contextMenu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${adminPublic}`);
expect(await contextMenu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${adminPublic}`);
});

it('Available actions when a library is selected - Favorite Libraries - user requested to join - [C290089]', async () => {
await page.goToFavoriteLibraries();
await dataTable.rightClickOnItem(adminModerated);
expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed');
expect(await contextMenu.isMenuItemPresent('Cancel join')).toBe(true, `Cancel join is not displayed for ${adminModerated}`);
expect(await contextMenu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${adminModerated}`);
expect(await contextMenu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${adminModerated}`);
});
});

describe('on Shared Files', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickSharedFilesAndWait();
Expand All @@ -234,7 +283,7 @@ describe('Context menu actions - single selection : ', () => {
});
});

describe('Recent Files', () => {
describe('on Recent Files', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickRecentFilesAndWait();
Expand All @@ -257,7 +306,7 @@ describe('Context menu actions - single selection : ', () => {
});
});

describe('Favorites', () => {
describe('on Favorites', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickFavoritesAndWait();
Expand Down Expand Up @@ -296,7 +345,7 @@ describe('Context menu actions - single selection : ', () => {
});
});

describe('Trash', () => {
describe('on Trash', () => {
beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickTrashAndWait();
Expand Down
86 changes: 50 additions & 36 deletions e2e/suites/actions/create-folder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/

import { browser } from 'protractor';
import { SITE_VISIBILITY, SITE_ROLES } from '../../configs';
import { LoginPage, BrowsingPage } from '../../pages/pages';
import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog';
import { Menu } from '../../components/menu/menu';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';

Expand All @@ -41,7 +39,12 @@ describe('Create folder', () => {
const duplicateFolderName = `folder-${Utils.random()}`;
const nameWithSpaces = ` folder-${Utils.random()} `;

const siteName = `site-private-${Utils.random()}`;
const sitePrivate = `site-private-${Utils.random()}`;
const siteName = `site-${Utils.random()}`;

const folderSite = `folder-site-${Utils.random()}`;
const duplicateFolderSite = `folder-${Utils.random()}`;
let docLibUserSite;

const apis = {
admin: new RepoClient(),
Expand All @@ -52,22 +55,29 @@ describe('Create folder', () => {
const page = new BrowsingPage();
const createDialog = new CreateOrEditFolderDialog();
const { dataTable } = page;
const menu = new Menu();

beforeAll(async (done) => {
await apis.admin.people.createUser({ username });
await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE);
const docLibId = (await apis.admin.sites.getDocLibId(siteName));

await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE);
const docLibId = await apis.admin.sites.getDocLibId(sitePrivate);
await apis.admin.nodes.createFolder(folderName1, docLibId);
await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER.ROLE);
await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE);

parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFolder(duplicateFolderName, parentId);

await apis.user.sites.createSite(siteName);
docLibUserSite = await apis.user.sites.getDocLibId(siteName);
await apis.user.nodes.createFolder(duplicateFolderSite, docLibUserSite);

await loginPage.loginWith(username);
done();
});

afterAll(async (done) => {
await apis.admin.sites.deleteSite(siteName);
await apis.admin.sites.deleteSite(sitePrivate);
await apis.user.sites.deleteSite(siteName);
await apis.user.nodes.deleteNodeById(parentId);
done();
});
Expand All @@ -83,13 +93,6 @@ describe('Create folder', () => {
done();
});

it('option is enabled when having enough permissions - [C216339]', async () => {
await page.dataTable.doubleClickOnRowByName(parent);
await page.sidenav.openNewMenu();
const isEnabled = await menu.getItemByLabel('Create folder').isEnabled();
expect(isEnabled).toBe(true, 'Create folder is not enabled');
});

it('creates new folder with name - [C216341]', async () => {
await page.dataTable.doubleClickOnRowByName(parent);
await page.sidenav.openCreateFolderDialog();
Expand All @@ -112,18 +115,11 @@ describe('Create folder', () => {
await createDialog.waitForDialogToClose();
await dataTable.waitForHeader();
expect(await dataTable.getRowByName(folderName2).isPresent()).toBe(true, 'Folder not displayed');
const desc = await apis.user.nodes.getNodeDescription(folderName2, parent);
const desc = await apis.user.nodes.getNodeDescription(folderName2, parentId);
expect(desc).toEqual(folderDescription);
done();
});

it('enabled option tooltip - [C216342]', async () => {
await page.dataTable.doubleClickOnRowByName(parent);
await page.sidenav.openNewMenu();
await browser.actions().mouseMove(menu.getItemByLabel('Create folder')).perform();
expect(await menu.getItemTooltip('Create folder')).toContain('Create new folder');
});

it('dialog UI elements - [C216345]', async () => {
await page.dataTable.doubleClickOnRowByName(parent);
await page.sidenav.openCreateFolderDialog();
Expand Down Expand Up @@ -238,21 +234,39 @@ describe('Create folder', () => {
done();
});

it('option is disabled when not enough permissions - [C280397]', async () => {
await fileLibrariesPage.dataTable.doubleClickOnRowByName(siteName);
await fileLibrariesPage.dataTable.doubleClickOnRowByName(folderName1);
await fileLibrariesPage.sidenav.openNewMenu();
const isEnabled = await menu.getItemByLabel('Create folder').isEnabled();
expect(isEnabled).toBe(false, 'Create folder is not disabled');
it('creates new folder with name and description - [C280394]', async () => {
await page.dataTable.doubleClickOnRowByName(siteName);
await page.sidenav.openCreateFolderDialog();
await createDialog.waitForDialogToOpen();
await createDialog.enterName(folderSite);
await createDialog.enterDescription(folderDescription);
await createDialog.clickCreate();
await createDialog.waitForDialogToClose();
await dataTable.waitForHeader();
expect(await dataTable.getRowByName(folderSite).isPresent()).toBe(true, 'Folder not displayed');
const desc = await apis.user.nodes.getNodeDescription(folderSite, docLibUserSite);
expect(desc).toEqual(folderDescription);
});

it('cancel folder creation - [C280403]', async () => {
await page.dataTable.doubleClickOnRowByName(siteName);
await page.sidenav.openCreateFolderDialog();
await createDialog.waitForDialogToOpen();
await createDialog.enterName('test');
await createDialog.enterDescription('test description');
await createDialog.clickCancel();
expect(await createDialog.isDialogOpen()).not.toBe(true, 'dialog is not closed');
});

it('disabled option tooltip - [C280398]', async () => {
await fileLibrariesPage.dataTable.doubleClickOnRowByName(siteName);
await fileLibrariesPage.dataTable.doubleClickOnRowByName(folderName1);
await fileLibrariesPage.sidenav.openNewMenu();
await browser.actions().mouseMove(menu.getItemByLabel('Create folder')).perform();
const tooltip = await menu.getItemTooltip('Create folder');
expect(tooltip).toContain(`Folders cannot be created whilst viewing the current items`);
it('duplicate folder name - [C280404]', async () => {
await page.dataTable.doubleClickOnRowByName(siteName);
await page.sidenav.openCreateFolderDialog();
await createDialog.waitForDialogToOpen();
await createDialog.enterName(duplicateFolderSite);
await createDialog.clickCreate();
const message = await page.getSnackBarMessage();
expect(message).toEqual(`There's already a folder with this name. Try a different name.`);
expect(await createDialog.isDialogOpen()).toBe(true, 'dialog is not present');
});
});

Expand Down
9 changes: 0 additions & 9 deletions e2e/suites/actions/create-library.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/

import { browser } from 'protractor';
import { SITE_VISIBILITY } from '../../configs';
import { LoginPage, BrowsingPage } from '../../pages/pages';
import { CreateLibraryDialog } from '../../components/dialog/create-library-dialog';
import { Menu } from '../../components/menu/menu';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';

Expand Down Expand Up @@ -62,7 +60,6 @@ describe('Create library', () => {
const loginPage = new LoginPage();
const page = new BrowsingPage();
const createDialog = new CreateLibraryDialog();
const menu = new Menu();
const { dataTable } = page;

beforeAll(async (done) => {
Expand Down Expand Up @@ -215,10 +212,4 @@ describe('Create library', () => {
expect(await apis.user.sites.getTitle(`${duplicateSite.id}-2`)).toEqual(duplicateSite.name);
});

it('Tooltip for "Create Library" button - [C286526]', async () => {
await page.sidenav.openNewMenu();
await browser.actions().mouseMove(menu.getItemByLabel('Create Library')).perform();
expect(await menu.getItemTooltip('Create Library')).toContain('Create a new File Library');
});

});
Loading