Remove demo shell test and make cloud a bit more stable (#6781)

* remove demo shell test and make cloud a bit more stable

* fix lint

* Update restore-content-directive.e2e.ts

* Update restore-content-directive.e2e.ts

* Update restore-content-directive.e2e.ts

* try fix attach

* Update .travis.yml

* sleep...

* remove about e2e demo shell....

* fix

* lint fix

* configure

* refactor buuild

* names and remove demo shell build from libs

* fix new build approach

* fix

* fix

* .

* uncomment

* .

* .

* fix

* fix

* .

* fix

* lock update

* fix demo shell errors

* use replay subject

* fix some console log error

* suffix problem

* split process e2e

* not need to check everywhere the pagination e2e

* split content

* fix

* fix

* fix

* fix

* reorg

# Conflicts:
#	.travis.yml
This commit is contained in:
Eugenio Romano
2021-03-17 15:17:46 +00:00
committed by GitHub
parent 90aabe3541
commit cd915b307b
115 changed files with 659 additions and 1117 deletions

View File

@@ -0,0 +1,210 @@
/*!
* @license
* Copyright 2019 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 {
ApiService,
LoginPage,
StringUtil,
UploadActions,
UserModel,
UsersActions,
ViewerPage
} from '@alfresco/adf-testing';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { CommentsPage } from '../../core/pages/comments.page';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { FileModel } from '../../models/ACS/file.model';
import { browser } from 'protractor';
import CONSTANTS = require('../../util/constants');
describe('Comment', () => {
const loginPage: LoginPage = new LoginPage();
const contentServicesPage: ContentServicesPage = new ContentServicesPage();
const viewerPage: ViewerPage = new ViewerPage();
const commentsPage: CommentsPage = new CommentsPage();
const navigationBarPage = new NavigationBarPage();
const apiService = new ApiService();
let userFullName, nodeId;
let acsUser: UserModel;
const pngFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_path
});
const uploadActions = new UploadActions(apiService);
const usersActions = new UsersActions(apiService);
const comments = {
first: 'This is a comment',
multiline: 'This is a comment\n' + 'with a new line',
second: 'This is another comment',
codeType: `<form action="/action_page.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>`,
test: 'Test'
};
beforeAll(async () => {
await apiService.loginWithProfile('admin');
acsUser = await usersActions.createUser();
});
describe('component', () => {
beforeEach(async () => {
await apiService.login(acsUser.username, acsUser.password);
const pngUploadedFile = await uploadActions.uploadFile(pngFileModel.location, pngFileModel.name, '-my-');
nodeId = pngUploadedFile.entry.id;
userFullName = pngUploadedFile.entry.createdByUser.displayName;
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await contentServicesPage.waitForTableBody();
});
afterEach(async () => {
await apiService.loginWithProfile('admin');
await uploadActions.deleteFileOrFolder(nodeId);
await navigationBarPage.clickLogoutButton();
});
it('[C276947] Should be able to add a comment on ACS and view on ADF', async () => {
await apiService.getInstance().core.commentsApi.addComment(nodeId, { content: comments.test });
await viewerPage.viewFile(pngFileModel.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await commentsPage.checkCommentsTabIsSelected();
await commentsPage.checkCommentInputIsDisplayed();
await commentsPage.getTotalNumberOfComments('Comments (1)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.test);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
});
it('[C276948] Should be able to add a comment on a file', async () => {
await viewerPage.viewFile(pngFileModel.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await viewerPage.clickOnCommentsTab();
await commentsPage.addComment(comments.first);
await commentsPage.checkUserIconIsDisplayed();
await commentsPage.getTotalNumberOfComments('Comments (1)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.first);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
});
it('[C280021] Should be able to add a multiline comment on a file', async () => {
await viewerPage.viewFile(pngFileModel.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await viewerPage.clickOnCommentsTab();
await commentsPage.addComment(comments.multiline);
await commentsPage.checkUserIconIsDisplayed();
await commentsPage.getTotalNumberOfComments('Comments (1)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.multiline);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
await commentsPage.addComment(comments.second);
await commentsPage.checkUserIconIsDisplayed();
await commentsPage.getTotalNumberOfComments('Comments (2)');
await expect(await commentsPage.getMessage(0)).toEqual(comments.second);
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
});
it('[C280022] Should not be able to add an HTML or other code input into the comment input filed', async () => {
await viewerPage.viewFile(pngFileModel.name);
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await viewerPage.clickOnCommentsTab();
await commentsPage.addComment(comments.codeType);
await commentsPage.checkUserIconIsDisplayed();
await commentsPage.getTotalNumberOfComments('Comments (1)');
await expect(await commentsPage.getMessage(0)).toEqual('First name: Last name:');
await expect(await commentsPage.getUserName(0)).toEqual(userFullName);
await expect(await commentsPage.getTime(0)).toMatch(/(ago|few)/);
});
});
describe('Consumer Permissions', () => {
let site, pngUploadedFile;
beforeAll(async () => {
await apiService.loginWithProfile('admin');
site = await apiService.getInstance().core.sitesApi.createSite({
title: StringUtil.generateRandomString(8),
visibility: 'PUBLIC'
});
await apiService.getInstance().core.sitesApi.addSiteMember(site.entry.id, {
id: acsUser.username,
role: CONSTANTS.CS_USER_ROLES.CONSUMER
});
pngUploadedFile = await uploadActions.uploadFile(pngFileModel.location, pngFileModel.name, site.entry.guid);
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
});
afterAll(async () => {
await apiService.loginWithProfile('admin');
await uploadActions.deleteFileOrFolder(pngUploadedFile.entry.id);
await apiService.getInstance().core.sitesApi.deleteSite(site.entry.id, { permanent: true });
});
it('[C290147] Should NOT be able to add comments to a site file with Consumer permissions', async () => {
await navigationBarPage.goToSite(site);
await contentServicesPage.checkAcsContainer();
await viewerPage.viewFile(pngUploadedFile.entry.name);
await viewerPage.checkInfoButtonIsDisplayed();
await viewerPage.clickInfoButton();
await viewerPage.checkInfoSideBarIsDisplayed();
await commentsPage.checkCommentsTabIsSelected();
await commentsPage.checkCommentInputIsNotDisplayed();
await viewerPage.clickCloseButton();
});
});
});

View File

@@ -0,0 +1,347 @@
/*!
* @license
* Copyright 2019 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 {
ApiService,
LoginPage,
StringUtil,
UploadActions,
UserModel,
UsersActions,
WaitActions
} from '@alfresco/adf-testing';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { LockFilePage } from '../../content-services/pages/lock-file.page';
import { FileModel } from '../../models/ACS/file.model';
import { browser } from 'protractor';
import { NodeEntry } from '@alfresco/js-api';
import CONSTANTS = require('../../util/constants');
describe('Lock File', () => {
const loginPage = new LoginPage();
const navigationBarPage = new NavigationBarPage();
const lockFilePage = new LockFilePage();
const contentServices = new ContentServicesPage();
const adminUser = new UserModel();
const managerUser = new UserModel();
const apiService = new ApiService();
const usersActions = new UsersActions(apiService);
const uploadActions = new UploadActions(apiService);
const waitActions = new WaitActions(apiService);
const pngFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_path
});
const pngFileToLock = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG_B.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG_B.file_path
});
let site, documentLibrary;
beforeAll(async () => {
await apiService.loginWithProfile('admin');
await usersActions.createUser(adminUser);
await usersActions.createUser(managerUser);
await apiService.login(adminUser.username, adminUser.password);
site = await apiService.getInstance().core.sitesApi.createSite({
title: StringUtil.generateRandomString(),
visibility: 'PRIVATE'
});
const resultNode = await apiService.getInstance().core.nodesApi.getNodeChildren(site.entry.guid);
documentLibrary = resultNode.list.entries[0].entry.id;
await apiService.getInstance().core.sitesApi.addSiteMember(site.entry.id, {
id: managerUser.username,
role: CONSTANTS.CS_USER_ROLES.MANAGER
});
});
afterAll(async () => {
await apiService.loginWithProfile('admin');
try {
await apiService.getInstance().core.sitesApi.deleteSite(site.entry.id, { permanent: true });
} catch (e) {
}
});
describe('Lock file interaction with the UI', () => {
let pngLockedUploadedFile: NodeEntry;
let pngUploadedFile: NodeEntry;
beforeAll(async () => {
pngLockedUploadedFile = await uploadActions.uploadFile(pngFileToLock.location, pngFileToLock.name, documentLibrary);
await loginPage.login(adminUser.username, adminUser.password);
pngUploadedFile = await uploadActions.uploadFile(pngFileModel.location, pngFileModel.name, documentLibrary);
await navigationBarPage.openContentServicesFolder(documentLibrary);
await contentServices.waitForTableBody();
});
afterEach(async () => {
await apiService.login(adminUser.username, adminUser.password);
try {
await apiService.getInstance().core.nodesApi.unlockNode(pngUploadedFile.entry.id);
await waitActions.nodeIsUnlock(pngUploadedFile.entry.id);
} catch (e) {
}
});
afterAll(async () => {
await apiService.loginWithProfile('admin');
try {
await apiService.getInstance().core.nodesApi.unlockNode(pngLockedUploadedFile.entry.id);
} catch (e) {
}
try {
await uploadActions.deleteFileOrFolder(pngUploadedFile.entry.id);
} catch (e) {
}
try {
await uploadActions.deleteFileOrFolder(pngLockedUploadedFile.entry.id);
} catch (e) {
}
await navigationBarPage.clickLogoutButton();
});
it('[C286604] Should be able to open Lock file option by clicking the lock image', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.cancelButton.waitVisible();
await lockFilePage.saveButton.waitVisible();
});
it('[C286625] Should be able to click Cancel to cancel lock file operation', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.cancelButton.click();
await contentServices.checkUnlockedIcon(pngFileModel.name);
});
it('[C286603] Should be able to click on Lock file checkbox and lock a file', async () => {
await contentServices.lockContent(pngFileToLock.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.saveButton.click();
await contentServices.checkLockedIcon(pngFileToLock.name);
});
it('[C286618] Should be able to uncheck Lock file checkbox and unlock a file', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.saveButton.click();
await contentServices.checkLockedIcon(pngFileModel.name);
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.saveButton.click();
await contentServices.checkUnlockedIcon(pngFileModel.name);
});
});
describe('Locked file without owner permissions', () => {
let pngUploadedFile: NodeEntry;
beforeEach(async () => {
await apiService.login(adminUser.username, adminUser.password);
pngUploadedFile = await uploadActions.uploadFile(pngFileModel.location, pngFileModel.name, documentLibrary);
await loginPage.login(managerUser.username, managerUser.password);
await navigationBarPage.openContentServicesFolder(documentLibrary);
});
afterEach(async () => {
await apiService.login(adminUser.username, adminUser.password);
try {
await apiService.getInstance().core.nodesApi.unlockNode(pngUploadedFile.entry.id);
await uploadActions.deleteFileOrFolder(pngUploadedFile.entry.id);
} catch (error) {
}
await navigationBarPage.clickLogoutButton();
});
it('[C286610] Should not be able to delete a locked file', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.saveButton.click();
try {
await apiService.getInstance().core.nodesApi.deleteNode(pngUploadedFile.entry.id);
} catch (error) {
await expect(error.status).toEqual(409);
}
});
it('[C286611] Should not be able to rename a locked file', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.saveButton.click();
try {
await apiService.getInstance().core.nodesApi.updateNode(pngUploadedFile.entry.id, { name: 'My new name' });
} catch (error) {
await expect(error.status).toEqual(409);
}
});
it('[C286612] Should not be able to move a locked file', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.saveButton.click();
try {
await apiService.getInstance().core.nodesApi.moveNode(pngUploadedFile.entry.id, { targetParentId: '-my-' });
} catch (error) {
await expect(error.status).toEqual(409);
}
});
it('[C286613] Should not be able to update a new version on a locked file', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.saveButton.click();
try {
await apiService.getInstance().core.nodesApi.updateNodeContent(pngUploadedFile.entry.id, 'NEW FILE CONTENT');
} catch (error) {
await expect(error.status).toEqual(409);
}
});
});
describe('Locked file with owner permissions', () => {
let pngFileToBeLocked: NodeEntry;
let pngUploadedFile: NodeEntry;
beforeEach(async () => {
await apiService.login(adminUser.username, adminUser.password);
pngFileToBeLocked = await uploadActions.uploadFile(pngFileToLock.location, pngFileToLock.name, documentLibrary);
pngUploadedFile = await uploadActions.uploadFile(pngFileModel.location, pngFileModel.name, documentLibrary);
await loginPage.login(adminUser.username, adminUser.password);
await navigationBarPage.openContentServicesFolder(documentLibrary);
await contentServices.getDocumentList().dataTable.waitTillContentLoaded();
});
afterEach(async () => {
await apiService.login(adminUser.username, adminUser.password);
try {
await uploadActions.deleteFileOrFolder(pngUploadedFile.entry.id);
await uploadActions.deleteFileOrFolder(pngFileToBeLocked.entry.id);
} catch (e) {
}
await navigationBarPage.clickLogoutButton();
});
it('[C286615] Owner of the locked file should be able to update a new version if Allow owner to modify is checked', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.allowOwnerCheckbox.click();
await lockFilePage.saveButton.click();
try {
await apiService.login(adminUser.username, adminUser.password);
const response = await apiService.getInstance().core.nodesApi.updateNodeContent(pngUploadedFile.entry.id, 'NEW FILE CONTENT');
await expect(response.entry.modifiedAt.getTime()).toBeGreaterThan(response.entry.createdAt.getTime());
} catch (error) {
}
});
it('[C286616] Owner of the locked file should be able to move if Allow owner to modify is checked', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.allowOwnerCheckbox.click();
await lockFilePage.saveButton.click();
try {
await apiService.login(adminUser.username, adminUser.password);
await apiService.getInstance().core.nodesApi.moveNode(pngUploadedFile.entry.id, { targetParentId: '-my-' });
const movedFile = await apiService.getInstance().core.nodesApi.getNode(pngUploadedFile.entry.id);
await expect(movedFile.entry.parentId).not.toEqual(documentLibrary);
} catch (error) {
}
});
it('[C286617] Owner of the locked file should be able to delete if Allow owner to modify is checked', async () => {
await contentServices.lockContent(pngFileToLock.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.allowOwnerCheckbox.click();
await lockFilePage.saveButton.click();
await contentServices.deleteContent(pngFileToBeLocked.entry.name);
await contentServices.checkContentIsNotDisplayed(pngFileToBeLocked.entry.name);
});
it('[C286614] Owner of the locked file should be able to rename if Allow owner to modify is checked', async () => {
await contentServices.lockContent(pngFileModel.name);
await lockFilePage.lockFileCheckboxText.waitVisible();
await lockFilePage.lockFileCheckbox.click();
await lockFilePage.allowOwnerCheckbox.click();
await lockFilePage.saveButton.click();
try {
const response = await apiService.getInstance().core.nodesApi.updateNode(pngUploadedFile.entry.id, { name: 'My new name' });
await expect(response.entry.name).toEqual('My new name');
} catch (error) {
}
});
});
});

View File

@@ -0,0 +1,388 @@
/*!
* @license
* Copyright 2019 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 { PermissionsPage } from '../../content-services/pages/permissions.page';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { FileModel } from '../../models/ACS/file.model';
import {
ApiService,
BrowserActions,
LoginPage,
NotificationHistoryPage,
PermissionActions,
SearchService,
StringUtil,
UploadActions,
UserModel,
UsersActions,
ViewerPage
} from '@alfresco/adf-testing';
import { browser } from 'protractor';
import { FolderModel } from '../../models/ACS/folder.model';
import { MetadataViewPage } from '../../core/pages/metadata-view.page';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { UploadDialogPage } from '../../core/pages/dialog/upload-dialog.page';
import { NotificationDemoPage } from '../../core/pages/notification.page';
describe('Permissions Component', () => {
const apiService = new ApiService();
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const permissionsPage = new PermissionsPage();
const navigationBarPage = new NavigationBarPage();
const uploadActions = new UploadActions(apiService);
const usersActions = new UsersActions(apiService);
const notificationPage = new NotificationDemoPage();
const searchService = new SearchService(apiService);
const permissionActions = new PermissionActions(apiService);
const contentList = contentServicesPage.getDocumentList();
const viewerPage = new ViewerPage();
const metadataViewPage = new MetadataViewPage();
const notificationHistoryPage = new NotificationHistoryPage();
const uploadDialog = new UploadDialogPage();
let file;
const fileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_path
});
const fileLocation = browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_location;
const testFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_location
});
const pngFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_location
});
const groupBody = {
id: StringUtil.generateRandomString(),
displayName: StringUtil.generateRandomString()
};
const fileOwnerUser = new UserModel();
const filePermissionUser = new UserModel();
const duplicateUserPermissionMessage = 'One or more of the permissions you have set is already present : authority -> ' + filePermissionUser.username + ' / role -> Contributor';
const roleConsumerFolderModel = new FolderModel({ name: 'roleConsumer' + StringUtil.generateRandomString() });
const roleCoordinatorFolderModel = new FolderModel({ name: 'roleCoordinator' + StringUtil.generateRandomString() });
const roleCollaboratorFolderModel = new FolderModel({ name: 'roleCollaborator' + StringUtil.generateRandomString() });
const roleContributorFolderModel = new FolderModel({ name: 'roleContributor' + StringUtil.generateRandomString() });
const roleEditorFolderModel = new FolderModel({ name: 'roleEditor' + StringUtil.generateRandomString() });
let roleConsumerFolder, roleCoordinatorFolder, roleContributorFolder, roleCollaboratorFolder, roleEditorFolder;
beforeAll(async () => {
await apiService.loginWithProfile('admin');
await usersActions.createUser(fileOwnerUser);
await usersActions.createUser(filePermissionUser);
await apiService.getInstance().core.groupsApi.createGroup(groupBody);
// to sync user in acs
await searchService.isUserSearchable(filePermissionUser);
await apiService.login(fileOwnerUser.username, fileOwnerUser.password);
roleConsumerFolder = await uploadActions.createFolder(roleConsumerFolderModel.name, '-my-');
roleCoordinatorFolder = await uploadActions.createFolder(roleCoordinatorFolderModel.name, '-my-');
roleContributorFolder = await uploadActions.createFolder(roleContributorFolderModel.name, '-my-');
roleCollaboratorFolder = await uploadActions.createFolder(roleCollaboratorFolderModel.name, '-my-');
roleEditorFolder = await uploadActions.createFolder(roleEditorFolderModel.name, '-my-');
await uploadActions.uploadFile(fileModel.location, 'RoleConsumer' + fileModel.name, roleConsumerFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleContributor' + fileModel.name, roleContributorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleCoordinator' + fileModel.name, roleCoordinatorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleCollaborator' + fileModel.name, roleCollaboratorFolder.entry.id);
await uploadActions.uploadFile(fileModel.location, 'RoleEditor' + fileModel.name, roleEditorFolder.entry.id);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Consumer', roleConsumerFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Collaborator', roleCollaboratorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Coordinator', roleCoordinatorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Contributor', roleContributorFolder);
await permissionActions.addRoleForUser(filePermissionUser.username, 'Editor', roleEditorFolder);
await browser.sleep(browser.params.testConfig.timeouts.index_search); // wait search index previous file/folder uploaded
});
describe('Inherit and assigning permissions', () => {
beforeEach(async () => {
await apiService.login(fileOwnerUser.username, fileOwnerUser.password);
file = await uploadActions.uploadFile(fileModel.location, fileModel.name, '-my-');
await loginPage.login(fileOwnerUser.username, fileOwnerUser.password);
await contentServicesPage.goToDocumentList();
await contentServicesPage.contentList.dataTablePage().waitTillContentLoaded();
await contentServicesPage.checkContentIsDisplayed(fileModel.name);
await contentList.rightClickOnRow(fileModel.name);
await contentServicesPage.pressContextMenuActionNamed('Permission');
await permissionsPage.addPermissionsDialog.checkPermissionContainerIsDisplayed();
});
afterEach(async () => {
await BrowserActions.closeMenuAndDialogs();
try {
await uploadActions.deleteFileOrFolder(file.entry.id);
} catch (error) {
}
await navigationBarPage.clickLogoutButton();
});
it('[C286272] Should be able to see results when searching for a user', async () => {
await permissionsPage.addPermissionButton.waitVisible();
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup('a');
await permissionsPage.addPermissionsDialog.checkResultListIsDisplayed();
});
it('[C276979] Should be able to give permissions to a group of people', async () => {
await permissionsPage.addPermissionButton.waitVisible();
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(groupBody.id);
await permissionsPage.addPermissionsDialog.clickUserOrGroup(groupBody.displayName);
await permissionsPage.addPermissionsDialog.checkGroupIsAdded(groupBody.id);
});
it('[C277100] Should display EVERYONE group in the search result set', async () => {
await permissionsPage.addPermissionButton.waitVisible();
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.username);
await permissionsPage.addPermissionsDialog.checkResultListIsDisplayed();
await permissionsPage.addPermissionsDialog.checkUserOrGroupIsDisplayed('EVERYONE');
await permissionsPage.addPermissionsDialog.searchUserOrGroup('somerandomtext');
await permissionsPage.addPermissionsDialog.checkResultListIsDisplayed();
await permissionsPage.addPermissionsDialog.checkUserOrGroupIsDisplayed('EVERYONE');
});
});
describe('Changing and duplicate Permissions', () => {
beforeEach(async () => {
await apiService.login(fileOwnerUser.username, fileOwnerUser.password);
file = await uploadActions.uploadFile(fileModel.location, fileModel.name, '-my-');
await loginPage.login(fileOwnerUser.username, fileOwnerUser.password);
await contentServicesPage.goToDocumentList();
await contentServicesPage.checkContentIsDisplayed(fileModel.name);
await contentServicesPage.checkSelectedSiteIsDisplayed('My files');
await contentList.rightClickOnRow(fileModel.name);
await contentServicesPage.pressContextMenuActionNamed('Permission');
await permissionsPage.addPermissionButton.waitVisible();
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.clickUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.checkUserIsAdded(filePermissionUser.username);
});
afterEach(async () => {
await uploadActions.deleteFileOrFolder(file.entry.id);
await navigationBarPage.clickLogoutButton();
});
it('[C274691] Should be able to add a new User with permission to the file and also change locally set permissions', async () => {
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.username)).toEqual('Contributor');
await permissionsPage.addPermissionsDialog.clickRoleDropdownByUserOrGroupName(filePermissionUser.username);
const roleDropdownOptions = permissionsPage.addPermissionsDialog.getRoleDropdownOptions();
await expect(await roleDropdownOptions.count()).toBe(5);
await expect(await BrowserActions.getText(roleDropdownOptions.get(0))).toBe('Contributor');
await expect(await BrowserActions.getText(roleDropdownOptions.get(1))).toBe('Collaborator');
await expect(await BrowserActions.getText(roleDropdownOptions.get(2))).toBe('Coordinator');
await expect(await BrowserActions.getText(roleDropdownOptions.get(3))).toBe('Editor');
await expect(await BrowserActions.getText(roleDropdownOptions.get(4))).toBe('Consumer');
await BrowserActions.closeMenuAndDialogs();
await permissionsPage.changePermission(filePermissionUser.username, 'Collaborator');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.username)).toEqual('Collaborator');
await permissionsPage.changePermission(filePermissionUser.username, 'Coordinator');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.username)).toEqual('Coordinator');
await permissionsPage.changePermission(filePermissionUser.username, 'Editor');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.username)).toEqual('Editor');
await permissionsPage.changePermission(filePermissionUser.username, 'Consumer');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.username)).toEqual('Consumer');
});
it('[C276980] Should not be able to duplicate User or Group to the locally set permissions', async () => {
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.username)).toEqual('Contributor');
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.clickUserOrGroup(filePermissionUser.firstName);
await expect(await notificationPage.getSnackBarMessage()).toEqual(duplicateUserPermissionMessage);
await notificationHistoryPage.checkNotifyContains(duplicateUserPermissionMessage);
});
it('[C276982] Should be able to remove User or Group from the locally set permissions', async () => {
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.username)).toEqual('Contributor');
await permissionsPage.addPermissionsDialog.clickDeletePermissionButton();
await permissionsPage.addPermissionsDialog.checkUserIsDeleted(filePermissionUser.username);
});
});
describe('Role: Consumer, Contributor, Coordinator, Collaborator, Editor, No Permissions', () => {
afterEach(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C276993] Role Consumer', async () => {
await loginPage.login(filePermissionUser.username, filePermissionUser.password);
await navigationBarPage.openContentServicesFolder(roleConsumerFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('RoleConsumer' + fileModel.name);
await contentList.doubleClickRow('RoleConsumer' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.checkDeleteIsDisabled('RoleConsumer' + fileModel.name);
await BrowserActions.closeMenuAndDialogs();
await contentList.checkActionMenuIsNotDisplayed();
await contentServicesPage.metadataContent('RoleConsumer' + fileModel.name);
await expect(await notificationPage.getSnackBarMessage()).toEqual('You don\'t have access to do this.');
await notificationHistoryPage.checkNotifyContains('You don\'t have access to do this.');
await browser.sleep(3000);
await contentServicesPage.uploadFile(fileLocation);
await expect(await notificationPage.getSnackBarMessage()).toEqual('You don\'t have the create permission to upload the content');
await notificationHistoryPage.checkNotifyContains('You don\'t have the create permission to upload the content');
});
it('[C276996] Role Contributor', async () => {
await loginPage.login(filePermissionUser.username, filePermissionUser.password);
await navigationBarPage.openContentServicesFolder(roleContributorFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('RoleContributor' + fileModel.name);
await contentList.doubleClickRow('RoleContributor' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.checkDeleteIsDisabled('RoleContributor' + fileModel.name);
await BrowserActions.closeMenuAndDialogs();
await contentList.checkActionMenuIsNotDisplayed();
await contentServicesPage.metadataContent('RoleContributor' + fileModel.name);
await notificationHistoryPage.checkNotifyContains('You don\'t have access to do this.');
await contentServicesPage.uploadFile(testFileModel.location);
await contentServicesPage.checkContentIsDisplayed(testFileModel.name);
await uploadDialog.fileIsUploaded(testFileModel.name);
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
});
it('[C277000] Role Editor', async () => {
await loginPage.login(filePermissionUser.username, filePermissionUser.password);
await navigationBarPage.openContentServicesFolder(roleEditorFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('RoleEditor' + fileModel.name);
await contentList.doubleClickRow('RoleEditor' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.checkDeleteIsDisabled('RoleEditor' + fileModel.name);
await BrowserActions.closeMenuAndDialogs();
await contentList.checkActionMenuIsNotDisplayed();
await contentServicesPage.metadataContent('RoleEditor' + fileModel.name);
await metadataViewPage.editIconIsDisplayed();
await metadataViewPage.editIconClick();
await metadataViewPage.editPropertyIconIsDisplayed('properties.cm:title');
await metadataViewPage.enterPropertyText('properties.cm:title', 'newTitle1');
await expect(await metadataViewPage.getPropertyText('properties.cm:title')).toEqual('newTitle1');
await metadataViewPage.clickCloseButton();
await contentServicesPage.uploadFile(fileLocation);
await notificationHistoryPage.checkNotifyContains('You don\'t have the create permission to upload the content');
});
it('[C277003] Role Collaborator', async () => {
await loginPage.login(filePermissionUser.username, filePermissionUser.password);
await navigationBarPage.openContentServicesFolder(roleCollaboratorFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('RoleCollaborator' + fileModel.name);
await contentList.doubleClickRow('RoleCollaborator' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.checkDeleteIsDisabled('RoleCollaborator' + fileModel.name);
await BrowserActions.closeMenuAndDialogs();
await contentList.checkActionMenuIsNotDisplayed();
await contentServicesPage.metadataContent('RoleCollaborator' + fileModel.name);
await metadataViewPage.editIconIsDisplayed();
await metadataViewPage.editIconClick();
await metadataViewPage.editPropertyIconIsDisplayed('properties.cm:title');
await metadataViewPage.enterPropertyText('properties.cm:title', 'newTitle2');
await expect(await metadataViewPage.getPropertyText('properties.cm:title')).toEqual('newTitle2');
await metadataViewPage.clickCloseButton();
await contentServicesPage.uploadFile(testFileModel.location);
await contentServicesPage.checkContentIsDisplayed(testFileModel.name);
await uploadDialog.fileIsUploaded(testFileModel.name);
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
});
it('[C277004] Role Coordinator', async () => {
await loginPage.login(filePermissionUser.username, filePermissionUser.password);
await navigationBarPage.openContentServicesFolder(roleCoordinatorFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('RoleCoordinator' + fileModel.name);
await contentList.doubleClickRow('RoleCoordinator' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.metadataContent('RoleCoordinator' + fileModel.name);
await metadataViewPage.editIconIsDisplayed();
await metadataViewPage.editIconClick();
await metadataViewPage.editPropertyIconIsDisplayed('properties.cm:title');
await metadataViewPage.enterPropertyText('properties.cm:title', 'newTitle3');
await expect(await metadataViewPage.getPropertyText('properties.cm:title')).toEqual('newTitle3');
await metadataViewPage.clickCloseButton();
await contentServicesPage.uploadFile(pngFileModel.location);
await contentServicesPage.checkContentIsDisplayed(pngFileModel.name);
await uploadDialog.fileIsUploaded(pngFileModel.name);
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
await contentServicesPage.checkContentIsDisplayed('RoleCoordinator' + fileModel.name);
await contentServicesPage.deleteContent('RoleCoordinator' + fileModel.name);
await contentServicesPage.checkContentIsNotDisplayed('RoleCoordinator' + fileModel.name);
});
it('[C279881] No Permission User', async () => {
await loginPage.login(filePermissionUser.username, filePermissionUser.password);
await navigationBarPage.openContentServicesFolder(roleConsumerFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('RoleConsumer' + fileModel.name);
await contentServicesPage.checkSelectedSiteIsDisplayed('My files');
await contentList.rightClickOnRow('RoleConsumer' + fileModel.name);
await contentServicesPage.pressContextMenuActionNamed('Permission');
await permissionsPage.addPermissionsDialog.checkPermissionInheritedButtonIsDisplayed();
await permissionsPage.addPermissionButton.waitVisible();
await permissionsPage.addPermissionsDialog.clickPermissionInheritedButton();
await expect(await notificationPage.getSnackBarMessage()).toEqual('You are not allowed to change permissions');
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await expect(await notificationPage.getSnackBarMessage()).toEqual('You are not allowed to change permissions');
await notificationHistoryPage.checkNotifyContains('You are not allowed to change permissions');
});
});
});

View File

@@ -0,0 +1,237 @@
/*!
* @license
* Copyright 2019 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 {
ApiService,
ApiUtil,
BrowserActions,
LocalStorageUtil,
LoginPage,
NotificationHistoryPage,
UploadActions,
UserModel,
UsersActions,
ViewerPage
} from '@alfresco/adf-testing';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { ShareDialogPage } from '../../core/pages/dialog/share-dialog.page';
import { FileModel } from '../../models/ACS/file.model';
import { browser } from 'protractor';
import { SharedLinkEntry, SharedLinkPaging } from '@alfresco/js-api';
import { CustomSourcesPage } from '../../core/pages/custom-sources.page';
describe('Share file', () => {
const apiService = new ApiService();
const usersActions = new UsersActions(apiService);
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const contentListPage = contentServicesPage.getDocumentList();
const shareDialog = new ShareDialogPage();
const navigationBarPage = new NavigationBarPage();
const customSourcesPage = new CustomSourcesPage();
const viewerPage = new ViewerPage();
const notificationHistoryPage = new NotificationHistoryPage();
let acsUser: UserModel;
const uploadActions = new UploadActions(apiService);
const pngFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_path
});
let nodeId;
const waitForShareLink = async (nodeIdSharedFile: string) => {
const predicate = (sharedLinkPaging: SharedLinkPaging) => {
const sharedLink = sharedLinkPaging.list.entries.find((sharedLinkEntry: SharedLinkEntry) => {
return sharedLinkEntry.entry.nodeId === nodeIdSharedFile;
});
return !!sharedLink;
};
const apiCall = async () => {
await apiService.login(acsUser.username, acsUser.password);
return apiService.getInstance().core.sharedlinksApi.findSharedLinks();
};
return ApiUtil.waitForApi(apiCall, predicate, 10, 2000);
};
beforeAll(async () => {
await apiService.loginWithProfile('admin');
acsUser = await usersActions.createUser();
await apiService.login(acsUser.username, acsUser.password);
const pngUploadedFile = await uploadActions.uploadFile(pngFileModel.location, pngFileModel.name, '-my-');
nodeId = pngUploadedFile.entry.id;
});
afterAll(async () => {
await apiService.loginWithProfile('admin');
await uploadActions.deleteFileOrFolder(nodeId);
});
describe('Shared link dialog', () => {
beforeAll(async () => {
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await contentListPage.selectRow(pngFileModel.name);
await BrowserActions.closeMenuAndDialogs();
});
afterAll(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C286549] Should check automatically toggle button in Share dialog', async () => {
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.shareToggleButtonIsChecked();
await BrowserActions.closeMenuAndDialogs();
});
it('[C286544] Should display notification when clicking URL copy button', async () => {
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickShareLinkButton();
await BrowserActions.closeMenuAndDialogs();
await notificationHistoryPage.checkNotifyContains('Link copied to the clipboard');
});
it('[C286543] Should be possible to close Share dialog', async () => {
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.checkShareLinkIsDisplayed();
await BrowserActions.closeMenuAndDialogs();
});
it('[C286578] Should disable today option in expiration day calendar', async () => {
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickExpireToggle();
await shareDialog.clickDateTimePickerButton();
await shareDialog.calendarTodayDayIsDisabled();
await BrowserActions.closeMenuAndDialogs();
});
it('[C286548] Should be possible to set expiry date for link', async () => {
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickExpireToggle();
await shareDialog.setDefaultDay();
await shareDialog.setDefaultHour();
await shareDialog.setDefaultMinutes();
await shareDialog.dateTimePickerDialogIsClosed();
const value = await shareDialog.getExpirationDate();
await shareDialog.clickCloseButton();
await shareDialog.dialogIsClosed();
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.expirationDateInputHasValue(value);
await BrowserActions.closeMenuAndDialogs();
});
it('[C310329] Should be possible to set expiry date only for link', async () => {
await LocalStorageUtil.setConfigField('sharedLinkDateTimePickerType', JSON.stringify('date'));
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickExpireToggle();
await shareDialog.setDefaultDay();
await shareDialog.dateTimePickerDialogIsClosed();
const value = await shareDialog.getExpirationDate();
await shareDialog.clickCloseButton();
await shareDialog.dialogIsClosed();
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.expirationDateInputHasValue(value);
await BrowserActions.closeMenuAndDialogs();
});
});
describe('Shared link preview', () => {
beforeEach(async () => {
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await contentServicesPage.waitForTableBody();
});
afterEach(async () => {
await BrowserActions.getUrl('/');
await navigationBarPage.clickLogoutButton();
});
it('[C286565] Should open file when logged user access shared link', async () => {
await contentListPage.selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickShareLinkButton();
const sharedLink = await shareDialog.getShareLink();
await BrowserActions.closeMenuAndDialogs();
await BrowserActions.getUrl(sharedLink);
await viewerPage.checkFileNameIsDisplayed(pngFileModel.name);
});
it('[C287803] Should the URL be kept the same when opening the share dialog multiple times', async () => {
await contentListPage.selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickShareLinkButton();
const sharedLink = await shareDialog.getShareLink();
await shareDialog.clickCloseButton();
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickShareLinkButton();
const secondSharedLink = await shareDialog.getShareLink();
await BrowserActions.closeMenuAndDialogs();
await expect(sharedLink).toEqual(secondSharedLink);
await BrowserActions.getUrl(sharedLink);
await viewerPage.checkFileNameIsDisplayed(pngFileModel.name);
});
it('[C286539] Should open file when non-logged user access shared link', async () => {
await contentListPage.selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.checkShareLinkIsDisplayed();
const sharedLink = await shareDialog.getShareLink();
await shareDialog.clickCloseButton();
await navigationBarPage.clickLogoutButton();
await BrowserActions.getUrl(sharedLink);
await viewerPage.checkFileNameIsDisplayed(pngFileModel.name);
});
it('[C260153] Should shared files listed in share files custom resources', async () => {
await contentListPage.selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickShareLinkButton();
await BrowserActions.closeMenuAndDialogs();
await waitForShareLink(nodeId);
await customSourcesPage.navigateToCustomSources();
await customSourcesPage.selectSharedLinksSourceType();
await customSourcesPage.checkRowIsDisplayed(pngFileModel.name);
});
});
});

View File

@@ -0,0 +1,370 @@
/*!
* @license
* Copyright 2019 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 { PermissionsPage } from '../../content-services/pages/permissions.page';
import {
ApiService,
BrowserActions,
LoginPage,
NotificationHistoryPage,
StringUtil,
UploadActions,
UserModel,
UsersActions,
ViewerPage
} from '@alfresco/adf-testing';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { FileModel } from '../../models/ACS/file.model';
import { browser } from 'protractor';
import { MetadataViewPage } from '../../core/pages/metadata-view.page';
import { UploadDialogPage } from '../../core/pages/dialog/upload-dialog.page';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { VersionManagePage } from '../../core/pages/version-manager.page';
import CONSTANTS = require('../../util/constants');
describe('Permissions Component', () => {
const apiService = new ApiService();
const uploadActions = new UploadActions(apiService);
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const permissionsPage = new PermissionsPage();
const viewerPage = new ViewerPage();
const navigationBarPage = new NavigationBarPage();
const metadataViewPage = new MetadataViewPage();
const notificationHistoryPage = new NotificationHistoryPage();
const uploadDialog = new UploadDialogPage();
const versionManagePage = new VersionManagePage();
const contentList = contentServicesPage.getDocumentList();
let publicSite, privateSite, folderName;
const fileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_path
});
const testFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_location
});
const pngFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_location
});
const newVersionFile = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG_B.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG_B.file_location
});
let siteFolder, privateSiteFile;
const folderOwnerUser = new UserModel();
const consumerUser: UserModel = new UserModel();
const siteConsumerUser: UserModel = new UserModel();
const collaboratorUser: UserModel = new UserModel();
const contributorUser: UserModel = new UserModel();
const managerUser: UserModel = new UserModel();
const usersActions = new UsersActions(apiService);
beforeAll(async () => {
await apiService.loginWithProfile('admin');
await usersActions.createUser(folderOwnerUser);
await usersActions.createUser(siteConsumerUser);
await usersActions.createUser(consumerUser);
await usersActions.createUser(contributorUser);
await usersActions.createUser(collaboratorUser);
await usersActions.createUser(managerUser);
await apiService.login(folderOwnerUser.username, folderOwnerUser.password);
await browser.sleep(browser.params.testConfig.timeouts.index_search);
const publicSiteName = `PUBLIC_TEST_SITE_${StringUtil.generateRandomString(5)}`;
const privateSiteName = `PRIVATE_TEST_SITE_${StringUtil.generateRandomString(5)}`;
folderName = `MEESEEKS_${StringUtil.generateRandomString(5)}`;
const publicSiteBody = { visibility: 'PUBLIC', title: publicSiteName };
const privateSiteBody = { visibility: 'PRIVATE', title: privateSiteName };
publicSite = await apiService.getInstance().core.sitesApi.createSite(publicSiteBody);
privateSite = await apiService.getInstance().core.sitesApi.createSite(privateSiteBody);
await apiService.getInstance().core.sitesApi.addSiteMember(publicSite.entry.id, {
id: siteConsumerUser.username,
role: CONSTANTS.CS_USER_ROLES.CONSUMER
});
await apiService.getInstance().core.sitesApi.addSiteMember(publicSite.entry.id, {
id: collaboratorUser.username,
role: CONSTANTS.CS_USER_ROLES.COLLABORATOR
});
await apiService.getInstance().core.sitesApi.addSiteMember(publicSite.entry.id, {
id: contributorUser.username,
role: CONSTANTS.CS_USER_ROLES.CONTRIBUTOR
});
await apiService.getInstance().core.sitesApi.addSiteMember(publicSite.entry.id, {
id: managerUser.username,
role: CONSTANTS.CS_USER_ROLES.MANAGER
});
await apiService.getInstance().core.sitesApi.addSiteMember(privateSite.entry.id, {
id: managerUser.username,
role: CONSTANTS.CS_USER_ROLES.MANAGER
});
siteFolder = await uploadActions.createFolder(folderName, publicSite.entry.guid);
privateSiteFile = await uploadActions.uploadFile(fileModel.location, 'privateSite' + fileModel.name, privateSite.entry.guid);
await apiService.getInstance().core.nodesApi.updateNode(privateSiteFile.entry.id,
{
permissions: {
locallySet: [{
authorityId: managerUser.username,
name: 'SiteConsumer',
accessStatus: 'ALLOWED'
}]
}
});
await uploadActions.uploadFile(fileModel.location, 'Site' + fileModel.name, siteFolder.entry.id);
});
afterAll(async () => {
await apiService.loginWithProfile('admin');
await apiService.getInstance().core.sitesApi.deleteSite(publicSite.entry.id, { permanent: true });
await apiService.getInstance().core.sitesApi.deleteSite(privateSite.entry.id, { permanent: true });
});
describe('Role Site Dropdown', () => {
beforeAll(async () => {
await loginPage.login(folderOwnerUser.username, folderOwnerUser.password);
await BrowserActions.getUrl(browser.baseUrl + '/files/' + publicSite.entry.guid);
await contentServicesPage.contentList.dataTablePage().waitTillContentLoaded();
});
afterAll(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C277002] Should display the Role Site dropdown', async () => {
await contentServicesPage.checkContentIsDisplayed(folderName);
await contentList.rightClickOnRow(folderName);
await contentServicesPage.pressContextMenuActionNamed('Permission');
await permissionsPage.addPermissionsDialog.checkPermissionInheritedButtonIsDisplayed();
await permissionsPage.addPermissionButton.waitVisible();
await browser.sleep(5000);
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(consumerUser.username);
await permissionsPage.addPermissionsDialog.clickUserOrGroup(consumerUser.firstName);
await permissionsPage.addPermissionsDialog.checkUserIsAdded(consumerUser.username);
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(consumerUser.username)).toEqual('SiteCollaborator');
await permissionsPage.addPermissionsDialog.clickRoleDropdownByUserOrGroupName(consumerUser.username);
const roleDropdownOptions = permissionsPage.addPermissionsDialog.getRoleDropdownOptions();
await expect(await roleDropdownOptions.count()).toBe(4);
await expect(await BrowserActions.getText(roleDropdownOptions.get(0))).toBe(CONSTANTS.CS_USER_ROLES.COLLABORATOR);
await expect(await BrowserActions.getText(roleDropdownOptions.get(1))).toBe(CONSTANTS.CS_USER_ROLES.CONSUMER);
await expect(await BrowserActions.getText(roleDropdownOptions.get(2))).toBe(CONSTANTS.CS_USER_ROLES.CONTRIBUTOR);
await expect(await BrowserActions.getText(roleDropdownOptions.get(3))).toBe(CONSTANTS.CS_USER_ROLES.MANAGER);
});
});
describe('Roles: SiteConsumer, SiteCollaborator, SiteContributor, SiteManager', () => {
afterEach(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C276994] Role SiteConsumer', async () => {
await loginPage.login(siteConsumerUser.username, siteConsumerUser.password);
await navigationBarPage.openContentServicesFolder(siteFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('Site' + fileModel.name);
await contentList.doubleClickRow('Site' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.checkDeleteIsDisabled('Site' + fileModel.name);
await BrowserActions.closeMenuAndDialogs();
await contentList.checkActionMenuIsNotDisplayed();
await contentServicesPage.metadataContent('Site' + fileModel.name);
await notificationHistoryPage.checkNotifyContains('You don\'t have access to do this.');
await contentServicesPage.uploadFile(testFileModel.location);
await notificationHistoryPage.checkNotifyContains('You don\'t have the create permission to upload the content');
});
it('[C276997] Role SiteContributor', async () => {
await loginPage.login(contributorUser.username, contributorUser.password);
await navigationBarPage.openContentServicesFolder(siteFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('Site' + fileModel.name);
await contentList.doubleClickRow('Site' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.checkDeleteIsDisabled('Site' + fileModel.name);
await BrowserActions.closeMenuAndDialogs();
await contentList.checkActionMenuIsNotDisplayed();
await contentServicesPage.metadataContent('Site' + fileModel.name);
await notificationHistoryPage.checkNotifyContains('You don\'t have access to do this.');
await contentServicesPage.uploadFile(testFileModel.location);
await contentServicesPage.checkContentIsDisplayed(testFileModel.name);
await uploadDialog.fileIsUploaded(testFileModel.name);
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
});
it('[C277005] Role SiteCollaborator', async () => {
await loginPage.login(collaboratorUser.username, collaboratorUser.password);
await navigationBarPage.openContentServicesFolder(siteFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('Site' + fileModel.name);
await contentList.doubleClickRow('Site' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.checkDeleteIsDisabled('Site' + fileModel.name);
await BrowserActions.closeMenuAndDialogs();
await contentList.checkActionMenuIsNotDisplayed();
await contentServicesPage.metadataContent('Site' + fileModel.name);
await metadataViewPage.editIconIsDisplayed();
await metadataViewPage.editIconClick();
await metadataViewPage.editPropertyIconIsDisplayed('properties.cm:title');
await metadataViewPage.enterPropertyText('properties.cm:title', 'newTitle');
await expect(await metadataViewPage.getPropertyText('properties.cm:title')).toEqual('newTitle');
await metadataViewPage.clickCloseButton();
await contentServicesPage.uploadFile(pngFileModel.location);
await contentServicesPage.checkContentIsDisplayed(pngFileModel.name);
await uploadDialog.fileIsUploaded(pngFileModel.name);
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
});
it('[C277006] Role SiteManager', async () => {
await loginPage.login(managerUser.username, managerUser.password);
await navigationBarPage.openContentServicesFolder(siteFolder.entry.id);
await contentServicesPage.checkContentIsDisplayed('Site' + fileModel.name);
await contentList.doubleClickRow('Site' + fileModel.name);
await viewerPage.checkFileIsLoaded();
await viewerPage.clickCloseButton();
await contentList.waitForTableBody();
await contentServicesPage.metadataContent('Site' + fileModel.name);
await metadataViewPage.editIconIsDisplayed();
await metadataViewPage.editIconClick();
await metadataViewPage.editPropertyIconIsDisplayed('properties.cm:description');
await metadataViewPage.enterDescriptionText('newDescription');
await metadataViewPage.clickSaveMetadata();
await expect(await metadataViewPage.getPropertyText('properties.cm:description')).toEqual('newDescription');
await metadataViewPage.clickCloseButton();
await contentServicesPage.uploadFile(testFileModel.location);
await contentServicesPage.checkContentIsDisplayed(testFileModel.name);
await uploadDialog.fileIsUploaded(testFileModel.name);
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
await contentServicesPage.checkContentIsDisplayed('Site' + fileModel.name);
await contentServicesPage.deleteContent('Site' + fileModel.name);
await contentServicesPage.checkContentIsNotDisplayed('Site' + fileModel.name);
});
});
describe('Roles: Private site and Manager User', () => {
afterEach(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C277196] should a user with Manager permissions be able to upload a new version for the created file', async () => {
await loginPage.login(managerUser.username, managerUser.password);
await navigationBarPage.openContentServicesFolder(privateSite.entry.guid);
await contentServicesPage.versionManagerContent('privateSite' + fileModel.name);
await versionManagePage.showNewVersionButton.click();
await versionManagePage.uploadNewVersionFile(newVersionFile.location);
await versionManagePage.checkFileVersionExist('1.1');
await expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
});
});
});

View File

@@ -0,0 +1,204 @@
/*!
* @license
* Copyright 2019 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 {
ApiService,
LikePage,
LoginPage,
RatePage,
UploadActions,
UserModel,
UsersActions
} from '@alfresco/adf-testing';
import { FileModel } from '../../models/ACS/file.model';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { SocialPage } from '../../content-services/pages/social.page';
import { browser } from 'protractor';
describe('Social component', () => {
const loginPage = new LoginPage();
const likePage = new LikePage();
const ratePage = new RatePage();
const socialPage = new SocialPage();
const navigationBarPage = new NavigationBarPage();
const componentOwner = new UserModel();
const componentVisitor = new UserModel();
const secondComponentVisitor = new UserModel();
const apiService = new ApiService();
const usersActions = new UsersActions(apiService);
const uploadActions = new UploadActions(apiService);
const blueLikeColor = ('rgba(33, 150, 243, 1)');
const greyLikeColor = ('rgba(128, 128, 128, 1)');
const yellowRatedStarColor = ('rgba(255, 233, 68, 1)');
const averageStarColor = ('rgba(128, 128, 128, 1)');
let emptyFile;
const emptyFileModel = new FileModel({
'name': browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_name,
'location': browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_path
});
beforeAll(async () => {
await apiService.loginWithProfile('admin');
await usersActions.createUser(componentOwner);
await usersActions.createUser(componentVisitor);
await usersActions.createUser(secondComponentVisitor);
await apiService.login(componentOwner.username, componentOwner.password);
emptyFile = await uploadActions.uploadFile(emptyFileModel.location, emptyFileModel.name, '-my-');
await apiService.getInstance().core.nodesApi.updateNode(emptyFile.entry.id,
{
permissions: {
locallySet: [{
authorityId: componentVisitor.username,
name: 'Consumer',
accessStatus: 'ALLOWED'
}, {
authorityId: secondComponentVisitor.username,
name: 'Consumer',
accessStatus: 'ALLOWED'
}]
}
});
});
afterAll(async () => {
await apiService.loginWithProfile('admin');
await uploadActions.deleteFileOrFolder(emptyFile.entry.email);
});
describe('User interaction on their own components', () => {
beforeEach(async () => {
await loginPage.login(componentOwner.username, componentOwner.password);
await navigationBarPage.clickSocialButton();
});
afterEach(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C203006] Should be able to like and unlike their components but not rate them,', async () => {
await socialPage.writeCustomNodeId(emptyFile.entry.id);
await expect(await socialPage.getNodeIdFieldValue()).toEqual(emptyFile.entry.id);
await likePage.clickLike();
await likePage.checkLikeCounter(1);
await likePage.removeHoverFromLikeButton();
await expect(await likePage.getLikedIconColor()).toBe(blueLikeColor);
await ratePage.rateComponent(4);
await ratePage.checkRatingCounter(0);
await expect(await ratePage.isNotStarRated(4));
await expect(await ratePage.getUnratedStarColor(4)).toBe(averageStarColor);
await likePage.clickUnlike();
await likePage.checkLikeCounter(0);
await likePage.removeHoverFromLikeButton();
await expect(await likePage.getUnLikedIconColor()).toBe(greyLikeColor);
});
});
describe('User interaction on components that belong to other users', () => {
beforeEach(async () => {
await loginPage.login(componentVisitor.username, componentVisitor.password);
await navigationBarPage.clickSocialButton();
});
afterEach(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C310198] Should be able to rate and unRate a component', async () => {
await socialPage.writeCustomNodeId(emptyFile.entry.id);
await expect(await socialPage.getNodeIdFieldValue()).toEqual(emptyFile.entry.id);
await ratePage.checkRatingCounter(0);
await ratePage.rateComponent(4);
await ratePage.checkRatingCounter(1);
await expect(await ratePage.isStarRated(4));
await expect(await ratePage.getRatedStarColor(4)).toBe(yellowRatedStarColor);
await ratePage.removeRating(4);
await ratePage.checkRatingCounter(0);
await expect(await ratePage.isNotStarRated(4));
});
});
describe('Multiple Users interaction', () => {
beforeEach(async () => {
await loginPage.login(componentVisitor.username, componentVisitor.password);
await navigationBarPage.clickSocialButton();
});
afterEach(async () => {
await navigationBarPage.clickLogoutButton();
});
it('[C310197] Should be able to like, unLike, display total likes', async () => {
await socialPage.writeCustomNodeId(emptyFile.entry.id);
await expect(await socialPage.getNodeIdFieldValue()).toEqual(emptyFile.entry.id);
await expect(await likePage.getUnLikedIconColor()).toBe(greyLikeColor);
await likePage.clickLike();
await likePage.checkLikeCounter(1);
await likePage.removeHoverFromLikeButton();
await expect(await likePage.getLikedIconColor()).toBe(blueLikeColor);
await navigationBarPage.clickLogoutButton();
await loginPage.login(secondComponentVisitor.username, secondComponentVisitor.password);
await navigationBarPage.clickSocialButton();
await socialPage.writeCustomNodeId(emptyFile.entry.id);
await expect(await likePage.getUnLikedIconColor()).toBe(greyLikeColor);
await likePage.clickLike();
await likePage.checkLikeCounter(2);
await likePage.removeHoverFromLikeButton();
await expect(await likePage.getLikedIconColor()).toBe(blueLikeColor);
await likePage.clickUnlike();
await likePage.checkLikeCounter(1);
await likePage.removeHoverFromLikeButton();
await expect(await likePage.getUnLikedIconColor()).toBe(greyLikeColor);
});
it('[C260327] Should be able to rate, unRate, display total ratings, display average rating', async () => {
await socialPage.writeCustomNodeId(emptyFile.entry.id);
await expect(await socialPage.getNodeIdFieldValue()).toEqual(emptyFile.entry.id);
await ratePage.rateComponent(4);
await ratePage.checkRatingCounter(1);
await expect(await ratePage.isStarRated(4));
await expect(await ratePage.getRatedStarColor(4)).toBe(yellowRatedStarColor);
await navigationBarPage.clickLogoutButton();
await loginPage.login(secondComponentVisitor.username, secondComponentVisitor.password);
await navigationBarPage.clickSocialButton();
await socialPage.writeCustomNodeId(emptyFile.entry.id);
await expect(await socialPage.getNodeIdFieldValue()).toEqual(emptyFile.entry.id);
await ratePage.checkRatingCounter(1);
await expect(await ratePage.getAverageStarColor(4)).toBe(averageStarColor);
await ratePage.rateComponent(0);
await ratePage.checkRatingCounter(2);
await expect(await ratePage.isStarRated(2));
await ratePage.removeRating(0);
await ratePage.checkRatingCounter(1);
await expect(await ratePage.getAverageStarColor(4)).toBe(averageStarColor);
});
});
});

View File

@@ -0,0 +1,164 @@
/*!
* @license
* Copyright 2019 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 { FileModel } from '../../models/ACS/file.model';
import { ApiService, LoginPage, StringUtil, UploadActions, UserModel, UsersActions } from '@alfresco/adf-testing';
import { TagPage } from '../../content-services/pages/tag.page';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { browser } from 'protractor';
describe('Tag component', () => {
const loginPage = new LoginPage();
const tagPage = new TagPage();
const navigationBarPage = new NavigationBarPage();
let acsUser: UserModel;
const apiService = new ApiService();
const usersActions = new UsersActions(apiService);
const uploadActions = new UploadActions(apiService);
const pdfFileModel = new FileModel({ name: browser.params.resources.Files.ADF_DOCUMENTS.PDF.file_name });
const deleteFile = new FileModel({ name: StringUtil.generateRandomString() });
const sameTag = StringUtil.generateRandomString().toLowerCase();
const tagList = [
StringUtil.generateRandomString().toLowerCase(),
StringUtil.generateRandomString().toLowerCase(),
StringUtil.generateRandomString().toLowerCase(),
StringUtil.generateRandomString().toLowerCase()];
const tags = [
{ tag: 'test-tag-01' }, { tag: 'test-tag-02' }, { tag: 'test-tag-03' }, { tag: 'test-tag-04' }, { tag: 'test-tag-05' },
{ tag: 'test-tag-06' }, { tag: 'test-tag-07' }, { tag: 'test-tag-08' }, { tag: 'test-tag-09' }, { tag: 'test-tag-10' },
{ tag: 'test-tag-11' }];
let pdfUploadedFile, nodeId;
beforeAll(async () => {
await apiService.loginWithProfile('admin');
acsUser = await usersActions.createUser();
await apiService.login(acsUser.username, acsUser.password);
pdfUploadedFile = await uploadActions.uploadFile(pdfFileModel.location, pdfFileModel.name, '-my-');
nodeId = pdfUploadedFile.entry.id;
const uploadedDeleteFile = await uploadActions.uploadFile(deleteFile.location, deleteFile.name, '-my-');
Object.assign(pdfFileModel, pdfUploadedFile.entry);
Object.assign(deleteFile, uploadedDeleteFile.entry);
await apiService.getInstance().core.tagsApi.addTag(nodeId, tags);
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.clickTagButton();
});
afterAll(async () => {
await navigationBarPage.clickLogoutButton();
await apiService.loginWithProfile('admin');
await uploadActions.deleteFileOrFolder(pdfUploadedFile.entry.id);
});
it('[C260374] Should NOT be possible to add a new tag without Node ID', async () => {
await expect(await tagPage.getNodeId()).toEqual('');
await expect(await tagPage.newTagInput.getAttribute('data-placeholder')).toEqual('New Tag');
await expect(await tagPage.addTagButtonIsEnabled()).toEqual(false);
await tagPage.tagListRow.waitNotVisible();
await tagPage.tagListByNodeIdRow.waitNotVisible();
await tagPage.newTagInput.typeText('a');
await expect(await tagPage.addTagButtonIsEnabled()).toEqual(false);
await expect(await tagPage.newTagInput.getAttribute('value')).toEqual('a');
});
it('[C268151] Should be possible to add a new tag to a Node', async () => {
await tagPage.insertNodeId(pdfFileModel.id);
await tagPage.addTag(tagList[0]);
await tagPage.checkTagIsDisplayedInTagList(tagList[0]);
await tagPage.checkTagIsDisplayedInTagListByNodeId(tagList[0]);
});
it('[C260377] Should NOT be possible to add a tag that already exists', async () => {
await tagPage.insertNodeId(pdfFileModel.id);
await tagPage.addTag(sameTag);
await tagPage.checkTagIsDisplayedInTagList(sameTag);
await tagPage.addTag(sameTag);
await expect(await tagPage.errorMessage.getText()).toEqual('Tag already exists');
});
it('[C260375] Should be possible to delete a tag', async () => {
const deleteTag = StringUtil.generateRandomString().toUpperCase();
await tagPage.insertNodeId(deleteFile.id);
await tagPage.addTag(deleteTag);
await tagPage.checkTagIsDisplayedInTagList(deleteTag.toLowerCase());
await tagPage.checkTagIsDisplayedInTagListByNodeId(deleteTag.toLowerCase());
await tagPage.deleteTagFromTagListByNodeId(deleteTag.toLowerCase());
await tagPage.checkTagIsNotDisplayedInTagList(deleteTag.toLowerCase());
await tagPage.checkTagIsNotDisplayedInTagListByNodeId(deleteTag.toLowerCase());
await tagPage.insertNodeId(deleteFile.id);
await tagPage.addTag(deleteTag);
await tagPage.checkTagIsDisplayedInTagList(deleteTag.toLowerCase());
await tagPage.checkTagIsDisplayedInTagListByNodeId(deleteTag.toLowerCase());
await tagPage.deleteTagFromTagList(deleteTag.toLowerCase());
await tagPage.checkTagIsNotDisplayedInTagList(deleteTag.toLowerCase());
await tagPage.checkTagIsNotDisplayedInTagListByNodeId(deleteTag.toLowerCase());
});
it('[C286290] Should be able to hide the delete option from a tag component', async () => {
await tagPage.insertNodeId(pdfFileModel.id);
await tagPage.addTag(tagList[3]);
await tagPage.checkTagIsDisplayedInTagListByNodeId(tagList[3]);
await tagPage.checkDeleteTagFromTagListByNodeIdIsDisplayed(tagList[3]);
await tagPage.showDeleteButton.click();
await tagPage.checkDeleteTagFromTagListByNodeIdIsNotDisplayed(tagList[3]);
});
it('[C286472] Should be able to click Show more/less button on List Tags Content Services', async () => {
await tagPage.insertNodeId(pdfFileModel.id);
await tagPage.showMoreButton.waitVisible();
await tagPage.showLessButton.waitNotVisible();
await expect(await tagPage.tagsOnPage.count()).toEqual(10);
await tagPage.showMoreButton.click();
await tagPage.showLessButton.waitVisible();
await tagPage.showLessButton.click();
await tagPage.showLessButton.waitNotVisible();
});
});

View File

@@ -0,0 +1,138 @@
/*!
* @license
* Copyright 2019 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 { ApiService, LoginPage, UploadActions, UserModel, UsersActions } from '@alfresco/adf-testing';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { TreeViewPage } from './../pages/tree-view.page';
describe('Tree View Component', () => {
const loginPage = new LoginPage();
const navigationBarPage = new NavigationBarPage();
const treeViewPage = new TreeViewPage();
let acsUser: UserModel;
const apiService = new ApiService();
const usersActions = new UsersActions(apiService);
const uploadActions = new UploadActions(apiService);
let treeFolder, secondTreeFolder, thirdTreeFolder;
const nodeNames = {
folder: 'Folder1',
secondFolder: 'Folder2',
thirdFolder: 'Folder3',
parentFolder: '-my-',
document: 'MyFile'
};
beforeAll(async () => {
await apiService.loginWithProfile('admin');
acsUser = await usersActions.createUser();
await apiService.login(acsUser.username, acsUser.password);
treeFolder = await apiService.getInstance().nodes.addNode(nodeNames.parentFolder, {
name: nodeNames.folder,
nodeType: 'cm:folder'
});
secondTreeFolder = await apiService.getInstance().nodes.addNode(nodeNames.parentFolder, {
name: nodeNames.secondFolder,
nodeType: 'cm:folder'
});
thirdTreeFolder = await apiService.getInstance().nodes.addNode(secondTreeFolder.entry.id, {
name: nodeNames.thirdFolder,
nodeType: 'cm:folder'
});
await apiService.getInstance().nodes.addNode(thirdTreeFolder.entry.id, {
name: nodeNames.document,
nodeType: 'cm:content'
});
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.clickTreeViewButton();
});
afterAll(async () => {
await navigationBarPage.clickLogoutButton();
await apiService.loginWithProfile('admin');
await uploadActions.deleteFileOrFolder(treeFolder.entry.id);
await uploadActions.deleteFileOrFolder(secondTreeFolder.entry.id);
});
it('[C289972] Should be able to show folders and sub-folders of a node as a tree view', async () => {
await treeViewPage.checkTreeViewTitleIsDisplayed();
await expect(await treeViewPage.getNodeId()).toEqual(nodeNames.parentFolder);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.folder);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.secondFolder);
await treeViewPage.clickNode(nodeNames.secondFolder);
await treeViewPage.checkClickedNodeName(nodeNames.secondFolder);
await treeViewPage.checkNodeIsDisplayedAsOpen(nodeNames.secondFolder);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.thirdFolder);
await treeViewPage.clickNode(nodeNames.thirdFolder);
await treeViewPage.checkClickedNodeName(nodeNames.thirdFolder);
await treeViewPage.checkNodeIsDisplayedAsOpen(nodeNames.thirdFolder);
await treeViewPage.clickNode(nodeNames.secondFolder);
await treeViewPage.checkClickedNodeName(nodeNames.secondFolder);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.secondFolder);
await treeViewPage.checkNodeIsNotDisplayed(nodeNames.thirdFolder);
});
it('[C289973] Should be able to change the default nodeId', async () => {
await treeViewPage.clearNodeIdInput();
await treeViewPage.checkNoNodeIdMessageIsDisplayed();
await treeViewPage.addNodeId(secondTreeFolder.entry.id);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.thirdFolder);
await treeViewPage.addNodeId('ThisIdDoesNotExist');
await treeViewPage.checkErrorMessageIsDisplayed();
await treeViewPage.addNodeId(nodeNames.parentFolder);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.folder);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.secondFolder);
await treeViewPage.clickNode(nodeNames.secondFolder);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.thirdFolder);
});
it('[C290071] Should not be able to display files', async () => {
await treeViewPage.addNodeId(secondTreeFolder.entry.id);
await treeViewPage.checkNodeIsDisplayedAsClosed(nodeNames.thirdFolder);
await treeViewPage.clickNode(nodeNames.thirdFolder);
await expect(await treeViewPage.getTotalNodes()).toEqual(1);
});
});

View File

@@ -0,0 +1,194 @@
/*!
* @license
* Copyright 2019 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 CONSTANTS = require('../../util/constants');
import {
ApiService,
BrowserActions,
ErrorPage,
LoginPage,
NotificationHistoryPage,
StringUtil,
UploadActions,
UserModel,
UsersActions
} from '@alfresco/adf-testing';
import { NodeEntry } from '@alfresco/js-api';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { ShareDialogPage } from '../../core/pages/dialog/share-dialog.page';
import { FileModel } from '../../models/ACS/file.model';
import { browser } from 'protractor';
describe('Unshare file', () => {
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const navBar = new NavigationBarPage();
const errorPage = new ErrorPage();
const notificationHistoryPage = new NotificationHistoryPage();
const navigationBarPage = new NavigationBarPage();
const shareDialog = new ShareDialogPage();
const apiService = new ApiService();
const uploadActions = new UploadActions(apiService);
const usersActions = new UsersActions(apiService);
const siteName = `PRIVATE-TEST-SITE-${StringUtil.generateRandomString(5)}`;
let acsUser: UserModel;
let nodeBody, shareFilesSite;
let pngUploadedFile: NodeEntry;
const pngFileModel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PNG.file_path
});
beforeAll(async () => {
await apiService.loginWithProfile('admin');
acsUser = await usersActions.createUser();
const site = {
title: siteName,
visibility: 'PRIVATE',
id: siteName
};
nodeBody = {
name: StringUtil.generateRandomString(5),
nodeType: 'cm:content',
properties: {
'cm:title': StringUtil.generateRandomString(5)
}
};
shareFilesSite = await apiService.getInstance().core.sitesApi.createSite(site);
const docLibId = (await apiService.getInstance().core.sitesApi.getSiteContainers(siteName)).list.entries[0].entry.id;
const testFile1Id = (await apiService.getInstance().core.nodesApi.addNode(docLibId, nodeBody)).entry.id;
await apiService.getInstance().core.sitesApi.addSiteMember(siteName, {
id: acsUser.username,
role: CONSTANTS.CS_USER_ROLES.CONSUMER
});
await apiService.getInstance().core.nodesApi.updateNode(testFile1Id, {
permissions: {
isInheritanceEnabled: false,
locallySet: [
{
authorityId: acsUser.username,
name: CONSTANTS.CS_USER_ROLES.CONSUMER
}
]
}
});
await apiService.getInstance().core.sharedlinksApi.addSharedLink({ nodeId: testFile1Id });
});
afterAll(async () => {
await navigationBarPage.clickLogoutButton();
await apiService.getInstance().core.sitesApi.deleteSite(shareFilesSite.entry.id, { permanent: true });
});
describe('with permission', () => {
afterEach(async () => {
await apiService.loginWithProfile('admin');
await navigationBarPage.clickLogoutButton();
await uploadActions.deleteFileOrFolder(pngUploadedFile.entry.id);
});
beforeEach(async () => {
await apiService.login(acsUser.username, acsUser.password);
pngUploadedFile = await uploadActions.uploadFile(pngFileModel.location, pngFileModel.name, '-my-');
await loginPage.login(acsUser.username, acsUser.password);
await navBar.navigateToContentServices();
await contentServicesPage.waitForTableBody();
});
it('[C286551] Should be able to cancel unshare action', async () => {
await contentServicesPage.getDocumentList().selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickUnShareFile();
await shareDialog.confirmationDialogIsDisplayed();
await shareDialog.clickConfirmationDialogCancelButton();
await shareDialog.shareToggleButtonIsChecked();
});
it('[C286550] Should display unshare confirmation dialog', async () => {
await contentServicesPage.getDocumentList().selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await browser.sleep(2000);
await shareDialog.clickUnShareFile();
await shareDialog.confirmationDialogIsDisplayed();
});
it('[C286552] Should be able to confirm unshare action', async () => {
await contentServicesPage.getDocumentList().selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.clickUnShareFile();
await shareDialog.confirmationDialogIsDisplayed();
await shareDialog.clickConfirmationDialogRemoveButton();
await shareDialog.dialogIsClosed();
});
it('[C280556] Should redirect to 404 when trying to access an unshared file', async () => {
await contentServicesPage.getDocumentList().selectRow(pngFileModel.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await browser.sleep(2000);
const sharedLink = await shareDialog.getShareLink();
await shareDialog.clickUnShareFile();
await shareDialog.confirmationDialogIsDisplayed();
await shareDialog.clickConfirmationDialogRemoveButton();
await shareDialog.dialogIsClosed();
await BrowserActions.getUrl(sharedLink.replace(browser.params.testConfig.appConfig.ecmHost, `${browser.baseUrl}`));
await errorPage.checkErrorCode();
});
});
describe('without permission', () => {
beforeEach(async () => {
await loginPage.login(acsUser.username, acsUser.password);
});
it('[C286555] Should NOT be able to unshare file without permission', async () => {
await navBar.goToSite(shareFilesSite);
await contentServicesPage.openFolder('documentLibrary');
await contentServicesPage.getDocumentList().selectRow(nodeBody.name);
await contentServicesPage.clickShareButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.shareToggleButtonIsChecked();
await shareDialog.clickUnShareFile();
await shareDialog.confirmationDialogIsDisplayed();
await shareDialog.clickConfirmationDialogRemoveButton();
await shareDialog.checkDialogIsDisplayed();
await shareDialog.shareToggleButtonIsChecked();
await notificationHistoryPage.checkNotifyContains(`You don't have permission to unshare this file`);
});
});
});