Skip to content

Commit f672009

Browse files
authored
Playwright: Cleanup the user and role in playwright afterAll (open-metadata#23899)
* Playwright: Cleanup the user and role in playwright afterAll * Fix: cleanup roles and policies
1 parent eac72a3 commit f672009

File tree

7 files changed

+34
-5
lines changed

7 files changed

+34
-5
lines changed

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Permission.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ test.afterAll(async ({ browser }) => {
138138
const { apiContext, afterAction } = await performAdminLogin(browser);
139139
await user.delete(apiContext);
140140
await role.delete(apiContext);
141+
await role2.delete(apiContext);
141142
await policy.delete(apiContext);
143+
await policy2.delete(apiContext);
142144
await table.delete(apiContext);
143145
await afterAction();
144146
});

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Permissions/DomainPermissions.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ import { Domain } from '../../../support/domain/Domain';
1717
import { EntityDataClass } from '../../../support/entity/EntityDataClass';
1818
import { UserClass } from '../../../support/user/UserClass';
1919
import { performAdminLogin } from '../../../utils/admin';
20-
import { redirectToHomePage, uuid } from '../../../utils/common';
20+
import { getApiContext, redirectToHomePage, uuid } from '../../../utils/common';
2121
import { addCustomPropertiesForEntity } from '../../../utils/customProperty';
2222
import {
2323
assignRoleToUser,
24+
cleanupPermissions,
2425
initializePermissions,
2526
} from '../../../utils/permission';
2627
import {
@@ -93,6 +94,7 @@ test('Domain allow operations', async ({ testUserPage, browser }) => {
9394
// Setup allow permissions
9495
const page = await browser.newPage();
9596
await adminUser.login(page);
97+
const { apiContext } = await getApiContext(page);
9698
await initializePermissions(page, 'allow', [
9799
'EditDescription',
98100
'EditOwners',
@@ -156,6 +158,7 @@ test('Domain allow operations', async ({ testUserPage, browser }) => {
156158
await expect(element).toBeVisible();
157159
}
158160
}
161+
await cleanupPermissions(apiContext);
159162
});
160163

161164
test('Domain deny operations', async ({ testUserPage, browser }) => {
@@ -164,6 +167,7 @@ test('Domain deny operations', async ({ testUserPage, browser }) => {
164167
// Setup deny permissions
165168
const page = await browser.newPage();
166169
await adminUser.login(page);
170+
const { apiContext } = await getApiContext(page);
167171
await initializePermissions(page, 'deny', [
168172
'EditDescription',
169173
'EditOwners',
@@ -225,6 +229,7 @@ test('Domain deny operations', async ({ testUserPage, browser }) => {
225229
await expect(element).not.toBeVisible();
226230
}
227231
}
232+
await cleanupPermissions(apiContext);
228233
});
229234

230235
test.afterAll('Cleanup domain', async ({ browser }) => {

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Permissions/GlossaryPermissions.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import { EntityDataClass } from '../../../support/entity/EntityDataClass';
1717
import { Glossary } from '../../../support/glossary/Glossary';
1818
import { UserClass } from '../../../support/user/UserClass';
1919
import { performAdminLogin } from '../../../utils/admin';
20-
import { redirectToHomePage } from '../../../utils/common';
20+
import { getApiContext, redirectToHomePage } from '../../../utils/common';
2121
import {
2222
assignRoleToUser,
23+
cleanupPermissions,
2324
initializePermissions,
2425
} from '../../../utils/permission';
2526
import { sidebarClick } from '../../../utils/sidebar';
@@ -73,6 +74,7 @@ test('Glossary allow operations', async ({ testUserPage, browser }) => {
7374

7475
const page = await browser.newPage();
7576
await adminUser.login(page);
77+
const { apiContext } = await getApiContext(page);
7678
await initializePermissions(page, 'allow', [
7779
'EditDescription',
7880
'EditOwners',
@@ -127,13 +129,15 @@ test('Glossary allow operations', async ({ testUserPage, browser }) => {
127129
await expect(element).toBeVisible();
128130
}
129131
}
132+
await cleanupPermissions(apiContext);
130133
});
131134

132135
test('Glossary deny operations', async ({ testUserPage, browser }) => {
133136
test.slow(true);
134137

135138
// Setup deny permissions
136139
const page = await browser.newPage();
140+
const { apiContext } = await getApiContext(page);
137141
await adminUser.login(page);
138142
await initializePermissions(page, 'deny', [
139143
'EditDescription',
@@ -191,6 +195,7 @@ test('Glossary deny operations', async ({ testUserPage, browser }) => {
191195
await expect(element).not.toBeVisible();
192196
}
193197
}
198+
await cleanupPermissions(apiContext);
194199
});
195200

196201
test.afterAll('Cleanup glossary', async ({ browser }) => {

openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Teams.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,8 @@ test.describe('Teams Page with Data Consumer User', () => {
819819
await dataConsumerUser.delete(apiContext);
820820
await user.delete(apiContext);
821821
await team.delete(apiContext);
822+
await policy.delete(apiContext);
823+
await role.delete(apiContext);
822824
await team2.delete(apiContext);
823825
await afterAction();
824826
});
@@ -990,6 +992,13 @@ test.describe('Teams Page action as Owner of Team', () => {
990992
await afterAction();
991993
});
992994

995+
test.afterAll('Cleanup', async ({ browser }) => {
996+
const { apiContext, afterAction } = await performAdminLogin(browser);
997+
await policy.delete(apiContext);
998+
await role.delete(apiContext);
999+
await afterAction();
1000+
});
1001+
9931002
test.beforeEach('Visit Home Page', async ({ ownerUserPage }) => {
9941003
await redirectToHomePage(ownerUserPage);
9951004
});

openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Users.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ test.beforeAll('Setup pre-requests', async ({ browser }) => {
124124
await afterAction();
125125
});
126126

127+
test.afterAll('Cleanup', async ({ browser }) => {
128+
const { apiContext, afterAction } = await performAdminLogin(browser);
129+
await dataStewardUser.delete(apiContext);
130+
await policy.delete(apiContext);
131+
await role.delete(apiContext);
132+
await afterAction();
133+
});
134+
127135
test.describe('User with Admin Roles', () => {
128136
test.slow(true);
129137

openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ export const addCustomPropertiesForEntity = async ({
570570
}: {
571571
page: Page;
572572
propertyName: string;
573-
customPropertyData: { description: string; entityApiType: string };
573+
customPropertyData: { description: string; entityApiType?: string };
574574
customType: string;
575575
enumConfig?: { values: string[]; multiSelect: boolean };
576576
formatConfig?: string;

openmetadata-ui/src/main/resources/ui/playwright/utils/permission.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ export const updateDefaultOrganizationPolicy = async (
241241
};
242242

243243
export const cleanupPermissions = async (apiContext: APIRequestContext) => {
244-
if (role && role.responseData?.id) {
244+
if (role?.responseData?.id) {
245245
await role.delete(apiContext);
246246
}
247-
if (policy && policy.responseData?.id) {
247+
if (policy?.responseData?.id) {
248248
await policy.delete(apiContext);
249249
}
250250
};

0 commit comments

Comments
 (0)