[ACA-990] stabilise e2e tests (#104)

This commit is contained in:
Adina Parpalita 2017-12-01 13:12:24 +02:00 committed by Denys Vuika
parent 2ce7d57737
commit 2d6ae127aa
6 changed files with 222 additions and 286 deletions

View File

@ -21,11 +21,11 @@ import { Component } from '../component';
export class CreateOrEditFolderDialog extends Component { export class CreateOrEditFolderDialog extends Component {
private static selectors = { private static selectors = {
root: '.mat-dialog-container', root: 'adf-folder-dialog',
title: '.mat-dialog-title', title: '.mat-dialog-title',
nameInput: '.mat-dialog-container .mat-input-element[placeholder="Name"]', nameInput: 'input',
descriptionTextArea: '.mat-dialog-container .mat-input-element[placeholder="Description"]', descriptionTextArea: 'textarea',
button: '.mat-dialog-actions button', button: '.mat-dialog-actions button',
validationMessage: '.mat-hint span' validationMessage: '.mat-hint span'
}; };
@ -64,33 +64,27 @@ export class CreateOrEditFolderDialog extends Component {
.catch(() => ''); .catch(() => '');
} }
enterName(name: string): CreateOrEditFolderDialog { enterName(name: string): promise.Promise<CreateOrEditFolderDialog> {
const { nameInput } = this; return this.nameInput.clear()
.then(() => this.nameInput.sendKeys(name))
.then(() => this);
}
nameInput.clear(); enterDescription(description: string): promise.Promise<CreateOrEditFolderDialog> {
nameInput.sendKeys(name); return this.descriptionTextArea.clear()
.then(() => {
return this; browser.actions().click(this.descriptionTextArea).sendKeys(description).perform();
})
.then(() => this);
} }
deleteNameWithBackspace(): promise.Promise<void> { deleteNameWithBackspace(): promise.Promise<void> {
const { nameInput } = this; return this.nameInput.clear()
return nameInput.clear()
.then(() => { .then(() => {
return nameInput.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE); return this.nameInput.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
}); });
} }
enterDescription(description: string): CreateOrEditFolderDialog {
const { descriptionTextArea } = this;
descriptionTextArea.clear();
descriptionTextArea.sendKeys(description);
return this;
}
clickCreate() { clickCreate() {
return this.createButton.click(); return this.createButton.click();
} }

View File

@ -17,7 +17,7 @@
import { protractor, browser, by, ElementFinder } from 'protractor'; import { protractor, browser, by, ElementFinder } from 'protractor';
import { APP_ROUTES, BROWSER_WAIT_TIMEOUT, SITE_VISIBILITY, SITE_ROLES } from '../../configs'; import { SIDEBAR_LABELS, BROWSER_WAIT_TIMEOUT, SITE_VISIBILITY, SITE_ROLES } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog'; import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog';
import { Utils } from '../../utilities/utils'; import { Utils } from '../../utilities/utils';
@ -42,16 +42,13 @@ describe('Create folder', () => {
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const logoutPage = new LogoutPage(); const logoutPage = new LogoutPage();
const personalFilesPage = new BrowsingPage(APP_ROUTES.PERSONAL_FILES); const personalFilesPage = new BrowsingPage();
const createDialog = new CreateOrEditFolderDialog(); const createDialog = new CreateOrEditFolderDialog();
const dataTable = personalFilesPage.dataTable; const { dataTable } = personalFilesPage;
function openCreateDialog(): any { function openCreateDialog(): any {
return personalFilesPage.sidenav return personalFilesPage.sidenav.openNewMenu()
.openNewMenu() .then(menu => menu.clickMenuItem('Create folder'))
.then((menu) => {
menu.clickMenuItem('Create folder');
})
.then(() => createDialog.waitForDialogToOpen()); .then(() => createDialog.waitForDialogToOpen());
} }
@ -61,25 +58,25 @@ describe('Create folder', () => {
.then(() => apis.admin.nodes.createFolders([ folderName1 ], `Sites/${siteName}/documentLibrary`)) .then(() => apis.admin.nodes.createFolders([ folderName1 ], `Sites/${siteName}/documentLibrary`))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.user.nodes.createFolders([ duplicateFolderName ], parent)) .then(() => apis.user.nodes.createFolders([ duplicateFolderName ], parent))
.then(() => loginPage.load() .then(() => loginPage.load())
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
.then(done)); .then(done);
}); });
beforeEach(done => { beforeEach(done => {
personalFilesPage.load() personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(done); .then(done);
}); });
afterEach(done => { afterEach(done => {
browser.$('body').sendKeys(protractor.Key.ESCAPE).then(done); browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
}); });
afterAll(done => { afterAll(done => {
Promise Promise
.all([ .all([
apis.admin.sites.deleteSite(siteName, true), apis.admin.sites.deleteSite(siteName),
apis.user.nodes.deleteNodes([ parent ]), apis.user.nodes.deleteNodes([ parent ]),
logoutPage.load() logoutPage.load()
]) ])
@ -88,214 +85,187 @@ describe('Create folder', () => {
it('option is enabled when having enough permissions', () => { it('option is enabled when having enough permissions', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openNewMenu() .then(() => personalFilesPage.sidenav.openNewMenu())
.then((menu) => { .then(menu => {
const isEnabled = menu.getItemByLabel('Create folder').getWebElement().isEnabled(); const isEnabled = menu.getItemByLabel('Create folder').isEnabled();
expect(isEnabled).toBe(true, 'Create folder is not enabled');
expect(isEnabled).toBe(true, 'Create folder is not enabled'); });
})
);
}); });
it('creates new folder with name', () => { it('creates new folder with name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => createDialog.enterName(folderName1).clickCreate()) .then(() => createDialog.enterName(folderName1))
.then(() => createDialog.waitForDialogToClose()) .then(() => createDialog.clickCreate())
.then(() => dataTable.waitForHeader()) .then(() => createDialog.waitForDialogToClose())
.then(() => { .then(() => dataTable.waitForHeader())
const isPresent = dataTable.getRowByName(folderName1).isPresent(); .then(() => {
expect(isPresent).toBe(true, 'Folder not displayed in list view'); const isPresent = dataTable.getRowByName(folderName1).isPresent();
}) expect(isPresent).toBe(true, 'Folder not displayed in list view');
); });
}); });
it('creates new folder with name and description', () => { it('creates new folder with name and description', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => { .then(() => createDialog.enterName(folderName2))
createDialog .then(() => createDialog.enterDescription(folderDescription))
.enterName(folderName2) .then(() => createDialog.clickCreate())
.enterDescription(folderDescription) .then(() => createDialog.waitForDialogToClose())
.clickCreate(); .then(() => dataTable.waitForHeader())
}) .then(() => {
.then(() => createDialog.waitForDialogToClose()) const isPresent = dataTable.getRowByName(folderName2).isPresent();
.then(() => dataTable.waitForHeader()) expect(isPresent).toBe(true, 'Folder not displayed in list view');
.then(() => { })
const isPresent = dataTable.getRowByName(folderName2).isPresent(); .then(() => {
expect(isPresent).toBe(true, 'Folder not displayed in list view'); expect(apis.user.nodes.getNodeDescription(folderName2)).toEqual(folderDescription);
}) });
.then(() => {
apis.user.nodes.getNodeDescription(folderName2)
.then((description) => expect(description).toEqual(folderDescription));
})
);
}); });
it('enabled option tooltip', () => { it('enabled option tooltip', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openNewMenu() .then(() => personalFilesPage.sidenav.openNewMenu())
.then(menu => { .then(menu => browser.actions().mouseMove(menu.getItemByLabel('Create folder')).perform()
const action = browser.actions().mouseMove(menu.getItemByLabel('Create folder')); .then(() => menu))
action.perform(); .then(menu => {
expect(menu.getItemTooltip('Create folder')).toContain('Create new folder');
return menu; });
})
.then((menu) => {
const tooltip = menu.getItemTooltip('Create folder');
expect(tooltip).toContain('Create new folder');
})
);
}); });
it('option is disabled when not enough permissions', () => { it('option is disabled when not enough permissions', () => {
const fileLibrariesPage = new BrowsingPage(APP_ROUTES.FILE_LIBRARIES); const fileLibrariesPage = new BrowsingPage();
fileLibrariesPage.sidenav.navigateToLinkByLabel('File Libraries') fileLibrariesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName)) .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1)) .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1))
.then(() => fileLibrariesPage.sidenav.openNewMenu()) .then(() => fileLibrariesPage.sidenav.openNewMenu())
.then(menu => { .then(menu => {
const isEnabled = menu.getItemByLabel('Create folder').getWebElement().isEnabled(); const isEnabled = menu.getItemByLabel('Create folder').isEnabled();
expect(isEnabled).toBe(false, 'Create folder is not disabled'); expect(isEnabled).toBe(false, 'Create folder is not disabled');
}); });
}); });
it('disabled option tooltip', () => { it('disabled option tooltip', () => {
const fileLibrariesPage = new BrowsingPage(APP_ROUTES.FILE_LIBRARIES); const fileLibrariesPage = new BrowsingPage();
fileLibrariesPage.sidenav.navigateToLinkByLabel('File Libraries') fileLibrariesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName)) .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1)) .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1))
.then(() => fileLibrariesPage.sidenav.openNewMenu()) .then(() => fileLibrariesPage.sidenav.openNewMenu())
.then(menu => browser.actions().mouseMove(menu.getItemByLabel('Create folder')).perform()
.then(() => menu))
.then(menu => { .then(menu => {
const action = browser.actions().mouseMove(menu.getItemByLabel('Create folder')); const tooltip = menu.getItemTooltip('Create folder');
action.perform() expect(tooltip).toContain(`You can't create a folder here`);
.then(() => {
const tooltip = menu.getItemTooltip('Create folder');
expect(tooltip).toContain(`You can't create a folder here`);
});
}); });
}); });
it('dialog UI elements', () => { it('dialog UI elements', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog().then(() => { .then(() => openCreateDialog())
.then(() => {
const dialogTitle = createDialog.getTitle(); const dialogTitle = createDialog.getTitle();
const isFolderNameDisplayed = createDialog.nameInput.getWebElement().isDisplayed(); const isFolderNameDisplayed = createDialog.nameInput.isDisplayed();
const isDescriptionDisplayed = createDialog.descriptionTextArea.getWebElement().isDisplayed(); const isDescriptionDisplayed = createDialog.descriptionTextArea.isDisplayed();
const isCreateEnabled = createDialog.createButton.getWebElement().isEnabled(); const isCreateEnabled = createDialog.createButton.isEnabled();
const isCancelEnabled = createDialog.cancelButton.getWebElement().isEnabled(); const isCancelEnabled = createDialog.cancelButton.isEnabled();
expect(dialogTitle).toBe('Create new folder'); expect(dialogTitle).toMatch('Create new folder');
expect(isFolderNameDisplayed).toBe(true, 'Name input is not displayed'); expect(isFolderNameDisplayed).toBe(true, 'Name input is not displayed');
expect(isDescriptionDisplayed).toBe(true, 'Description field is not displayed'); expect(isDescriptionDisplayed).toBe(true, 'Description field is not displayed');
expect(isCreateEnabled).toBe(false, 'Create button is not disabled'); expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(isCancelEnabled).toBe(true, 'Cancel button is not enabled'); expect(isCancelEnabled).toBe(true, 'Cancel button is not enabled');
}) });
);
}); });
it('with empty folder name', () => { it('with empty folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => { .then(() => createDialog.deleteNameWithBackspace())
createDialog.deleteNameWithBackspace(); .then(() => {
}) const isCreateEnabled = createDialog.createButton.isEnabled();
.then(() => { const validationMessage = createDialog.getValidationMessage();
const isCreateEnabled = createDialog.createButton.getWebElement().isEnabled();
const validationMessage = createDialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is enabled'); expect(isCreateEnabled).toBe(false, 'Create button is enabled');
expect(validationMessage).toMatch('Folder name is required'); expect(validationMessage).toMatch('Folder name is required');
}) });
);
}); });
it('with folder name ending with a dot "."', () => { it('with folder name ending with a dot "."', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => createDialog.enterName('folder-name.')) .then(() => createDialog.enterName('folder-name.'))
.then((dialog) => { .then(dialog => {
const isCreateEnabled = dialog.createButton.getWebElement().isEnabled(); const isCreateEnabled = dialog.createButton.isEnabled();
const validationMessage = dialog.getValidationMessage(); const validationMessage = dialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is not disabled'); expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(validationMessage).toMatch(`Folder name can't end with a period .`); expect(validationMessage).toMatch(`Folder name can't end with a period .`);
}) });
);
}); });
it('with folder name containing special characters', () => { it('with folder name containing special characters', () => {
const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ];
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => { .then(() => namesWithSpecialChars.forEach(name => {
namesWithSpecialChars.forEach(name => { createDialog.enterName(name);
createDialog.enterName(name);
const isCreateEnabled = createDialog.createButton.getWebElement().isEnabled(); const isCreateEnabled = createDialog.createButton.isEnabled();
const validationMessage = createDialog.getValidationMessage(); const validationMessage = createDialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is not disabled'); expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(validationMessage).toContain(`Folder name can't contain these characters`); expect(validationMessage).toContain(`Folder name can't contain these characters`);
}); }));
})
);
}); });
it('with folder name containing only spaces', () => { it('with folder name containing only spaces', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => createDialog.enterName(' ')) .then(() => createDialog.enterName(' '))
.then((dialog) => { .then(dialog => {
const isCreateEnabled = dialog.createButton.getWebElement().isEnabled(); const isCreateEnabled = dialog.createButton.isEnabled();
const validationMessage = dialog.getValidationMessage(); const validationMessage = dialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is not disabled'); expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(validationMessage).toMatch(`Folder name can't contain only spaces`); expect(validationMessage).toMatch(`Folder name can't contain only spaces`);
}) });
);
}); });
it('cancel folder creation', () => { it('cancel folder creation', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => { .then(() => createDialog.enterName('test'))
createDialog .then(() => createDialog.enterDescription('test description'))
.enterName('test') .then(() => createDialog.clickCancel())
.enterDescription('test description') .then(() => {
.clickCancel(); expect(createDialog.component.isPresent()).not.toBe(true, 'dialog is not closed');
}) });
.then(() => expect(createDialog.component.isPresent()).not.toBe(true, 'dialog is not closed'))
);
}); });
it('duplicate folder name', () => { it('duplicate folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => createDialog.enterName(duplicateFolderName).clickCreate()) .then(() => createDialog.enterName(duplicateFolderName))
.then(() => { .then(() => createDialog.clickCreate())
personalFilesPage.getSnackBarMessage() .then(() => personalFilesPage.getSnackBarMessage())
.then(message => { .then(message => {
expect(message).toEqual(`There's already a folder with this name. Try a different name.`); expect(message).toEqual(`There's already a folder with this name. Try a different name.`);
expect(createDialog.component.isPresent()).toBe(true, 'dialog is not present'); expect(createDialog.component.isPresent()).toBe(true, 'dialog is not present');
}); });
})
);
}); });
it('trim ending spaces from folder name', () => { it('trim ending spaces from folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog() .then(() => openCreateDialog())
.then(() => createDialog.enterName(nameWithSpaces).clickCreate()) .then(() => createDialog.enterName(nameWithSpaces))
.then(() => createDialog.waitForDialogToClose()) .then(() => createDialog.clickCreate())
.then(() => dataTable.waitForHeader()) .then(() => createDialog.waitForDialogToClose())
.then(() => { .then(() => dataTable.waitForHeader())
const isPresent = dataTable.getRowByName(nameWithSpaces.trim()).isPresent(); .then(() => {
expect(isPresent).toBe(true, 'Folder not displayed in list view'); const isPresent = dataTable.getRowByName(nameWithSpaces.trim()).isPresent();
}) expect(isPresent).toBe(true, 'Folder not displayed in list view');
); });
}); });
}); });

View File

@ -17,7 +17,7 @@
import { protractor, element, browser, by, ElementFinder, promise } from 'protractor'; import { protractor, element, browser, by, ElementFinder, promise } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { APP_ROUTES, SITE_VISIBILITY, SITE_ROLES } from '../../configs'; import { SIDEBAR_LABELS, SITE_VISIBILITY, SITE_ROLES } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client'; import { RepoClient } from '../../utilities/repo-client/repo-client';
import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog'; import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog';
import { Utils } from '../../utilities/utils'; import { Utils } from '../../utilities/utils';
@ -44,42 +44,40 @@ describe('Edit folder', () => {
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const logoutPage = new LogoutPage(); const logoutPage = new LogoutPage();
const personalFilesPage = new BrowsingPage(APP_ROUTES.PERSONAL_FILES); const personalFilesPage = new BrowsingPage();
const editDialog = new CreateOrEditFolderDialog(); const editDialog = new CreateOrEditFolderDialog();
const dataTable = personalFilesPage.dataTable; const { dataTable } = personalFilesPage;
const editButton = personalFilesPage.toolbar.actions.getButtonByTitleAttribute('Edit'); const editButton = personalFilesPage.toolbar.actions.getButtonByTitleAttribute('Edit');
beforeAll(done => { beforeAll(done => {
Promise apis.admin.people.createUser(username)
.all([ .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE))
apis.admin.people.createUser(username), .then(() => apis.admin.nodes.createFolders([ folderName ], `Sites/${siteName}/documentLibrary`))
apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE)
.then(() => apis.admin.nodes.createFolders([ folderName ], `Sites/${siteName}/documentLibrary`))
])
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER))
.then(() => Promise.all([
apis.user.nodes.createNodeWithProperties( folderName, '', folderDescription, parent ), .then(() => apis.user.nodes.createNodeWithProperties( folderName, '', folderDescription, parent ))
apis.user.nodes.createFolders([ folderNameToEdit, duplicateFolderName ], parent) .then(() => apis.user.nodes.createFolders([ folderNameToEdit, duplicateFolderName ], parent))
])) .then(() => loginPage.load())
.then(() => loginPage.load() .then(() => loginPage.loginWith(username))
.then(() => loginPage.loginWith(username)) .then(done);
.then(done));
}); });
beforeEach(done => { beforeEach(done => {
personalFilesPage.load() personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(parent))
.then(() => dataTable.waitForHeader()) .then(() => dataTable.waitForHeader())
.then(done); .then(done);
}); });
afterEach(done => { afterEach(done => {
browser.$('body').sendKeys(protractor.Key.ESCAPE).then(done); browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
}); });
afterAll(done => { afterAll(done => {
Promise Promise
.all([ .all([
apis.admin.sites.deleteSite(siteName, true), apis.admin.sites.deleteSite(siteName),
apis.user.nodes.deleteNodes([ parent ]), apis.user.nodes.deleteNodes([ parent ]),
logoutPage.load() logoutPage.load()
]) ])
@ -87,124 +85,98 @@ describe('Edit folder', () => {
}); });
it('dialog UI defaults', () => { it('dialog UI defaults', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderName)
.then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => {
.then(() => { expect(editDialog.getTitle()).toEqual('Edit folder');
expect(editDialog.getTitle()).toBe('Edit folder'); expect(editDialog.nameInput.getAttribute('value')).toBe(folderName);
expect(editDialog.nameInput.getWebElement().getAttribute('value')).toBe(folderName); expect(editDialog.descriptionTextArea.getAttribute('value')).toBe(folderDescription);
expect(editDialog.descriptionTextArea.getWebElement().getAttribute('value')).toBe(folderDescription); expect(editDialog.updateButton.isEnabled()).toBe(true, 'upload button is not enabled');
expect(editDialog.updateButton.getWebElement().isEnabled()).toBe(true, 'upload button is not enabled'); expect(editDialog.cancelButton.isEnabled()).toBe(true, 'cancel button is not enabled');
expect(editDialog.cancelButton.getWebElement().isEnabled()).toBe(true, 'cancel button is not enabled'); });
})
);
}); });
it('properties are modified when pressing OK', () => { it('properties are modified when pressing OK', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderNameToEdit)
.then(() => dataTable.clickOnItemName(folderNameToEdit) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => editDialog.waitForDialogToOpen())
.then(() => { .then(() => editDialog.enterName(folderNameEdited))
editDialog .then(() => editDialog.enterDescription(folderDescriptionEdited))
.enterName(folderNameEdited) .then(() => editDialog.clickUpdate())
.enterDescription(folderDescriptionEdited) .then(() => editDialog.waitForDialogToClose())
.clickUpdate(); .then(() => dataTable.waitForHeader())
}) .then(() => {
.then(() => editDialog.waitForDialogToClose()) const isPresent = dataTable.getRowByName(folderNameEdited).isPresent();
.then(() => dataTable.waitForHeader()) expect(isPresent).toBe(true, 'Folder not displayed in list view');
.then(() => { })
const isPresent = dataTable.getRowByName(folderNameEdited).isPresent(); .then(() => {
expect(isPresent).toBe(true, 'Folder not displayed in list view'); expect(apis.user.nodes.getNodeDescription(folderNameEdited)).toEqual(folderDescriptionEdited);
}) });
.then(() => {
apis.user.nodes.getNodeDescription(folderNameEdited)
.then((description) => {
expect(description).toEqual(folderDescriptionEdited);
});
})
);
}); });
it('with empty folder name', () => { it('with empty folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderName)
.then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => editDialog.deleteNameWithBackspace())
.then(() => { .then(() => {
editDialog.deleteNameWithBackspace(); expect(editDialog.updateButton.isEnabled()).toBe(false, 'upload button is not enabled');
}) expect(editDialog.getValidationMessage()).toMatch('Folder name is required');
.then(() => { });
expect(editDialog.updateButton.getWebElement().isEnabled()).toBe(false, 'upload button is not enabled');
expect(editDialog.getValidationMessage()).toMatch('Folder name is required');
})
);
}); });
it('with name with special characters', () => { it('with name with special characters', () => {
const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ];
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderName)
.then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => namesWithSpecialChars.forEach(name => {
.then(() => { editDialog.enterName(name);
namesWithSpecialChars.forEach(name => {
editDialog.enterName(name);
expect(editDialog.updateButton.getWebElement().isEnabled()).toBe(false, 'upload button is not disabled'); expect(editDialog.updateButton.isEnabled()).toBe(false, 'upload button is not disabled');
expect(editDialog.getValidationMessage()).toContain(`Folder name can't contain these characters`); expect(editDialog.getValidationMessage()).toContain(`Folder name can't contain these characters`);
}); }));
})
);
}); });
it('with name ending with a dot', () => { it('with name ending with a dot', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderName)
.then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => editDialog.nameInput.sendKeys('.'))
.then(() => editDialog.nameInput.sendKeys('.')) .then(() => {
.then(() => { expect(editDialog.updateButton.isEnabled()).toBe(false, 'upload button is not enabled');
expect(editDialog.updateButton.getWebElement().isEnabled()).toBe(false, 'upload button is not enabled'); expect(editDialog.getValidationMessage()).toMatch(`Folder name can't end with a period .`);
expect(editDialog.getValidationMessage()).toMatch(`Folder name can't end with a period .`); });
})
);
}); });
it('Cancel button', () => { it('Cancel button', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderName)
.then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => editDialog.clickCancel())
.then(() => editDialog.clickCancel()) .then(() => {
.then(() => { expect(editDialog.component.isPresent()).not.toBe(true, 'dialog is not closed');
expect(editDialog.component.isPresent()).not.toBe(true, 'dialog is not closed'); });
})
);
}); });
it('with duplicate folder name', () => { it('with duplicate folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderName)
.then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => editDialog.enterName(duplicateFolderName))
.then(() => editDialog.enterName(duplicateFolderName).clickUpdate()) .then(() => editDialog.clickUpdate())
.then(() => { .then(() => personalFilesPage.getSnackBarMessage())
personalFilesPage.getSnackBarMessage() .then(message => {
.then(message => { expect(message).toEqual(`There's already a folder with this name. Try a different name.`);
expect(message).toEqual(`There's already a folder with this name. Try a different name.`); expect(editDialog.component.isPresent()).toBe(true, 'dialog is not present');
expect(editDialog.component.isPresent()).toBe(true, 'dialog is not present'); });
});
})
);
}); });
it('trim ending spaces', () => { it('trim ending spaces', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent) dataTable.clickOnItemName(folderName)
.then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click())
.then(() => editButton.click()) .then(() => editDialog.nameInput.sendKeys(' '))
.then(() => editDialog.nameInput.sendKeys(' ')) .then(() => editDialog.clickUpdate())
.then(() => editDialog.clickUpdate()) .then(() => editDialog.waitForDialogToClose())
.then(() => editDialog.waitForDialogToClose()) .then(() => {
.then(() => { expect(personalFilesPage.snackBar.isPresent()).not.toBe(true, 'notification appears');
expect(personalFilesPage.snackBar.isPresent()).not.toBe(true, 'notification appears'); expect(dataTable.getRowByName(folderName).isPresent()).toBe(true, 'Folder not displayed in list view');
expect(dataTable.getRowByName(folderName).isPresent()).toBe(true, 'Folder not displayed in list view'); });
})
);
}); });
}); });

View File

@ -66,7 +66,7 @@ describe('Permanently delete from Trash', () => {
afterAll(done => { afterAll(done => {
Promise.all([ Promise.all([
apis.user.trashcan.emptyTrash(), apis.admin.trashcan.emptyTrash(),
logoutPage.load() logoutPage.load()
]) ])
.then(done); .then(done);

View File

@ -70,7 +70,7 @@ describe('Restore from Trash', () => {
Promise.all([ Promise.all([
apis.user.nodes.deleteNodesById(filesIds), apis.user.nodes.deleteNodesById(filesIds),
apis.user.nodes.deleteNodesById(foldersIds), apis.user.nodes.deleteNodesById(foldersIds),
apis.user.trashcan.emptyTrash(), apis.admin.trashcan.emptyTrash(),
logoutPage.load() logoutPage.load()
]) ])
.then(done); .then(done);

View File

@ -23,7 +23,7 @@ exports.config = {
], ],
capabilities: { capabilities: {
'browserName': 'chrome', browserName: 'chrome',
chromeOptions: { chromeOptions: {
prefs: { prefs: {
'credentials_enable_service': false 'credentials_enable_service': false