Skip to content

Commit 9e127f7

Browse files
committed
chore: tests for acl in object overview
1 parent f876431 commit 9e127f7

File tree

2 files changed

+73
-54
lines changed

2 files changed

+73
-54
lines changed

tests/suites/tenant/summary/ObjectSummary.ts

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -126,43 +126,34 @@ export class ObjectSummary {
126126
}
127127

128128
async waitForAclVisible() {
129-
await this.aclWrapper.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
129+
// In the new UI, the ACL tab shows a redirect message instead of the actual ACL content
130+
const redirectMessage = this.page.locator('text=Section was moved to Diagnostics');
131+
await redirectMessage.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
130132
return true;
131133
}
132134

133-
async getAccessRights(): Promise<{user: string; rights: string}[]> {
134-
await this.waitForAclVisible();
135-
const items = await this.aclList.locator('.gc-definition-list__item').all();
136-
const result = [];
137-
138-
for (const item of items) {
139-
const user =
140-
(await item.locator('.gc-definition-list__term-wrapper span').textContent()) || '';
141-
const definitionContent = await item.locator('.gc-definition-list__definition').first();
142-
const rights = (await definitionContent.textContent()) || '';
143-
result.push({user: user.trim(), rights: rights.trim()});
135+
async getRedirectMessage(): Promise<string | null> {
136+
const redirectMessage = this.page.locator('text=Section was moved to Diagnostics');
137+
if (await redirectMessage.isVisible()) {
138+
return redirectMessage.textContent();
144139
}
145-
146-
return result;
140+
return null;
147141
}
148142

149-
async getEffectiveAccessRights(): Promise<{group: string; permissions: string[]}[]> {
150-
await this.waitForAclVisible();
151-
const items = await this.effectiveAclList.locator('.gc-definition-list__item').all();
152-
const result = [];
153-
154-
for (const item of items) {
155-
const group =
156-
(await item.locator('.gc-definition-list__term-wrapper span').textContent()) || '';
157-
const definitionContent = await item.locator('.gc-definition-list__definition').first();
158-
const permissionElements = await definitionContent.locator('span').all();
159-
const permissions = await Promise.all(
160-
permissionElements.map(async (el) => ((await el.textContent()) || '').trim()),
161-
);
162-
result.push({group: group.trim(), permissions});
143+
async hasOpenInDiagnosticsButton(): Promise<boolean> {
144+
try {
145+
const diagnosticsButton = this.page.getByRole('button', {name: 'Open in Diagnostics'});
146+
await diagnosticsButton.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
147+
return true;
148+
} catch (error) {
149+
console.error('Open in Diagnostics button not visible:', error);
150+
return false;
163151
}
152+
}
164153

165-
return result;
154+
async clickOpenInDiagnosticsButton(): Promise<void> {
155+
const diagnosticsButton = this.page.getByRole('button', {name: 'Open in Diagnostics'});
156+
await diagnosticsButton.click();
166157
}
167158

168159
async isTreeVisible() {

tests/suites/tenant/summary/objectSummary.test.ts

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,31 +158,6 @@ test.describe('Object Summary', async () => {
158158
expect(vslotsColumns).not.toEqual(storagePoolsColumns);
159159
});
160160

161-
test('ACL tab shows correct access rights', async ({page}) => {
162-
const pageQueryParams = {
163-
schema: '/local/.sys_health',
164-
database: '/local',
165-
summaryTab: 'acl',
166-
tenantPage: 'query',
167-
};
168-
const tenantPage = new TenantPage(page);
169-
await tenantPage.goto(pageQueryParams);
170-
171-
const objectSummary = new ObjectSummary(page);
172-
await objectSummary.waitForAclVisible();
173-
174-
// Check Access Rights
175-
const accessRights = await objectSummary.getAccessRights();
176-
expect(accessRights).toEqual([{user: 'root@builtin', rights: 'Owner'}]);
177-
178-
// Check Effective Access Rights
179-
const effectiveRights = await objectSummary.getEffectiveAccessRights();
180-
expect(effectiveRights).toEqual([
181-
{group: 'Access', permissions: ['Manage']},
182-
{group: 'Inheritance type', permissions: ['Inherit']},
183-
]);
184-
});
185-
186161
test('Copy path copies correct path to clipboard', async ({page}) => {
187162
const pageQueryParams = {
188163
schema: dsVslotsSchema,
@@ -294,4 +269,57 @@ test.describe('Object Summary', async () => {
294269
await objectSummary.expandSummary();
295270
await expect(objectSummary.isSummaryCollapsed()).resolves.toBe(false);
296271
});
272+
273+
test('ACL tab shows redirect message and link to Diagnostics', async ({page}) => {
274+
// Define the URL parameters
275+
const pageQueryParams = {
276+
schema: '/local/.sys_health',
277+
database: '/local',
278+
summaryTab: 'acl',
279+
tenantPage: 'query',
280+
};
281+
282+
// Navigate to the page
283+
const tenantPage = new TenantPage(page);
284+
await tenantPage.goto(pageQueryParams);
285+
286+
// Get the ObjectSummary instance
287+
const objectSummary = new ObjectSummary(page);
288+
289+
// Verify the ACL tab is selected
290+
await objectSummary.clickTab(ObjectSummaryTab.ACL);
291+
292+
// Wait for the ACL content to be visible
293+
await objectSummary.waitForAclVisible();
294+
295+
// Check for the redirect message
296+
const redirectMessage = await objectSummary.getRedirectMessage();
297+
expect(redirectMessage).toContain('Section was moved to Diagnostics');
298+
299+
// Check for the "Open in Diagnostics" button
300+
const hasButton = await objectSummary.hasOpenInDiagnosticsButton();
301+
expect(hasButton).toBe(true);
302+
303+
// Click the button and verify the URL
304+
await objectSummary.clickOpenInDiagnosticsButton();
305+
306+
// Verify the URL contains the expected parameters
307+
const expectedUrlParams = new URLSearchParams({
308+
tenantPage: 'diagnostics',
309+
diagnosticsTab: 'access',
310+
summaryTab: 'acl',
311+
schema: '/local/.sys_health',
312+
database: '/local',
313+
});
314+
315+
// Get the current URL and parse its parameters
316+
const currentUrl = page.url();
317+
const currentUrlObj = new URL(currentUrl);
318+
const currentParams = currentUrlObj.searchParams;
319+
320+
// Verify each expected parameter is in the URL
321+
for (const [key, value] of expectedUrlParams.entries()) {
322+
expect(currentParams.get(key)).toBe(value);
323+
}
324+
});
297325
});

0 commit comments

Comments
 (0)