mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-03 12:08:31 +00:00
Add test for Roles and Persona (#19777)
* update conditions in user profile page * updated as per comments * revert UI changes * update to use clickOutside
This commit is contained in:
parent
c6fe281de0
commit
96b36e4a76
@ -19,6 +19,7 @@ import { UserClass } from '../../support/user/UserClass';
|
||||
import { performAdminLogin } from '../../utils/admin';
|
||||
import { descriptionBox, redirectToHomePage } from '../../utils/common';
|
||||
import { settingClick } from '../../utils/sidebar';
|
||||
import { redirectToUserPage } from '../../utils/userDetails';
|
||||
|
||||
const user1 = new UserClass();
|
||||
const user2 = new UserClass();
|
||||
@ -65,26 +66,7 @@ test.describe('User with different Roles', () => {
|
||||
test('Non admin user should be able to edit display name and description on own profile', async ({
|
||||
userPage,
|
||||
}) => {
|
||||
await redirectToHomePage(userPage);
|
||||
|
||||
await userPage.getByTestId('dropdown-profile').click();
|
||||
|
||||
// Hover on the profile avatar to close the name tooltip
|
||||
await userPage.getByTestId('profile-avatar').hover();
|
||||
|
||||
await userPage.waitForSelector('.profile-dropdown', { state: 'visible' });
|
||||
|
||||
const getUserDetails = userPage.waitForResponse(`/api/v1/users/name/*`);
|
||||
|
||||
await userPage
|
||||
.locator('.profile-dropdown')
|
||||
.getByTestId('user-name')
|
||||
.click();
|
||||
|
||||
await getUserDetails;
|
||||
|
||||
// Close the profile dropdown
|
||||
await userPage.getByTestId('dropdown-profile').click();
|
||||
await redirectToUserPage(userPage);
|
||||
|
||||
// Check if the display name is present
|
||||
await expect(
|
||||
@ -188,6 +170,32 @@ test.describe('User with different Roles', () => {
|
||||
).toContainText('No description');
|
||||
});
|
||||
|
||||
test('Non admin user should not be able to edit the persona or roles', async ({
|
||||
userPage,
|
||||
}) => {
|
||||
await redirectToUserPage(userPage);
|
||||
|
||||
// Check if the display name is present
|
||||
await expect(
|
||||
userPage.getByTestId('user-profile-details').getByTestId('user-name')
|
||||
).toHaveText(user1.responseData.displayName);
|
||||
|
||||
await userPage
|
||||
.locator('.user-profile-container [data-icon="right"]')
|
||||
.click();
|
||||
|
||||
// Check for Roles field visibility
|
||||
await expect(userPage.getByTestId('user-profile-roles')).toBeVisible();
|
||||
|
||||
// Edit Persona icon shouldn't be visible
|
||||
await expect(
|
||||
userPage.getByTestId('persona-list').getByTestId('edit-persona')
|
||||
).not.toBeVisible();
|
||||
|
||||
// Edit Roles icon shouldn't be visible
|
||||
await expect(userPage.getByTestId('edit-roles-button')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('Non logged in user should not be able to edit display name and description on other users', async ({
|
||||
userPage,
|
||||
adminPage,
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2025 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 { Page } from '@playwright/test';
|
||||
import { clickOutside, redirectToHomePage } from './common';
|
||||
|
||||
export const redirectToUserPage = async (page: Page) => {
|
||||
await redirectToHomePage(page);
|
||||
|
||||
await page.getByTestId('dropdown-profile').click();
|
||||
|
||||
// Hover on the profile avatar to close the name tooltip
|
||||
await page.getByTestId('profile-avatar').hover();
|
||||
|
||||
await page.waitForSelector('.profile-dropdown', { state: 'visible' });
|
||||
|
||||
const getUserDetails = page.waitForResponse(`/api/v1/users/name/*`);
|
||||
|
||||
await page.locator('.profile-dropdown').getByTestId('user-name').click();
|
||||
|
||||
await getUserDetails;
|
||||
|
||||
// Close the profile dropdown
|
||||
await clickOutside(page);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user