mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-01 02:56:10 +00:00
Playwright: Cleanup the user and role in playwright afterAll (#23899)
* Playwright: Cleanup the user and role in playwright afterAll * Fix: cleanup roles and policies
This commit is contained in:
parent
eac72a3db0
commit
f6720098c8
@ -138,7 +138,9 @@ test.afterAll(async ({ browser }) => {
|
||||
const { apiContext, afterAction } = await performAdminLogin(browser);
|
||||
await user.delete(apiContext);
|
||||
await role.delete(apiContext);
|
||||
await role2.delete(apiContext);
|
||||
await policy.delete(apiContext);
|
||||
await policy2.delete(apiContext);
|
||||
await table.delete(apiContext);
|
||||
await afterAction();
|
||||
});
|
||||
|
||||
@ -17,10 +17,11 @@ import { Domain } from '../../../support/domain/Domain';
|
||||
import { EntityDataClass } from '../../../support/entity/EntityDataClass';
|
||||
import { UserClass } from '../../../support/user/UserClass';
|
||||
import { performAdminLogin } from '../../../utils/admin';
|
||||
import { redirectToHomePage, uuid } from '../../../utils/common';
|
||||
import { getApiContext, redirectToHomePage, uuid } from '../../../utils/common';
|
||||
import { addCustomPropertiesForEntity } from '../../../utils/customProperty';
|
||||
import {
|
||||
assignRoleToUser,
|
||||
cleanupPermissions,
|
||||
initializePermissions,
|
||||
} from '../../../utils/permission';
|
||||
import {
|
||||
@ -93,6 +94,7 @@ test('Domain allow operations', async ({ testUserPage, browser }) => {
|
||||
// Setup allow permissions
|
||||
const page = await browser.newPage();
|
||||
await adminUser.login(page);
|
||||
const { apiContext } = await getApiContext(page);
|
||||
await initializePermissions(page, 'allow', [
|
||||
'EditDescription',
|
||||
'EditOwners',
|
||||
@ -156,6 +158,7 @@ test('Domain allow operations', async ({ testUserPage, browser }) => {
|
||||
await expect(element).toBeVisible();
|
||||
}
|
||||
}
|
||||
await cleanupPermissions(apiContext);
|
||||
});
|
||||
|
||||
test('Domain deny operations', async ({ testUserPage, browser }) => {
|
||||
@ -164,6 +167,7 @@ test('Domain deny operations', async ({ testUserPage, browser }) => {
|
||||
// Setup deny permissions
|
||||
const page = await browser.newPage();
|
||||
await adminUser.login(page);
|
||||
const { apiContext } = await getApiContext(page);
|
||||
await initializePermissions(page, 'deny', [
|
||||
'EditDescription',
|
||||
'EditOwners',
|
||||
@ -225,6 +229,7 @@ test('Domain deny operations', async ({ testUserPage, browser }) => {
|
||||
await expect(element).not.toBeVisible();
|
||||
}
|
||||
}
|
||||
await cleanupPermissions(apiContext);
|
||||
});
|
||||
|
||||
test.afterAll('Cleanup domain', async ({ browser }) => {
|
||||
|
||||
@ -17,9 +17,10 @@ import { EntityDataClass } from '../../../support/entity/EntityDataClass';
|
||||
import { Glossary } from '../../../support/glossary/Glossary';
|
||||
import { UserClass } from '../../../support/user/UserClass';
|
||||
import { performAdminLogin } from '../../../utils/admin';
|
||||
import { redirectToHomePage } from '../../../utils/common';
|
||||
import { getApiContext, redirectToHomePage } from '../../../utils/common';
|
||||
import {
|
||||
assignRoleToUser,
|
||||
cleanupPermissions,
|
||||
initializePermissions,
|
||||
} from '../../../utils/permission';
|
||||
import { sidebarClick } from '../../../utils/sidebar';
|
||||
@ -73,6 +74,7 @@ test('Glossary allow operations', async ({ testUserPage, browser }) => {
|
||||
|
||||
const page = await browser.newPage();
|
||||
await adminUser.login(page);
|
||||
const { apiContext } = await getApiContext(page);
|
||||
await initializePermissions(page, 'allow', [
|
||||
'EditDescription',
|
||||
'EditOwners',
|
||||
@ -127,6 +129,7 @@ test('Glossary allow operations', async ({ testUserPage, browser }) => {
|
||||
await expect(element).toBeVisible();
|
||||
}
|
||||
}
|
||||
await cleanupPermissions(apiContext);
|
||||
});
|
||||
|
||||
test('Glossary deny operations', async ({ testUserPage, browser }) => {
|
||||
@ -134,6 +137,7 @@ test('Glossary deny operations', async ({ testUserPage, browser }) => {
|
||||
|
||||
// Setup deny permissions
|
||||
const page = await browser.newPage();
|
||||
const { apiContext } = await getApiContext(page);
|
||||
await adminUser.login(page);
|
||||
await initializePermissions(page, 'deny', [
|
||||
'EditDescription',
|
||||
@ -191,6 +195,7 @@ test('Glossary deny operations', async ({ testUserPage, browser }) => {
|
||||
await expect(element).not.toBeVisible();
|
||||
}
|
||||
}
|
||||
await cleanupPermissions(apiContext);
|
||||
});
|
||||
|
||||
test.afterAll('Cleanup glossary', async ({ browser }) => {
|
||||
|
||||
@ -819,6 +819,8 @@ test.describe('Teams Page with Data Consumer User', () => {
|
||||
await dataConsumerUser.delete(apiContext);
|
||||
await user.delete(apiContext);
|
||||
await team.delete(apiContext);
|
||||
await policy.delete(apiContext);
|
||||
await role.delete(apiContext);
|
||||
await team2.delete(apiContext);
|
||||
await afterAction();
|
||||
});
|
||||
@ -990,6 +992,13 @@ test.describe('Teams Page action as Owner of Team', () => {
|
||||
await afterAction();
|
||||
});
|
||||
|
||||
test.afterAll('Cleanup', async ({ browser }) => {
|
||||
const { apiContext, afterAction } = await performAdminLogin(browser);
|
||||
await policy.delete(apiContext);
|
||||
await role.delete(apiContext);
|
||||
await afterAction();
|
||||
});
|
||||
|
||||
test.beforeEach('Visit Home Page', async ({ ownerUserPage }) => {
|
||||
await redirectToHomePage(ownerUserPage);
|
||||
});
|
||||
|
||||
@ -124,6 +124,14 @@ test.beforeAll('Setup pre-requests', async ({ browser }) => {
|
||||
await afterAction();
|
||||
});
|
||||
|
||||
test.afterAll('Cleanup', async ({ browser }) => {
|
||||
const { apiContext, afterAction } = await performAdminLogin(browser);
|
||||
await dataStewardUser.delete(apiContext);
|
||||
await policy.delete(apiContext);
|
||||
await role.delete(apiContext);
|
||||
await afterAction();
|
||||
});
|
||||
|
||||
test.describe('User with Admin Roles', () => {
|
||||
test.slow(true);
|
||||
|
||||
|
||||
@ -570,7 +570,7 @@ export const addCustomPropertiesForEntity = async ({
|
||||
}: {
|
||||
page: Page;
|
||||
propertyName: string;
|
||||
customPropertyData: { description: string; entityApiType: string };
|
||||
customPropertyData: { description: string; entityApiType?: string };
|
||||
customType: string;
|
||||
enumConfig?: { values: string[]; multiSelect: boolean };
|
||||
formatConfig?: string;
|
||||
|
||||
@ -241,10 +241,10 @@ export const updateDefaultOrganizationPolicy = async (
|
||||
};
|
||||
|
||||
export const cleanupPermissions = async (apiContext: APIRequestContext) => {
|
||||
if (role && role.responseData?.id) {
|
||||
if (role?.responseData?.id) {
|
||||
await role.delete(apiContext);
|
||||
}
|
||||
if (policy && policy.responseData?.id) {
|
||||
if (policy?.responseData?.id) {
|
||||
await policy.delete(apiContext);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user