Skip to content

Commit 56dd723

Browse files
siddhant1Siddhant
andauthored
fix(test): unflake GlossaryPermissions team-based test (#27422)
* fix(test): assign role to team in P-11 team-based permissions test The "Team-based permissions work correctly" test created a team and added testUser to it, but never attached the new role to the team — so the user inherited no permissions from team membership. The test relied on default Organization conditional rules, which the frontend treats as no-permission (only Access.Allow becomes truthy in PermissionsUtils). The glossary page then rendered the no-permission placeholder and never fired /api/v1/glossaries?fields=*, hanging visitGlossaryPage's waitForResponse for the full 30s toPass budget. Patch the team's defaultRoles after initializePermissions so the user actually inherits Allow via team membership, matching the test's intent. Local repro (full file × 10 repeats × 4 workers, retries=0): - Before: 10/10 P-11 failures - After: 10/10 P-11 pass, 93/93 overall pass * fix(test): isolate P-11 to a dedicated user/team Avoid mutating the file-shared testUser. Previously the fix added testUser to a temporary team and attached an Allow role; if cleanup failed, the elevated permissions would leak into subsequent tests sharing the same worker. Now P-11 creates its own UserClass + page, runs the team-permission verification in isolation, and tears down the user, team, role, and policy at the end. Other tests in the file see no state change from this test beyond what initializePermissions/cleanupPermissions already do. Local verification (full file × 10 repeats × 4 workers, retries=0): 93/93 pass, P-11 10/10. --------- Co-authored-by: Siddhant <siddhant@MacBook-Pro-621.local>
1 parent 5895359 commit 56dd723

1 file changed

Lines changed: 41 additions & 24 deletions

File tree

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

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,14 @@ test.describe('Glossary Permissions', () => {
354354
});
355355

356356
// P-11: Team-based permissions work correctly
357-
test('Team-based permissions work correctly', async ({
358-
testUserPage,
359-
page,
360-
}) => {
357+
test('Team-based permissions work correctly', async ({ browser, page }) => {
361358
test.slow(true);
362359

363360
const { apiContext } = await getApiContext(page);
364361

365-
// Create a team and add testUser to it
362+
const teamUser = new UserClass();
363+
await teamUser.create(apiContext);
364+
366365
const teamName = `TestTeam${Date.now()}`;
367366
const teamResponse = await apiContext.post('/api/v1/teams', {
368367
data: {
@@ -375,14 +374,13 @@ test.describe('Glossary Permissions', () => {
375374
const teamData = await teamResponse.json();
376375
const teamId = teamData.id;
377376

378-
// Add user to team
379-
await apiContext.patch(`/api/v1/teams/${teamData.id}`, {
377+
await apiContext.patch(`/api/v1/teams/${teamId}`, {
380378
data: [
381379
{
382380
op: 'add',
383381
path: '/users/0',
384382
value: {
385-
id: testUser.responseData.id,
383+
id: teamUser.responseData.id,
386384
type: 'user',
387385
},
388386
},
@@ -392,30 +390,49 @@ test.describe('Glossary Permissions', () => {
392390
},
393391
});
394392

395-
// Set up permissions with team as the principal
396-
await initializePermissions(page, 'allow', [
393+
const { role: teamRole } = await initializePermissions(page, 'allow', [
397394
'EditDescription',
398395
'EditOwners',
399396
]);
400397

401-
// Login as test user and verify permissions inherited from team
402-
await expect(async () => {
403-
await glossary.visitEntityPage(testUserPage);
404-
await waitForAllLoadersToDisappear(testUserPage);
398+
await apiContext.patch(`/api/v1/teams/${teamId}`, {
399+
data: [
400+
{
401+
op: 'add',
402+
path: '/defaultRoles/0',
403+
value: {
404+
id: teamRole.responseData.id,
405+
type: 'role',
406+
name: teamRole.responseData.name,
407+
},
408+
},
409+
],
410+
headers: {
411+
'Content-Type': 'application/json-patch+json',
412+
},
413+
});
405414

406-
const glossaryHeader = testUserPage.getByTestId(
407-
'entity-header-display-name'
408-
);
415+
const teamUserPage = await browser.newPage();
416+
try {
417+
await teamUser.login(teamUserPage);
409418

410-
await expect(glossaryHeader).toBeVisible({ timeout: 5_000 });
411-
await expect(glossaryHeader).toContainText(glossary.data.displayName);
412-
}).toPass({ timeout: 30_000, intervals: [2_000, 5_000] });
419+
await expect(async () => {
420+
await glossary.visitEntityPage(teamUserPage);
421+
await waitForAllLoadersToDisappear(teamUserPage);
413422

414-
// Clean up
415-
await cleanupPermissions(apiContext);
423+
const glossaryHeader = teamUserPage.getByTestId(
424+
'entity-header-display-name'
425+
);
416426

417-
if (teamId) {
418-
await apiContext.delete(`/api/v1/teams/${teamId}?hardDelete=true`);
427+
await expect(glossaryHeader).toBeVisible({ timeout: 5_000 });
428+
await expect(glossaryHeader).toContainText(glossary.data.displayName);
429+
}).toPass({ timeout: 30_000, intervals: [2_000, 5_000] });
430+
} finally {
431+
await teamUserPage.close();
419432
}
433+
434+
await cleanupPermissions(apiContext);
435+
await apiContext.delete(`/api/v1/teams/${teamId}?hardDelete=true`);
436+
await teamUser.delete(apiContext);
420437
});
421438
});

0 commit comments

Comments
 (0)