Skip to content

Commit

Permalink
[ADF-5283] Fix Permission Flaky test (#6380)
Browse files Browse the repository at this point in the history
* [ADF-5283] Fix Permission Flaky test

* * Removed search service

* * check permission for folder

* * execution flow fixed

* * wait for files to index

* Fix e2e tests

* * wait for user to index

* * try something api fix

* * revert back the changes

* Add sleep

* Refactor permission tests

* bring back good things

Co-authored-by: Cano <[email protected]>
Co-authored-by: Eugenio Romano <[email protected]>
Co-authored-by: Eugenio Romano <[email protected]>
  • Loading branch information
4 people authored Dec 8, 2020
1 parent 6a76ba0 commit d70cfa7
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 142 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ jobs:
name: Build
script:
- ./scripts/travis/build/build.sh
- ./scripts/lint.sh
- ./scripts/travis/release/release-npm.sh
- ./scripts/travis/release/release-docker.sh

after_success:
- ./scripts/travis/release/release-docker.sh
- ./scripts/ci/utils/artifact-to-s3.sh -a ./dist/demo-shell -o "$S3_DBP_FOLDER/alfresco-demoshell.tar.bz2"
- ./scripts/ci/utils/artifact-to-s3.sh -a ./lib/dist -o "$S3_DBP_FOLDER/alfresco-libs.tar.bz2"

- stage: Lint & Build Dist & Release
name: Lint
script:
- ./scripts/lint.sh

- stage: Unit test
name: Unit test content
script: ./scripts/travis/unit-test/content.sh
Expand Down
9 changes: 8 additions & 1 deletion e2e/content-services/pages/permissions.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
BrowserVisibility,
BrowserActions
} from '@alfresco/adf-testing';
import { by, element } from 'protractor';
import { browser, by, element } from 'protractor';

export class PermissionsPage {

Expand All @@ -43,6 +43,13 @@ export class PermissionsPage {
await BrowserActions.click(this.closeButton);
}

async changePermission(name: string, role: string): Promise<void> {
await this.addPermissionsDialog.clickRoleDropdownByUserOrGroupName(name);
await this.addPermissionsDialog.selectOption(role);
await browser.sleep(500);
await this.dataTableComponentPage.checkRowIsNotSelected('Authority ID', name);
}

async checkAddPermissionButtonIsDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.addPermissionButton);
}
Expand Down
129 changes: 33 additions & 96 deletions e2e/content-services/permissions/permissions-component.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
BrowserActions,
LoginPage,
NotificationHistoryPage,
PermissionActions,
SearchService,
StringUtil,
UploadActions,
UserModel,
Expand All @@ -34,6 +36,7 @@ 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', () => {

Expand All @@ -44,6 +47,9 @@ describe('Permissions Component', () => {
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();
Expand Down Expand Up @@ -72,106 +78,47 @@ describe('Permissions Component', () => {
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.email + ' / 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;
let folders;
const fileOwnerUser = new UserModel();
const filePermissionUser = new UserModel();

const duplicateUserPermissionMessage = 'One or more of the permissions you have set is already present : authority -> ' + filePermissionUser.email + ' / role -> Contributor';

beforeAll(async () => {
await apiService.loginWithProfile('admin');
await usersActions.createUser(fileOwnerUser);
await usersActions.createUser(filePermissionUser);
await apiService.getInstance().core.groupsApi.createGroup(groupBody);
await apiService.login(fileOwnerUser.email, fileOwnerUser.password);

// to sync user in acs
await searchService.isUserSearchable(filePermissionUser);

await apiService.login(fileOwnerUser.email, 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-');

folders = [roleConsumerFolder, roleContributorFolder, roleCoordinatorFolder, roleCollaboratorFolder, roleEditorFolder];

await apiService.getInstance().core.nodesApi.updateNode(roleConsumerFolder.entry.id,

{
permissions: {
locallySet: [{
authorityId: filePermissionUser.email,
name: 'Consumer',
accessStatus: 'ALLOWED'
}]
}
});

await apiService.getInstance().core.nodesApi.updateNode(roleCollaboratorFolder.entry.id,
{
permissions: {
locallySet: [{
authorityId: filePermissionUser.email,
name: 'Collaborator',
accessStatus: 'ALLOWED'
}]
}
});

await apiService.getInstance().core.nodesApi.updateNode(roleCoordinatorFolder.entry.id,
{
permissions: {
locallySet: [{
authorityId: filePermissionUser.email,
name: 'Coordinator',
accessStatus: 'ALLOWED'
}]
}
});

await apiService.getInstance().core.nodesApi.updateNode(roleContributorFolder.entry.id,

{
permissions: {
locallySet: [{
authorityId: filePermissionUser.email,
name: 'Contributor',
accessStatus: 'ALLOWED'
}]
}
});

await apiService.getInstance().core.nodesApi.updateNode(roleEditorFolder.entry.id,

{
permissions: {
locallySet: [{
authorityId: filePermissionUser.email,
name: 'Editor',
accessStatus: 'ALLOWED'
}]
}
});

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 browser.sleep(browser.params.testConfig.timeouts.index_search); // wait search index previous file/folder uploaded
});
await permissionActions.addRoleForUser(filePermissionUser.email, 'Consumer', roleConsumerFolder);
await permissionActions.addRoleForUser(filePermissionUser.email, 'Collaborator', roleCollaboratorFolder);
await permissionActions.addRoleForUser(filePermissionUser.email, 'Coordinator', roleCoordinatorFolder);
await permissionActions.addRoleForUser(filePermissionUser.email, 'Contributor', roleContributorFolder);
await permissionActions.addRoleForUser(filePermissionUser.email, 'Editor', roleEditorFolder);

afterAll(async () => {
await apiService.loginWithProfile('admin');
for (const folder of folders) {
await uploadActions.deleteFileOrFolder(folder.entry.id);
}
await browser.sleep(browser.params.testConfig.timeouts.index_search); // wait search index previous file/folder uploaded
});

describe('Inherit and assigning permissions', () => {
Expand Down Expand Up @@ -200,19 +147,6 @@ describe('Permissions Component', () => {
await navigationBarPage.clickLogoutButton();
});

it('[C268974] Inherit Permission', async () => {
await permissionsPage.addPermissionsDialog.checkPermissionInheritedButtonIsDisplayed();
await permissionsPage.addPermissionsDialog.getPermissionInheritedButtonText('Permission Inherited');
await permissionsPage.addPermissionsDialog.checkPermissionsDatatableIsDisplayed();
await permissionsPage.addPermissionsDialog.clickPermissionInheritedButton();

await permissionsPage.addPermissionsDialog.getPermissionInheritedButtonText('Inherit Permission');
await permissionsPage.addPermissionsDialog.checkNoPermissionsIsDisplayed();
await permissionsPage.addPermissionsDialog.clickPermissionInheritedButton();
await permissionsPage.addPermissionsDialog.getPermissionInheritedButtonText('Permission Inherited');
await permissionsPage.addPermissionsDialog.checkPermissionsDatatableIsDisplayed();
});

it('[C286272] Should be able to see results when searching for a user', async () => {
await permissionsPage.checkAddPermissionButtonIsDisplayed();
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
Expand Down Expand Up @@ -262,7 +196,7 @@ describe('Permissions Component', () => {
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.email);
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.clickUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.checkUserIsAdded(filePermissionUser.email);
});
Expand All @@ -284,19 +218,17 @@ describe('Permissions Component', () => {
await expect(await BrowserActions.getText(roleDropdownOptions.get(3))).toBe('Editor');
await expect(await BrowserActions.getText(roleDropdownOptions.get(4))).toBe('Consumer');

await permissionsPage.addPermissionsDialog.selectOption('Collaborator');
await BrowserActions.closeMenuAndDialogs();
await permissionsPage.changePermission(filePermissionUser.email, 'Collaborator');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.email)).toEqual('Collaborator');

await permissionsPage.addPermissionsDialog.clickRoleDropdownByUserOrGroupName(filePermissionUser.email);
await permissionsPage.addPermissionsDialog.selectOption('Coordinator');
await permissionsPage.changePermission(filePermissionUser.email, 'Coordinator');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.email)).toEqual('Coordinator');

await permissionsPage.addPermissionsDialog.clickRoleDropdownByUserOrGroupName(filePermissionUser.email);
await permissionsPage.addPermissionsDialog.selectOption('Editor');
await permissionsPage.changePermission(filePermissionUser.email, 'Editor');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.email)).toEqual('Editor');

await permissionsPage.addPermissionsDialog.clickRoleDropdownByUserOrGroupName(filePermissionUser.email);
await permissionsPage.addPermissionsDialog.selectOption('Consumer');
await permissionsPage.changePermission(filePermissionUser.email, 'Consumer');
await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(filePermissionUser.email)).toEqual('Consumer');
});

Expand All @@ -305,9 +237,10 @@ describe('Permissions Component', () => {
await permissionsPage.addPermissionsDialog.clickAddPermissionButton();
await permissionsPage.addPermissionsDialog.checkAddPermissionDialogIsDisplayed();
await permissionsPage.addPermissionsDialog.checkSearchUserInputIsDisplayed();
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.email);
await permissionsPage.addPermissionsDialog.searchUserOrGroup(filePermissionUser.firstName);
await permissionsPage.addPermissionsDialog.clickUserOrGroup(filePermissionUser.firstName);

await expect(await notificationPage.getSnackBarMessage()).toEqual(duplicateUserPermissionMessage);
await notificationHistoryPage.checkNotifyContains(duplicateUserPermissionMessage);
});

Expand Down Expand Up @@ -336,8 +269,11 @@ describe('Permissions Component', () => {
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');
});

Expand Down Expand Up @@ -443,8 +379,9 @@ describe('Permissions Component', () => {
await permissionsPage.addPermissionsDialog.checkPermissionInheritedButtonIsDisplayed();
await permissionsPage.checkAddPermissionButtonIsDisplayed();
await permissionsPage.addPermissionsDialog.clickPermissionInheritedButton();
await notificationHistoryPage.checkNotifyContains('You are not allowed to change permissions');
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');
});
});
Expand Down
7 changes: 0 additions & 7 deletions e2e/protractor.excludes.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
"C279932": "login problem APS not basic",
"C279931": "login problem APS not basic",
"C279930": "login problem APS not basic",
"C274691": "ADF-5283 Fix Permission Flaky test",
"C276980": "ADF-5283 Fix Permission Flaky test",
"C276993": "ADF-5283 Fix Permission Flaky test",
"C276996": "ADF-5283 Fix Permission Flaky test",
"C277000": "ADF-5283 Fix Permission Flaky test",
"C277003": "ADF-5283 Fix Permission Flaky test",
"C277004": "ADF-5283 Fix Permission Flaky test",
"C299187": "ADF-5285 Failing aspect test due multiple replica",
"C311290": "ADF-5293"
}
Loading

0 comments on commit d70cfa7

Please sign in to comment.