Skip to content

Commit c8f2c39

Browse files
committed
test: [PROD-14244] update tests after viewer security changes
1 parent e1bdb4c commit c8f2c39

File tree

6 files changed

+35
-31
lines changed

6 files changed

+35
-31
lines changed

cypress/commons/constants/generic/TestConstants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const PERMISSIONS = {
120120

121121
export const ROLES_PERMISSIONS_MAP = {
122122
[ROLES.SCENARIO.VIEWER]: {
123-
granted: [PERMISSIONS.SCENARIO.READ, PERMISSIONS.SCENARIO.READ_SECURITY],
123+
granted: [PERMISSIONS.SCENARIO.READ],
124124
notGranted: [
125125
PERMISSIONS.SCENARIO.LAUNCH,
126126
PERMISSIONS.SCENARIO.WRITE,

cypress/e2e/brewery/ScenarioSharing.cy.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,12 @@ describe('Check workspace permissions for Viewer, Editor & Validator', () => {
147147
stub.stop();
148148
});
149149

150-
it('Check Viewer permissions', () => {
150+
it('must show a disabled button when role is Viewer', () => {
151151
const scenario = SHARED_SCENARIOS_LIST[0];
152152
ScenarioSelector.selectScenario(scenario.name, scenario.id, true);
153153

154154
Scenarios.getScenarioValidateButton().should('not.exist');
155-
RolesEdition.getShareButton().should('be.visible').should('not.be.disabled').click();
156-
RolesEdition.getShareDialogAgentsSelect().should('not.exist');
157-
RolesEdition.getRoleEditorAgentName(USERS_LIST[1].email).should('have.text', USERS_LIST[1].email);
158-
RolesEdition.getSelectedOptionByAgent(USERS_LIST[1].email).should('value', ROLES.SCENARIO.VIEWER);
159-
RolesEdition.isRoleEditorSelectorDisabled(USERS_LIST[1].email).should('eq', 'true');
160-
RolesEdition.getRoleEditorAgentName(USERS_LIST[2].email).should('have.text', USERS_LIST[2].email);
161-
RolesEdition.getSelectedOptionByAgent(USERS_LIST[2].email).should('value', ROLES.SCENARIO.EDITOR);
162-
RolesEdition.isRoleEditorSelectorDisabled(USERS_LIST[2].email).should('eq', 'true');
163-
RolesEdition.getRoleEditorAgentName(USERS_LIST[3].email).should('have.text', USERS_LIST[3].email);
164-
RolesEdition.getSelectedOptionByAgent(USERS_LIST[3].email).should('value', ROLES.SCENARIO.VALIDATOR);
165-
RolesEdition.isRoleEditorSelectorDisabled(USERS_LIST[3].email).should('eq', 'true');
166-
RolesEdition.isRoleEditorSelectorDisabled('Workspace').should('eq', 'true');
167-
RolesEdition.getShareDialogConfirmAddAccessButton().should('not.exist');
168-
RolesEdition.getShareDialogFirstCancelButton().click();
155+
RolesEdition.getShareButton().should('be.visible').should('be.disabled');
169156

170157
Scenarios.getScenarioValidateButton().should('not.exist');
171158
Scenarios.getScenarioRejectButton().should('not.exist');
@@ -186,6 +173,21 @@ describe('Check workspace permissions for Viewer, Editor & Validator', () => {
186173
const scenario = SHARED_SCENARIOS_LIST[1];
187174
ScenarioSelector.selectScenario(scenario.name, scenario.id);
188175

176+
RolesEdition.getShareButton().should('be.visible').should('not.be.disabled').click();
177+
RolesEdition.getShareDialogAgentsSelect().should('not.exist');
178+
RolesEdition.getRoleEditorAgentName(USERS_LIST[1].email).should('have.text', USERS_LIST[1].email);
179+
RolesEdition.getSelectedOptionByAgent(USERS_LIST[1].email).should('value', ROLES.SCENARIO.VIEWER);
180+
RolesEdition.isRoleEditorSelectorDisabled(USERS_LIST[1].email).should('eq', 'true');
181+
RolesEdition.getRoleEditorAgentName(USERS_LIST[2].email).should('have.text', USERS_LIST[2].email);
182+
RolesEdition.getSelectedOptionByAgent(USERS_LIST[2].email).should('value', ROLES.SCENARIO.EDITOR);
183+
RolesEdition.isRoleEditorSelectorDisabled(USERS_LIST[2].email).should('eq', 'true');
184+
RolesEdition.getRoleEditorAgentName(USERS_LIST[3].email).should('have.text', USERS_LIST[3].email);
185+
RolesEdition.getSelectedOptionByAgent(USERS_LIST[3].email).should('value', ROLES.SCENARIO.VALIDATOR);
186+
RolesEdition.isRoleEditorSelectorDisabled(USERS_LIST[3].email).should('eq', 'true');
187+
RolesEdition.isRoleEditorSelectorDisabled('Workspace').should('eq', 'true');
188+
RolesEdition.getShareDialogConfirmAddAccessButton().should('not.exist');
189+
RolesEdition.getShareDialogFirstCancelButton().click();
190+
189191
Scenarios.getScenarioValidateButton().should('not.exist');
190192
Scenarios.getScenarioRejectButton().should('not.exist');
191193
ScenarioParameters.getLaunchButton().should('be.visible').should('not.be.disabled');

cypress/fixtures/stubbing/default/organizations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const DEFAULT_ORGANIZATION_PERMISSIONS = [
66
component: 'organization',
77
roles: {
88
none: [],
9-
viewer: ['read', 'read_security'],
9+
viewer: ['read'],
1010
user: ['read', 'read_security', 'create_children'],
1111
editor: ['read', 'read_security', 'create_children', 'write'],
1212
admin: ['read', 'read_security', 'create_children', 'write', 'write_security', 'delete'],
@@ -16,7 +16,7 @@ export const DEFAULT_ORGANIZATION_PERMISSIONS = [
1616
component: 'workspace',
1717
roles: {
1818
none: [],
19-
viewer: ['read', 'read_security'],
19+
viewer: ['read'],
2020
user: ['read', 'read_security', 'create_children'],
2121
editor: ['read', 'read_security', 'create_children', 'write'],
2222
admin: ['read', 'read_security', 'create_children', 'write', 'write_security', 'delete'],
@@ -26,7 +26,7 @@ export const DEFAULT_ORGANIZATION_PERMISSIONS = [
2626
component: 'scenario',
2727
roles: {
2828
none: [],
29-
viewer: ['read', 'read_security'],
29+
viewer: ['read'],
3030
editor: ['read', 'read_security', 'launch', 'write'],
3131
validator: ['read', 'read_security', 'launch', 'write', 'validate'],
3232
admin: ['read', 'read_security', 'launch', 'write', 'validate', 'write_security', 'delete'],

src/components/ShareCurrentScenarioButton/ShareCurrentScenarioButton.spec.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,23 @@ describe('ShareCurrentScenarioButton', () => {
5050
mockRoleEditionButtonProps = undefined;
5151
});
5252

53-
test('None role dont display Share Scenario button', () => {
54-
setUp(ROLES.SCENARIO.NONE);
55-
expect(getRolesEditionButton()).not.toBeInTheDocument();
56-
});
53+
test.each([{ role: ROLES.SCENARIO.NONE }, { role: ROLES.SCENARIO.VIEWER }])(
54+
'must show a disabled button when role is $role',
55+
({ role }) => {
56+
setUp(role);
57+
expect(getRolesEditionButton()).toBeInTheDocument();
58+
expect(mockRoleEditionButtonProps.disabled).toEqual(true);
59+
}
60+
);
5761

5862
test.each([
59-
{ role: ROLES.SCENARIO.ADMIN, expected: undefined },
63+
{ role: ROLES.SCENARIO.ADMIN, expected: false },
6064
{ role: ROLES.SCENARIO.EDITOR, expected: true },
6165
{ role: ROLES.SCENARIO.VALIDATOR, expected: true },
62-
{ role: ROLES.SCENARIO.VIEWER, expected: true },
6366
])('$role role display Share Scenario button with isReadOnly $expected', ({ role, expected }) => {
6467
setUp(role);
6568
expect(getRolesEditionButton()).toBeInTheDocument();
69+
expect(mockRoleEditionButtonProps.disabled).toEqual(false);
6670
expect(mockRoleEditionButtonProps.isReadOnly).toEqual(expected);
6771
});
6872
});

tests/samples/application.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const DEFAULT_APPLICATION = {
6060
},
6161
permissionsMapping: {
6262
organization: {
63-
[ROLES.ORGANIZATION.VIEWER]: [PERMISSIONS.ORGANIZATION.READ, PERMISSIONS.ORGANIZATION.READ_SECURITY],
64-
[ROLES.ORGANIZATION.VIEWER]: [
63+
[ROLES.ORGANIZATION.VIEWER]: [PERMISSIONS.ORGANIZATION.READ],
64+
[ROLES.ORGANIZATION.USER]: [
6565
PERMISSIONS.ORGANIZATION.READ,
6666
PERMISSIONS.ORGANIZATION.READ_SECURITY,
6767
PERMISSIONS.ORGANIZATION.CREATE_CHILDREN,
@@ -83,7 +83,7 @@ export const DEFAULT_APPLICATION = {
8383
[ROLES.ORGANIZATION.NONE]: [],
8484
},
8585
workspace: {
86-
[ROLES.WORKSPACE.VIEWER]: [PERMISSIONS.WORKSPACE.READ, PERMISSIONS.WORKSPACE.READ_SECURITY],
86+
[ROLES.WORKSPACE.VIEWER]: [PERMISSIONS.WORKSPACE.READ],
8787
[ROLES.WORKSPACE.USER]: [
8888
PERMISSIONS.WORKSPACE.READ,
8989
PERMISSIONS.WORKSPACE.READ_SECURITY,
@@ -106,7 +106,7 @@ export const DEFAULT_APPLICATION = {
106106
[ROLES.WORKSPACE.NONE]: [],
107107
},
108108
scenario: {
109-
[ROLES.SCENARIO.VIEWER]: [PERMISSIONS.SCENARIO.READ, PERMISSIONS.SCENARIO.READ_SECURITY],
109+
[ROLES.SCENARIO.VIEWER]: [PERMISSIONS.SCENARIO.READ],
110110
[ROLES.SCENARIO.EDITOR]: [
111111
PERMISSIONS.SCENARIO.READ,
112112
PERMISSIONS.SCENARIO.READ_SECURITY,

tests/samples/reduxState.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Copyright (c) Cosmo Tech.
22
// Licensed under the MIT license.
3-
// Copyright (c) Cosmo Tech.
4-
// Licensed under the MIT license.
53
import { DEFAULT_APPLICATION } from './application';
64
import { USER_AUTH_ADMIN } from './auth';
75
import { DEFAULT_DATASETS_LIST_DATA } from './datasets';

0 commit comments

Comments
 (0)