diff --git a/ui/cypress/support/utils/user/PermissionUtils.ts b/ui/cypress/support/utils/user/PermissionUtils.ts index f56ab3f7b9..9907c56acc 100644 --- a/ui/cypress/support/utils/user/PermissionUtils.ts +++ b/ui/cypress/support/utils/user/PermissionUtils.ts @@ -26,6 +26,19 @@ export class PermissionUtils { public static markElementAsPublic() { PermissionUtils.openManagePermissions(); StaticPropertyUtils.clickCheckbox('permission-public-element'); + PermissionUtils.save(); + } + + public static authorizeUser(email: string) { + PermissionUtils.openManagePermissions(); + + cy.dataCy('authorized-user').type(email); + cy.get(`[data-cy="user-option-${email}"]`).click(); + + PermissionUtils.save(); + } + + public static save() { cy.dataCy('sp-manage-permissions-save').click(); } } diff --git a/ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts b/ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts index 790f5c884d..04290d02ca 100644 --- a/ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts +++ b/ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts @@ -19,66 +19,49 @@ import { UserRole } from '../../../src/app/_enums/user-role.enum'; import { UserUtils } from '../../support/utils/UserUtils'; import { ConnectUtils } from '../../support/utils/connect/ConnectUtils'; import { PermissionUtils } from '../../support/utils/user/PermissionUtils'; +import { GeneralUtils } from '../../support/utils/GeneralUtils'; describe('Test User Roles for Connect', () => { + var connectAdminUser; beforeEach('Setup Test', () => { cy.initStreamPipesTest(); - }); - - // it('Connect admin should not see adapters of other users', () => { - // const connectAdminUser = UserUtils.createUser( - // 'user', - // UserRole.ROLE_CONNECT_ADMIN, - // ); - // - // ConnectUtils.addMachineDataSimulator('simulator'); - // - // UserUtils.switchUser(connectAdminUser); - // - // GeneralUtils.validateAmountOfNavigationIcons(3); - // - // // Validate that no adapter is visible - // ConnectUtils.checkAmountOfAdapters(0); - // }); - - // it('Connect admin should see public adapters of other users', () => { - // const connectAdminUser = UserUtils.createUser( - // 'user', - // UserRole.ROLE_CONNECT_ADMIN, - // ); - // - // ConnectUtils.addMachineDataSimulator('simulator'); - // - // // Set adapter to public - // PermissionUtils.markElementAsPublic(); - // - // UserUtils.switchUser(connectAdminUser); - // - // GeneralUtils.validateAmountOfNavigationIcons(3); - // - // // Validate that adapter is visible - // ConnectUtils.checkAmountOfAdapters(1); - // }); - - it('Connect admin should see shared adapters of other users', () => { - const connectAdminUser = UserUtils.createUser( + connectAdminUser = UserUtils.createUser( 'user', UserRole.ROLE_CONNECT_ADMIN, ); - ConnectUtils.addMachineDataSimulator('simulator'); + }); + + it('Connect admin should not see adapters of other users', () => { + UserUtils.switchUser(connectAdminUser); + + GeneralUtils.validateAmountOfNavigationIcons(3); + // Validate that no adapter is visible + ConnectUtils.checkAmountOfAdapters(0); + }); + + it('Connect admin should see public adapters of other users', () => { // Set adapter to public - PermissionUtils.openManagePermissions(); - cy.dataCy('authorized-user').type(`${connectAdminUser.email}{tab}`); + PermissionUtils.markElementAsPublic(); + + UserUtils.switchUser(connectAdminUser); + + GeneralUtils.validateAmountOfNavigationIcons(3); + + // Validate that adapter is visible + ConnectUtils.checkAmountOfAdapters(1); + }); + + it('Connect admin should see shared adapters of other users', () => { + // Share adapter with user + PermissionUtils.authorizeUser(connectAdminUser.email); + + UserUtils.switchUser(connectAdminUser); - // cy.dataCy('sp-manage-permissions-save').click(); + GeneralUtils.validateAmountOfNavigationIcons(3); - // UserUtils.switchUser(connectAdminUser); - // - // GeneralUtils.validateAmountOfNavigationIcons(3); - // - // // Validate that adapter is visible - // ConnectUtils.checkAmountOfAdapters(1); + // Validate that adapter is visible + ConnectUtils.checkAmountOfAdapters(1); }); }); diff --git a/ui/src/app/core-ui/object-permission-dialog/object-permission-dialog.component.html b/ui/src/app/core-ui/object-permission-dialog/object-permission-dialog.component.html index 7dda706b7e..ba806e1b7b 100644 --- a/ui/src/app/core-ui/object-permission-dialog/object-permission-dialog.component.html +++ b/ui/src/app/core-ui/object-permission-dialog/object-permission-dialog.component.html @@ -80,6 +80,7 @@