Skip to content

Commit

Permalink
fix(#3372): Change tests to share adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Dec 17, 2024
1 parent 57ad7e3 commit 46aebf9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
13 changes: 13 additions & 0 deletions ui/cypress/support/utils/user/PermissionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
81 changes: 32 additions & 49 deletions ui/cypress/tests/userManagement/testUserRoleConnect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h4>{{ headerTitle }}</h4>
<mat-option
*ngFor="let user of filteredUsers | async"
[value]="user"
[attr.data-cy]="'user-option-' + user.username"
>
{{ user.username }}
</mat-option>
Expand Down

0 comments on commit 46aebf9

Please sign in to comment.