mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-29 17:49:14 +00:00
minor(ui): migrate AddRoleAndAssignToUser.spec (#17670)
* minor(ui): migrate AddRoleAndAssignToUser.spec * migrate SchemaDefinition * revert vite changes
This commit is contained in:
parent
1848be697b
commit
f01f250d68
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 Collate.
|
||||
* 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.
|
||||
*/
|
||||
import { visitEntityDetailsPage } from '../../common/Utils/Entity';
|
||||
import { EntityType } from '../../constants/Entity.interface';
|
||||
|
||||
const table = {
|
||||
term: 'dim_address',
|
||||
serviceName: 'sample_data',
|
||||
entity: EntityType.Table,
|
||||
};
|
||||
const query =
|
||||
'CREATE TABLE dim_address(address_id NUMERIC PRIMARY KEY, shop_id NUMERIC)';
|
||||
|
||||
describe('Schema definition (views)', () => {
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
});
|
||||
|
||||
it('Verify schema definition (views) of table entity', () => {
|
||||
visitEntityDetailsPage(table);
|
||||
|
||||
cy.get('[data-testid="schema_definition"]').click();
|
||||
cy.get('.CodeMirror-line > [role="presentation"]').should('contain', query);
|
||||
});
|
||||
});
|
||||
@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 Collate.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import {
|
||||
descriptionBox,
|
||||
interceptURL,
|
||||
uuid,
|
||||
verifyResponseStatusCode,
|
||||
} from '../../common/common';
|
||||
import { validateFormNameFieldInput } from '../../common/Utils/Form';
|
||||
import { BASE_URL } from '../../constants/constants';
|
||||
import { GlobalSettingOptions } from '../../constants/settings.constant';
|
||||
|
||||
const roleName = `Role-test-${uuid()}`;
|
||||
const userName = `usercttest${uuid()}`;
|
||||
const userEmail = `${userName}@gmail.com`;
|
||||
|
||||
describe(
|
||||
'Test Add role and assign it to the user',
|
||||
{ tags: 'Settings' },
|
||||
() => {
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
interceptURL('GET', '*api/v1/roles*', 'getRoles');
|
||||
interceptURL('GET', '/api/v1/users?*', 'usersPage');
|
||||
});
|
||||
|
||||
it('Create role', () => {
|
||||
cy.settingClick(GlobalSettingOptions.ROLES);
|
||||
verifyResponseStatusCode('@getRoles', 200);
|
||||
|
||||
cy.get('[data-testid="add-role"]').contains('Add Role').click();
|
||||
|
||||
// Asserting navigation
|
||||
cy.get('[data-testid="inactive-link"]').should('contain', 'Add New Role');
|
||||
|
||||
// Entering name
|
||||
validateFormNameFieldInput({
|
||||
value: roleName,
|
||||
fieldName: 'Name',
|
||||
errorDivSelector: '#name_help',
|
||||
});
|
||||
// Entering descrription
|
||||
cy.get(descriptionBox).type('description');
|
||||
// Select the policies
|
||||
cy.get('[data-testid="policies"]').click();
|
||||
|
||||
cy.get('[title="Data Consumer Policy"]').scrollIntoView().click();
|
||||
|
||||
cy.get('[title="Data Steward Policy"]').scrollIntoView().click();
|
||||
// Save the role
|
||||
cy.get('[data-testid="submit-btn"]').scrollIntoView().click();
|
||||
|
||||
// Verify the role is added successfully
|
||||
cy.url().should('eq', `${BASE_URL}/settings/access/roles/${roleName}`);
|
||||
cy.get('[data-testid="inactive-link"]').should('contain', roleName);
|
||||
|
||||
// Verify added description
|
||||
cy.get(
|
||||
'[data-testid="asset-description-container"] [data-testid="viewer-container"]'
|
||||
).should('contain', 'description');
|
||||
});
|
||||
|
||||
it('Create new user and assign new role to him', () => {
|
||||
// Create user and assign newly created role to the user
|
||||
cy.settingClick(GlobalSettingOptions.USERS);
|
||||
verifyResponseStatusCode('@usersPage', 200);
|
||||
|
||||
cy.get('[data-testid="add-user"]').contains('Add User').click();
|
||||
|
||||
cy.get('[data-testid="email"]').scrollIntoView().type(userEmail);
|
||||
|
||||
cy.get('[data-testid="displayName"]').type(userName);
|
||||
|
||||
cy.get(descriptionBox).type('Adding user');
|
||||
|
||||
interceptURL(
|
||||
'GET',
|
||||
'/api/v1/users/generateRandomPwd',
|
||||
'generatePassword'
|
||||
);
|
||||
cy.get('[data-testid="password-generator"]').scrollIntoView().click();
|
||||
verifyResponseStatusCode('@generatePassword', 200);
|
||||
|
||||
cy.get(`[data-testid="roles-dropdown"]`).type(roleName);
|
||||
cy.get(`.ant-select-dropdown [title="${roleName}"]`).click();
|
||||
|
||||
cy.clickOutside();
|
||||
interceptURL('POST', '/api/v1/users', 'createUser');
|
||||
cy.get('[data-testid="save-user"]').scrollIntoView().click();
|
||||
verifyResponseStatusCode('@createUser', 201);
|
||||
});
|
||||
|
||||
it('Verify assigned role to new user', () => {
|
||||
cy.settingClick(GlobalSettingOptions.USERS);
|
||||
verifyResponseStatusCode('@usersPage', 200);
|
||||
|
||||
interceptURL(
|
||||
'GET',
|
||||
'/api/v1/search/query?q=**&from=0&size=*&index=*',
|
||||
'searchUser'
|
||||
);
|
||||
interceptURL('GET', '/api/v1/users/name/*', 'userDetailsPage');
|
||||
cy.get('[data-testid="searchbar"]').type(userName);
|
||||
verifyResponseStatusCode('@searchUser', 200);
|
||||
|
||||
cy.get(`[data-testid="${userName}"]`).click();
|
||||
verifyResponseStatusCode('@userDetailsPage', 200);
|
||||
|
||||
// click the collapse button to open the other details
|
||||
cy.get(
|
||||
'[data-testid="user-profile"] .ant-collapse-expand-icon > .anticon'
|
||||
).click();
|
||||
|
||||
cy.get(
|
||||
'[data-testid="user-profile"] [data-testid="user-profile-roles"]'
|
||||
).should('contain', roleName);
|
||||
});
|
||||
}
|
||||
);
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2024 Collate.
|
||||
* 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.
|
||||
*/
|
||||
import test, { expect } from '@playwright/test';
|
||||
import { redirectToHomePage } from '../../utils/common';
|
||||
import { visitEntityPage } from '../../utils/entity';
|
||||
|
||||
const table = {
|
||||
term: 'dim_address',
|
||||
serviceName: 'sample_data',
|
||||
};
|
||||
const query =
|
||||
'CREATE TABLE dim_address(address_id NUMERIC PRIMARY KEY, shop_id NUMERIC)';
|
||||
|
||||
// use the admin user to login
|
||||
test.use({ storageState: 'playwright/.auth/admin.json', trace: 'off' });
|
||||
|
||||
test.describe('Schema definition (views)', () => {
|
||||
test.beforeEach('pre-requisite', async ({ page }) => {
|
||||
await redirectToHomePage(page);
|
||||
});
|
||||
|
||||
test('Verify schema definition (views) of table entity', async ({ page }) => {
|
||||
await visitEntityPage({
|
||||
page,
|
||||
searchTerm: table.term,
|
||||
dataTestId: `${table.serviceName}-${table.term}`,
|
||||
});
|
||||
|
||||
await page.click('[data-testid="schema_definition"]');
|
||||
await page.waitForSelector('.CodeMirror-line > [role="presentation"]');
|
||||
|
||||
await expect(
|
||||
page.locator('.CodeMirror-line > [role="presentation"]')
|
||||
).toContainText(query);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2022 Collate.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import test, { expect } from '@playwright/test';
|
||||
import { GlobalSettingOptions } from '../../constant/settings';
|
||||
import {
|
||||
clickOutside,
|
||||
createNewPage,
|
||||
descriptionBox,
|
||||
generateRandomUsername,
|
||||
redirectToHomePage,
|
||||
uuid,
|
||||
} from '../../utils/common';
|
||||
import { settingClick } from '../../utils/sidebar';
|
||||
|
||||
const roleName = `Role-test-${uuid()}`;
|
||||
const user = generateRandomUsername();
|
||||
const userDisplayName = user.firstName + ' ' + user.lastName;
|
||||
const userName = user.email.split('@')[0].toLowerCase();
|
||||
|
||||
// use the admin user to login
|
||||
test.use({ storageState: 'playwright/.auth/admin.json', trace: 'off' });
|
||||
|
||||
test.describe.serial('Add role and assign it to the user', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await redirectToHomePage(page);
|
||||
});
|
||||
|
||||
test.afterAll('cleanup', async ({ browser }) => {
|
||||
const { apiContext, afterAction } = await createNewPage(browser);
|
||||
|
||||
await apiContext.delete(`/api/v1/roles/name/${roleName}`);
|
||||
await apiContext.delete(`/api/v1/users/name/${userName}`);
|
||||
|
||||
await afterAction();
|
||||
});
|
||||
|
||||
test('Create role', async ({ page }) => {
|
||||
await settingClick(page, GlobalSettingOptions.ROLES);
|
||||
|
||||
await page.click('[data-testid="add-role"]');
|
||||
|
||||
await page.fill('[data-testid="name"]', roleName);
|
||||
await page.fill(descriptionBox, `description for ${roleName}`);
|
||||
|
||||
await page.click('[data-testid="policies"]');
|
||||
await page.click('[title="Data Consumer Policy"]');
|
||||
await page.click('[title="Data Steward Policy"]');
|
||||
|
||||
const policyResponse = page.waitForResponse(`/api/v1/roles`);
|
||||
|
||||
await page.click('[data-testid="submit-btn"]');
|
||||
await policyResponse;
|
||||
|
||||
await page.waitForURL(`**/settings/access/roles/${roleName}`);
|
||||
|
||||
await page.waitForSelector('[data-testid="inactive-link"]');
|
||||
|
||||
expect(await page.textContent('[data-testid="inactive-link"]')).toBe(
|
||||
roleName
|
||||
);
|
||||
expect(
|
||||
await page.textContent(
|
||||
'[data-testid="asset-description-container"] [data-testid="viewer-container"]'
|
||||
)
|
||||
).toContain(`description for ${roleName}`);
|
||||
});
|
||||
|
||||
test('Create new user and assign new role to him', async ({ page }) => {
|
||||
await settingClick(page, GlobalSettingOptions.USERS);
|
||||
|
||||
await page.click('[data-testid="add-user"]');
|
||||
|
||||
await page.fill('[data-testid="email"]', user.email);
|
||||
await page.fill('[data-testid="displayName"]', userDisplayName);
|
||||
await page.fill(descriptionBox, 'Adding user');
|
||||
await page.click('[data-testid="password-generator"]');
|
||||
|
||||
await page.click('[data-testid="roles-dropdown"]');
|
||||
await page.fill('#roles', roleName);
|
||||
await page.click(`[title="${roleName}"]`);
|
||||
|
||||
await clickOutside(page);
|
||||
const userResponse = page.waitForResponse(`/api/v1/users`);
|
||||
await page.click('[data-testid="save-user"]');
|
||||
|
||||
await userResponse;
|
||||
});
|
||||
|
||||
test('Verify assigned role to new user', async ({ page }) => {
|
||||
await settingClick(page, GlobalSettingOptions.USERS);
|
||||
|
||||
await page.waitForSelector('[data-testid="searchbar"]');
|
||||
await page.fill('[data-testid="searchbar"]', userDisplayName);
|
||||
await page.waitForSelector(`[data-testid="${userName}"]`);
|
||||
await page.click(`[data-testid="${userName}"]`);
|
||||
await page.waitForSelector('[data-testid="user-profile"]');
|
||||
await page.click(
|
||||
'[data-testid="user-profile"] .ant-collapse-expand-icon > .anticon'
|
||||
);
|
||||
|
||||
expect(
|
||||
await page.textContent(
|
||||
'[data-testid="user-profile"] [data-testid="user-profile-roles"]'
|
||||
)
|
||||
).toContain(roleName);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user