2022-09-27 18:49:24 +05:30
|
|
|
/*
|
2022-12-27 12:37:58 +05:30
|
|
|
* Copyright 2022 Collate.
|
2022-09-27 18:49:24 +05:30
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
import {
|
|
|
|
|
descriptionBox,
|
|
|
|
|
interceptURL,
|
|
|
|
|
uuid,
|
|
|
|
|
verifyResponseStatusCode,
|
|
|
|
|
} from '../../common/common';
|
|
|
|
|
import { BASE_URL } from '../../constants/constants';
|
2022-09-27 18:49:24 +05:30
|
|
|
|
|
|
|
|
const roleName = `Role-test-${uuid()}`;
|
|
|
|
|
const userName = `Usercttest${uuid()}`;
|
|
|
|
|
const userEmail = `${userName}@gmail.com`;
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
describe('Test Add role and assign it to the user', () => {
|
2022-09-27 18:49:24 +05:30
|
|
|
beforeEach(() => {
|
2022-11-21 17:02:48 +05:30
|
|
|
cy.login();
|
2023-01-15 18:24:10 +05:30
|
|
|
|
2022-09-27 18:49:24 +05:30
|
|
|
interceptURL('GET', '*api/v1/roles*', 'getRoles');
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid="appbar-item-settings"]').should('be.visible').click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-menu-id*="roles"]').should('be.visible').click();
|
|
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@getRoles', 200);
|
|
|
|
|
|
2022-12-29 17:01:34 +05:30
|
|
|
cy.url().should('eq', `${BASE_URL}/settings/access/roles`);
|
2022-09-27 18:49:24 +05:30
|
|
|
});
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
it('Create and Assign role to user', () => {
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get('[data-testid="add-role"]')
|
|
|
|
|
.contains('Add Role')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Asserting navigation
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get('[data-testid="inactive-link"]')
|
|
|
|
|
.should('contain', 'Add New Role')
|
|
|
|
|
.should('be.visible');
|
2023-01-15 18:24:10 +05:30
|
|
|
// Entering name
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get('#name').should('be.visible').type(roleName);
|
2023-01-15 18:24:10 +05:30
|
|
|
// Entering descrription
|
|
|
|
|
cy.get(descriptionBox).type('description');
|
|
|
|
|
// Select the policies
|
2023-01-04 17:08:38 +05:30
|
|
|
cy.get('[data-testid="policies"]').should('be.visible').click();
|
2022-09-27 18:49:24 +05:30
|
|
|
|
|
|
|
|
cy.get('[title="Data Consumer Policy"]')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
cy.get('[title="Data Steward Policy"]')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
2023-01-15 18:24:10 +05:30
|
|
|
// Save the role
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get('[data-testid="submit-btn"]')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Verify the role is added successfully
|
|
|
|
|
cy.url().should('eq', `${BASE_URL}/settings/access/roles/${roleName}`);
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get('[data-testid="inactive-link"]').should('contain', roleName);
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Verify added description
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get('[data-testid="description"] > [data-testid="viewer-container"]')
|
|
|
|
|
.should('be.visible')
|
2023-01-15 18:24:10 +05:30
|
|
|
.should('contain', 'description');
|
|
|
|
|
|
2022-09-27 18:49:24 +05:30
|
|
|
// Create user and assign newly created role to the user
|
|
|
|
|
cy.get('[data-menu-id*="users"]').should('be.visible').click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid="add-user"]').contains('Add User').click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid="email"]')
|
2023-01-15 18:24:10 +05:30
|
|
|
.scrollIntoView()
|
|
|
|
|
.should('exist')
|
|
|
|
|
.should('be.visible')
|
2022-09-27 18:49:24 +05:30
|
|
|
.type(userEmail);
|
2023-01-15 18:24:10 +05:30
|
|
|
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get('[data-testid="displayName"]')
|
2023-01-15 18:24:10 +05:30
|
|
|
.should('exist')
|
|
|
|
|
.should('be.visible')
|
2022-09-27 18:49:24 +05:30
|
|
|
.type(userName);
|
2023-01-15 18:24:10 +05:30
|
|
|
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.get(descriptionBox)
|
2023-01-15 18:24:10 +05:30
|
|
|
.should('exist')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.type('Adding user');
|
2022-11-14 18:09:38 +05:30
|
|
|
|
|
|
|
|
interceptURL('GET', '/api/v1/users/generateRandomPwd', 'generatePassword');
|
2023-01-15 18:24:10 +05:30
|
|
|
cy.get('[data-testid="password-generator"]')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
2022-11-14 18:09:38 +05:30
|
|
|
verifyResponseStatusCode('@generatePassword', 200);
|
2022-09-27 18:49:24 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
cy.get(`[id="menu-button-Roles"]`)
|
|
|
|
|
.should('exist')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
cy.get(`[data-testid="${roleName}"]`)
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
2022-11-14 18:09:38 +05:30
|
|
|
|
|
|
|
|
cy.get('[data-testid="roles-dropdown"]').click();
|
|
|
|
|
|
|
|
|
|
cy.wait(1000);
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
interceptURL(
|
|
|
|
|
'GET',
|
|
|
|
|
'/api/v1/users?fields=profile,teams,roles&&isBot=false&limit=15',
|
|
|
|
|
'getUserPage'
|
|
|
|
|
);
|
2022-09-27 18:49:24 +05:30
|
|
|
|
|
|
|
|
cy.get('[data-testid="save-user"]').scrollIntoView().click();
|
|
|
|
|
|
2022-11-14 18:09:38 +05:30
|
|
|
verifyResponseStatusCode('@getUserPage', 200);
|
2022-09-27 18:49:24 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
cy.get('[data-testid="searchbar"]')
|
|
|
|
|
.should('exist')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.type(userName);
|
2022-11-14 18:09:38 +05:30
|
|
|
|
|
|
|
|
cy.get(`[data-testid="${userName}"]`).should('be.visible');
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
interceptURL('GET', '/api/v1/users/*', 'userDetailsPage');
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-testid="${userName}"]`).should('be.visible').click();
|
2023-01-15 18:24:10 +05:30
|
|
|
verifyResponseStatusCode('@userDetailsPage', 200);
|
2022-11-14 18:09:38 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
cy.get('[data-testid="left-panel"]')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.should('contain', roleName);
|
|
|
|
|
});
|
|
|
|
|
});
|