2025-09-15 21:42:59 +05:30
|
|
|
/*
|
|
|
|
* 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
|
2024-05-31 11:01:10 +05:30
|
|
|
* 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.
|
|
|
|
*/
|
2025-04-28 13:43:24 +05:30
|
|
|
import test, { APIRequestContext, expect, Page } from '@playwright/test';
|
2024-08-02 10:16:14 +05:30
|
|
|
import { get, isEmpty, isUndefined } from 'lodash';
|
2025-01-08 01:38:08 -08:00
|
|
|
import { SidebarItem } from '../constant/sidebar';
|
2025-04-28 13:43:24 +05:30
|
|
|
import { PolicyClass } from '../support/access-control/PoliciesClass';
|
|
|
|
import { RolesClass } from '../support/access-control/RolesClass';
|
2024-08-02 10:16:14 +05:30
|
|
|
import { DataProduct } from '../support/domain/DataProduct';
|
2024-05-31 11:01:10 +05:30
|
|
|
import { Domain } from '../support/domain/Domain';
|
2024-08-10 18:00:42 +05:30
|
|
|
import { SubDomain } from '../support/domain/SubDomain';
|
2024-08-02 10:16:14 +05:30
|
|
|
import { DashboardClass } from '../support/entity/DashboardClass';
|
|
|
|
import { EntityTypeEndpoint } from '../support/entity/Entity.interface';
|
|
|
|
import { EntityClass } from '../support/entity/EntityClass';
|
|
|
|
import { TableClass } from '../support/entity/TableClass';
|
|
|
|
import { TopicClass } from '../support/entity/TopicClass';
|
2025-04-28 13:43:24 +05:30
|
|
|
import { TeamClass } from '../support/team/TeamClass';
|
|
|
|
import { UserClass } from '../support/user/UserClass';
|
2024-08-02 10:16:14 +05:30
|
|
|
import {
|
2024-12-05 17:53:14 +05:30
|
|
|
closeFirstPopupAlert,
|
2024-08-02 10:16:14 +05:30
|
|
|
descriptionBox,
|
|
|
|
getApiContext,
|
|
|
|
INVALID_NAMES,
|
|
|
|
NAME_MAX_LENGTH_VALIDATION_ERROR,
|
|
|
|
NAME_VALIDATION_ERROR,
|
2025-01-08 01:38:08 -08:00
|
|
|
redirectToHomePage,
|
2025-09-26 20:31:39 +05:30
|
|
|
toastNotification,
|
2025-04-28 13:43:24 +05:30
|
|
|
uuid,
|
2024-08-02 10:16:14 +05:30
|
|
|
} from './common';
|
2025-08-31 12:46:39 +05:30
|
|
|
import { addOwner, waitForAllLoadersToDisappear } from './entity';
|
2025-01-08 01:38:08 -08:00
|
|
|
import { sidebarClick } from './sidebar';
|
2024-05-31 11:01:10 +05:30
|
|
|
|
|
|
|
export const assignDomain = async (page: Page, domain: Domain['data']) => {
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.getByTestId('add-entity-button').click();
|
2024-06-11 16:57:09 +05:30
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
2024-08-13 18:43:03 +05:30
|
|
|
const searchDomain = page.waitForResponse(
|
|
|
|
`/api/v1/search/query?q=*${encodeURIComponent(domain.name)}*`
|
|
|
|
);
|
2024-05-31 11:01:10 +05:30
|
|
|
await page
|
|
|
|
.getByTestId('selectable-list')
|
|
|
|
.getByTestId('searchbar')
|
|
|
|
.fill(domain.name);
|
2024-08-13 18:43:03 +05:30
|
|
|
await searchDomain;
|
2024-05-31 11:01:10 +05:30
|
|
|
await page.getByRole('listitem', { name: domain.displayName }).click();
|
|
|
|
|
2025-07-22 13:04:50 +05:30
|
|
|
const patchReq = page.waitForResponse(
|
|
|
|
(req) => req.request().method() === 'PATCH'
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.getByTestId('saveAssociatedTag').click();
|
|
|
|
await patchReq;
|
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
|
|
|
|
2024-05-31 11:01:10 +05:30
|
|
|
await expect(page.getByTestId('domain-link')).toContainText(
|
|
|
|
domain.displayName
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const updateDomain = async (page: Page, domain: Domain['data']) => {
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.getByTestId('add-entity-button').click();
|
2024-06-11 16:57:09 +05:30
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
2024-05-31 11:01:10 +05:30
|
|
|
await page.getByTestId('selectable-list').getByTestId('searchbar').clear();
|
2024-08-13 18:43:03 +05:30
|
|
|
const searchDomain = page.waitForResponse(
|
|
|
|
`/api/v1/search/query?q=*${encodeURIComponent(domain.name)}*`
|
|
|
|
);
|
2024-05-31 11:01:10 +05:30
|
|
|
await page
|
|
|
|
.getByTestId('selectable-list')
|
|
|
|
.getByTestId('searchbar')
|
|
|
|
.fill(domain.name);
|
2024-08-13 18:43:03 +05:30
|
|
|
await searchDomain;
|
2024-05-31 11:01:10 +05:30
|
|
|
await page.getByRole('listitem', { name: domain.displayName }).click();
|
|
|
|
|
|
|
|
await expect(page.getByTestId('domain-link')).toContainText(
|
|
|
|
domain.displayName
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const removeDomain = async (page: Page) => {
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.getByTestId('add-entity-button').click();
|
2024-06-11 16:57:09 +05:30
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
2024-05-31 11:01:10 +05:30
|
|
|
|
|
|
|
await expect(page.getByTestId('remove-owner').locator('path')).toBeVisible();
|
|
|
|
|
|
|
|
await page.getByTestId('remove-owner').locator('svg').click();
|
|
|
|
|
|
|
|
await expect(page.getByTestId('no-domain-text')).toContainText('No Domain');
|
|
|
|
};
|
2024-08-02 10:16:14 +05:30
|
|
|
|
2024-09-25 00:51:01 +05:30
|
|
|
export const validateDomainForm = async (page: Page) => {
|
2024-08-02 10:16:14 +05:30
|
|
|
// Error messages
|
|
|
|
await expect(page.locator('#name_help')).toHaveText('Name is required');
|
|
|
|
await expect(page.locator('#description_help')).toHaveText(
|
|
|
|
'Description is required'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Max length validation
|
|
|
|
await page.locator('[data-testid="name"]').type(INVALID_NAMES.MAX_LENGTH);
|
|
|
|
|
|
|
|
await expect(page.locator('#name_help')).toHaveText(
|
|
|
|
NAME_MAX_LENGTH_VALIDATION_ERROR
|
|
|
|
);
|
|
|
|
|
|
|
|
// With special char validation
|
|
|
|
await page.locator('[data-testid="name"]').clear();
|
|
|
|
await page
|
|
|
|
.locator('[data-testid="name"]')
|
|
|
|
.type(INVALID_NAMES.WITH_SPECIAL_CHARS);
|
|
|
|
|
|
|
|
await expect(page.locator('#name_help')).toHaveText(NAME_VALIDATION_ERROR);
|
|
|
|
};
|
|
|
|
|
2025-09-26 20:31:39 +05:30
|
|
|
export const selectDomain = async (page: Page, domain: Domain['data']) => {
|
|
|
|
const searchBox = page
|
|
|
|
.getByTestId('page-layout-v1')
|
|
|
|
.getByRole('textbox', { name: 'Search' });
|
|
|
|
|
|
|
|
const domainRes = page.waitForResponse(
|
|
|
|
'/api/v1/search/query?q=*&index=domain_search_index*'
|
|
|
|
);
|
|
|
|
|
|
|
|
await searchBox.fill(domain.name);
|
|
|
|
|
|
|
|
await domainRes;
|
|
|
|
|
|
|
|
await page.waitForSelector('[data-testid="loader"]', {
|
|
|
|
state: 'detached',
|
2025-09-13 13:44:24 +05:30
|
|
|
});
|
|
|
|
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.getByRole('row', { name: domain.displayName }).click();
|
2025-09-13 13:44:24 +05:30
|
|
|
|
2025-06-26 19:08:53 +05:30
|
|
|
await page.waitForLoadState('networkidle');
|
2025-09-13 13:44:24 +05:30
|
|
|
|
|
|
|
await page.waitForSelector('[data-testid="loader"]', {
|
|
|
|
state: 'detached',
|
|
|
|
});
|
2024-08-02 10:16:14 +05:30
|
|
|
};
|
|
|
|
|
2024-08-10 18:00:42 +05:30
|
|
|
export const selectSubDomain = async (
|
|
|
|
page: Page,
|
|
|
|
domain: Domain['data'],
|
|
|
|
subDomain: SubDomain['data']
|
|
|
|
) => {
|
2025-01-08 01:38:08 -08:00
|
|
|
const menuItem = page.getByRole('menuitem', { name: domain.displayName });
|
|
|
|
const isSelected = await menuItem.evaluate((element) => {
|
|
|
|
return element.classList.contains('ant-menu-item-selected');
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!isSelected) {
|
2025-08-06 13:18:58 +05:30
|
|
|
const subDomainRes = page.waitForResponse(
|
2025-08-11 16:33:48 +05:30
|
|
|
'/api/v1/search/query?q=*&from=0&size=0&index=domain_search_index&deleted=false&track_total_hits=true'
|
2025-08-06 13:18:58 +05:30
|
|
|
);
|
2025-01-08 01:38:08 -08:00
|
|
|
await menuItem.click();
|
2025-08-06 13:18:58 +05:30
|
|
|
await subDomainRes;
|
2025-07-03 18:50:46 +05:30
|
|
|
await page.waitForLoadState('networkidle');
|
2025-01-08 01:38:08 -08:00
|
|
|
}
|
2024-08-10 18:00:42 +05:30
|
|
|
|
2025-08-11 16:33:48 +05:30
|
|
|
const subDomainRes = page.waitForResponse(
|
|
|
|
'/api/v1/search/query?q=*&from=0&size=50&index=domain_search_index&deleted=false&track_total_hits=true'
|
|
|
|
);
|
2024-08-10 18:00:42 +05:30
|
|
|
await page.getByTestId('subdomains').getByText('Sub Domains').click();
|
2025-08-11 16:33:48 +05:30
|
|
|
await subDomainRes;
|
|
|
|
|
|
|
|
await page.waitForSelector('[data-testid="loader"]', {
|
|
|
|
state: 'detached',
|
|
|
|
});
|
|
|
|
|
2024-08-10 18:00:42 +05:30
|
|
|
await page.getByTestId(subDomain.name).click();
|
2025-06-25 18:19:33 +05:30
|
|
|
await page.waitForLoadState('networkidle');
|
2025-01-08 01:38:08 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const selectDataProductFromTab = async (
|
|
|
|
page: Page,
|
|
|
|
dataProduct: DataProduct['data']
|
|
|
|
) => {
|
|
|
|
const dpRes = page.waitForResponse(
|
2025-06-17 00:32:19 +05:30
|
|
|
'/api/v1/search/query?*&from=0&size=50&index=data_product_search_index*'
|
2025-01-08 01:38:08 -08:00
|
|
|
);
|
2025-04-28 13:43:24 +05:30
|
|
|
await page
|
|
|
|
.locator('.domain-details-page-tabs')
|
|
|
|
.getByText('Data Products')
|
|
|
|
.click();
|
2025-01-08 01:38:08 -08:00
|
|
|
|
|
|
|
await dpRes;
|
|
|
|
|
2025-08-22 15:58:21 +05:30
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
|
|
|
|
2025-01-08 01:38:08 -08:00
|
|
|
const dpDataRes = page.waitForResponse('/api/v1/dataProducts/name/*');
|
|
|
|
|
|
|
|
await page
|
|
|
|
.getByTestId(`explore-card-${dataProduct.name}`)
|
|
|
|
.getByTestId('entity-link')
|
|
|
|
.click();
|
|
|
|
await dpDataRes;
|
2024-08-10 18:00:42 +05:30
|
|
|
};
|
|
|
|
|
2024-08-02 10:16:14 +05:30
|
|
|
export const selectDataProduct = async (
|
|
|
|
page: Page,
|
|
|
|
domain: Domain['data'],
|
|
|
|
dataProduct: DataProduct['data']
|
|
|
|
) => {
|
|
|
|
await page
|
|
|
|
.getByRole('menuitem', { name: domain.displayName })
|
|
|
|
.locator('span')
|
|
|
|
.click();
|
|
|
|
|
2025-01-08 01:38:08 -08:00
|
|
|
await selectDataProductFromTab(page, dataProduct);
|
2024-08-02 10:16:14 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
const goToAssetsTab = async (page: Page, domain: Domain['data']) => {
|
|
|
|
await selectDomain(page, domain);
|
|
|
|
await checkDomainDisplayName(page, domain.displayName);
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.getByRole('tab', { name: /Assets/ }).click();
|
2025-08-31 12:46:39 +05:30
|
|
|
await waitForAllLoadersToDisappear(page);
|
2024-08-02 10:16:14 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
const fillCommonFormItems = async (
|
|
|
|
page: Page,
|
2024-08-10 18:00:42 +05:30
|
|
|
entity: Domain['data'] | DataProduct['data'] | SubDomain['data']
|
2024-08-02 10:16:14 +05:30
|
|
|
) => {
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.locator('#root\\/name').fill(entity.name);
|
|
|
|
await page.locator('#root\\/displayName').fill(entity.displayName);
|
2024-12-27 20:57:37 +05:30
|
|
|
await page.locator(descriptionBox).fill(entity.description);
|
2024-08-02 10:16:14 +05:30
|
|
|
if (!isEmpty(entity.owners) && !isUndefined(entity.owners)) {
|
2024-08-13 18:43:03 +05:30
|
|
|
await addOwner({
|
2024-08-02 10:16:14 +05:30
|
|
|
page,
|
2024-08-13 18:43:03 +05:30
|
|
|
owner: entity.owners[0].name,
|
|
|
|
type: entity.owners[0].type as 'Users' | 'Teams',
|
|
|
|
endpoint: EntityTypeEndpoint.Domain,
|
|
|
|
dataTestId: 'owner-container',
|
|
|
|
initiatorId: 'add-owner',
|
|
|
|
});
|
2024-08-02 10:16:14 +05:30
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2025-07-07 19:26:27 +05:30
|
|
|
export const fillDomainForm = async (
|
2024-08-10 18:00:42 +05:30
|
|
|
page: Page,
|
|
|
|
entity: Domain['data'] | SubDomain['data'],
|
|
|
|
isDomain = true
|
|
|
|
) => {
|
2024-08-02 10:16:14 +05:30
|
|
|
await fillCommonFormItems(page, entity);
|
2025-09-26 20:31:39 +05:30
|
|
|
|
|
|
|
const domainTypeCombo = page.getByRole('combobox', { name: 'Domain Type' });
|
|
|
|
await domainTypeCombo.click();
|
|
|
|
|
|
|
|
await page.getByRole('option', { name: entity.domainType }).click();
|
2024-08-02 10:16:14 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
export const checkDomainDisplayName = async (
|
|
|
|
page: Page,
|
|
|
|
displayName: string
|
|
|
|
) => {
|
|
|
|
await expect(page.getByTestId('entity-header-display-name')).toHaveText(
|
|
|
|
displayName
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const checkAssetsCount = async (page: Page, count: number) => {
|
|
|
|
await expect(page.getByTestId('assets').getByTestId('count')).toContainText(
|
|
|
|
count.toString()
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const checkDataProductCount = async (page: Page, count: number) => {
|
|
|
|
await expect(
|
|
|
|
page.getByTestId('data_products').getByTestId('count')
|
|
|
|
).toContainText(count.toString());
|
|
|
|
};
|
|
|
|
|
2024-08-10 18:00:42 +05:30
|
|
|
export const verifyDomain = async (
|
|
|
|
page: Page,
|
|
|
|
domain: Domain['data'] | SubDomain['data'],
|
|
|
|
parentDomain?: Domain['data'],
|
|
|
|
isDomain = true
|
|
|
|
) => {
|
2024-08-02 10:16:14 +05:30
|
|
|
await checkDomainDisplayName(page, domain.displayName);
|
|
|
|
|
2025-08-31 12:46:39 +05:30
|
|
|
await expect(page.getByText(domain.description)).toBeVisible();
|
2024-08-02 10:16:14 +05:30
|
|
|
|
2025-08-31 12:46:39 +05:30
|
|
|
expect(
|
|
|
|
await page.locator(`[id="KnowledgePanel\\.Description"]`).textContent()
|
|
|
|
).toContain(domain.description);
|
2024-08-02 10:16:14 +05:30
|
|
|
|
|
|
|
if (!isEmpty(domain.owners) && !isUndefined(domain.owners)) {
|
|
|
|
await expect(
|
|
|
|
page.getByTestId('domain-owner-name').getByTestId('owner-link')
|
|
|
|
).toContainText(domain.owners[0].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
page.getByTestId('domain-type-label').locator('div')
|
|
|
|
).toContainText(domain.domainType);
|
2024-08-10 18:00:42 +05:30
|
|
|
|
|
|
|
// Check breadcrumbs
|
|
|
|
if (!isDomain && parentDomain) {
|
|
|
|
await expect(
|
|
|
|
page.getByRole('link', { name: parentDomain.fullyQualifiedName })
|
|
|
|
).toBeVisible();
|
|
|
|
}
|
2024-08-02 10:16:14 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
export const createDomain = async (
|
|
|
|
page: Page,
|
|
|
|
domain: Domain['data'],
|
|
|
|
validate = false
|
|
|
|
) => {
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.click('[data-testid="add-entity-button"]');
|
2024-08-02 10:16:14 +05:30
|
|
|
|
2025-09-26 20:31:39 +05:30
|
|
|
await page.waitForSelector('h6:has-text("Add Domain")', { timeout: 5000 });
|
|
|
|
|
|
|
|
await expect(page.locator('h6:has-text("Add Domain")')).toBeVisible();
|
2024-08-02 10:16:14 +05:30
|
|
|
|
2025-09-26 20:31:39 +05:30
|
|
|
const saveButton = page.getByRole('button', { name: 'Save' });
|
2024-08-02 10:16:14 +05:30
|
|
|
|
|
|
|
if (validate) {
|
2025-09-26 20:31:39 +05:30
|
|
|
await saveButton.click();
|
2024-08-02 10:16:14 +05:30
|
|
|
await validateDomainForm(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
await fillDomainForm(page, domain);
|
|
|
|
|
|
|
|
const domainRes = page.waitForResponse('/api/v1/domains');
|
2025-09-26 20:31:39 +05:30
|
|
|
await saveButton.click();
|
2024-08-02 10:16:14 +05:30
|
|
|
await domainRes;
|
2025-09-26 20:31:39 +05:30
|
|
|
|
|
|
|
await toastNotification(page, /Domain created successfully/);
|
|
|
|
|
|
|
|
await selectDomain(page, domain);
|
|
|
|
|
2024-08-02 10:16:14 +05:30
|
|
|
await checkDomainDisplayName(page, domain.displayName);
|
|
|
|
await checkAssetsCount(page, 0);
|
|
|
|
await checkDataProductCount(page, 0);
|
|
|
|
};
|
|
|
|
|
2024-08-10 18:00:42 +05:30
|
|
|
export const createSubDomain = async (
|
|
|
|
page: Page,
|
|
|
|
subDomain: SubDomain['data']
|
|
|
|
) => {
|
|
|
|
await page.getByTestId('domain-details-add-button').click();
|
|
|
|
await page.getByRole('menuitem', { name: 'Sub Domains' }).click();
|
|
|
|
|
|
|
|
await expect(page.getByText('Add Sub Domain')).toBeVisible();
|
|
|
|
|
|
|
|
await fillDomainForm(page, subDomain, false);
|
|
|
|
const saveRes = page.waitForResponse('/api/v1/domains');
|
|
|
|
await page.getByTestId('save-sub-domain').click();
|
|
|
|
await saveRes;
|
|
|
|
};
|
|
|
|
|
2024-08-02 10:16:14 +05:30
|
|
|
export const addAssetsToDomain = async (
|
|
|
|
page: Page,
|
2025-01-08 01:38:08 -08:00
|
|
|
domain: Domain,
|
|
|
|
assets: EntityClass[],
|
|
|
|
navigateToAssetsTab = true
|
2024-08-02 10:16:14 +05:30
|
|
|
) => {
|
2025-01-08 01:38:08 -08:00
|
|
|
if (navigateToAssetsTab) {
|
|
|
|
await goToAssetsTab(page, domain.data);
|
|
|
|
}
|
2024-08-02 10:16:14 +05:30
|
|
|
await checkAssetsCount(page, 0);
|
|
|
|
|
|
|
|
await expect(page.getByTestId('no-data-placeholder')).toContainText(
|
|
|
|
'Adding a new Asset is easy, just give it a spin!'
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.getByTestId('domain-details-add-button').click();
|
2024-08-11 16:55:58 +05:30
|
|
|
await page.getByRole('menuitem', { name: 'Assets', exact: true }).click();
|
2024-08-02 10:16:14 +05:30
|
|
|
|
|
|
|
for (const asset of assets) {
|
|
|
|
const name = get(asset, 'entityResponseData.name');
|
|
|
|
const fqn = get(asset, 'entityResponseData.fullyQualifiedName');
|
2025-06-05 12:22:06 +05:30
|
|
|
const entityDisplayName = get(asset, 'entityResponseData.displayName');
|
|
|
|
const visibleName = entityDisplayName ?? name;
|
2024-08-02 10:16:14 +05:30
|
|
|
|
|
|
|
const searchRes = page.waitForResponse(
|
2025-06-05 12:22:06 +05:30
|
|
|
`/api/v1/search/query?q=${visibleName}&index=all&from=0&size=25&*`
|
2024-08-02 10:16:14 +05:30
|
|
|
);
|
2024-09-05 10:05:54 +05:30
|
|
|
await page
|
|
|
|
.getByTestId('asset-selection-modal')
|
|
|
|
.getByTestId('searchbar')
|
2025-06-05 12:22:06 +05:30
|
|
|
.fill(visibleName);
|
2024-08-02 10:16:14 +05:30
|
|
|
await searchRes;
|
|
|
|
|
|
|
|
await page.locator(`[data-testid="table-data-card_${fqn}"] input`).check();
|
2025-06-05 12:22:06 +05:30
|
|
|
|
|
|
|
await expect(
|
|
|
|
page.locator(
|
|
|
|
`[data-testid="table-data-card_${fqn}"] [data-testid="entity-header-name"]`
|
|
|
|
)
|
|
|
|
).toContainText(visibleName);
|
2024-08-02 10:16:14 +05:30
|
|
|
}
|
|
|
|
|
2025-01-08 01:38:08 -08:00
|
|
|
const assetsAddRes = page.waitForResponse(`/api/v1/domains/*/assets/add`);
|
2025-02-19 14:00:47 +05:30
|
|
|
const searchRes = page.waitForResponse((response) => {
|
|
|
|
const url = new URL(response.url());
|
|
|
|
const queryParams = new URLSearchParams(url.search);
|
|
|
|
const queryFilter = queryParams.get('query_filter');
|
|
|
|
|
|
|
|
return (
|
|
|
|
response
|
|
|
|
.url()
|
2025-08-11 10:21:41 -07:00
|
|
|
.includes('/api/v1/search/query?q=&index=all&from=0&size=15') &&
|
2025-02-19 14:00:47 +05:30
|
|
|
queryFilter !== null &&
|
|
|
|
queryFilter !== ''
|
|
|
|
);
|
|
|
|
});
|
2024-08-02 10:16:14 +05:30
|
|
|
await page.getByTestId('save-btn').click();
|
|
|
|
await assetsAddRes;
|
|
|
|
|
2025-02-19 14:00:47 +05:30
|
|
|
await searchRes;
|
|
|
|
|
2025-01-08 01:38:08 -08:00
|
|
|
await page.reload();
|
2025-02-11 14:51:48 +05:30
|
|
|
await page.waitForLoadState('networkidle');
|
2025-01-08 01:38:08 -08:00
|
|
|
|
2024-08-02 10:16:14 +05:30
|
|
|
await checkAssetsCount(page, assets.length);
|
|
|
|
};
|
|
|
|
|
2024-12-16 15:41:36 +05:30
|
|
|
export const addServicesToDomain = async (
|
|
|
|
page: Page,
|
|
|
|
domain: Domain['data'],
|
|
|
|
assets: EntityClass[]
|
|
|
|
) => {
|
|
|
|
await goToAssetsTab(page, domain);
|
|
|
|
|
|
|
|
await page.getByTestId('domain-details-add-button').click();
|
|
|
|
await page.getByRole('menuitem', { name: 'Assets', exact: true }).click();
|
|
|
|
|
|
|
|
for (const asset of assets) {
|
|
|
|
const name = get(asset, 'name');
|
|
|
|
const fqn = get(asset, 'fullyQualifiedName');
|
|
|
|
|
|
|
|
const searchRes = page.waitForResponse(
|
|
|
|
`/api/v1/search/query?q=${name}&index=all&from=0&size=25&*`
|
|
|
|
);
|
|
|
|
await page
|
|
|
|
.getByTestId('asset-selection-modal')
|
|
|
|
.getByTestId('searchbar')
|
|
|
|
.fill(name);
|
|
|
|
await searchRes;
|
|
|
|
|
|
|
|
await page.locator(`[data-testid="table-data-card_${fqn}"] input`).check();
|
|
|
|
}
|
|
|
|
|
|
|
|
const assetsAddRes = page.waitForResponse(
|
|
|
|
`/api/v1/domains/${encodeURIComponent(
|
|
|
|
domain.fullyQualifiedName ?? ''
|
|
|
|
)}/assets/add`
|
|
|
|
);
|
|
|
|
await page.getByTestId('save-btn').click();
|
|
|
|
await assetsAddRes;
|
|
|
|
};
|
|
|
|
|
2024-08-02 10:16:14 +05:30
|
|
|
export const addAssetsToDataProduct = async (
|
|
|
|
page: Page,
|
2025-01-08 01:38:08 -08:00
|
|
|
dataProductFqn: string,
|
2024-08-02 10:16:14 +05:30
|
|
|
assets: EntityClass[]
|
|
|
|
) => {
|
|
|
|
await page.getByTestId('assets').click();
|
|
|
|
await checkAssetsCount(page, 0);
|
|
|
|
|
|
|
|
await expect(page.getByTestId('no-data-placeholder')).toContainText(
|
|
|
|
'Adding a new Asset is easy, just give it a spin!'
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.getByTestId('data-product-details-add-button').click();
|
|
|
|
|
|
|
|
for (const asset of assets) {
|
|
|
|
const name = get(asset, 'entityResponseData.name');
|
|
|
|
const fqn = get(asset, 'entityResponseData.fullyQualifiedName');
|
|
|
|
|
|
|
|
const searchRes = page.waitForResponse(
|
|
|
|
`/api/v1/search/query?q=${name}&index=all&from=0&size=25&*`
|
|
|
|
);
|
|
|
|
await page.getByTestId('searchbar').fill(name);
|
|
|
|
await searchRes;
|
|
|
|
|
|
|
|
await page.locator(`[data-testid="table-data-card_${fqn}"] input`).check();
|
|
|
|
}
|
|
|
|
|
|
|
|
const assetsAddRes = page.waitForResponse(
|
2025-01-08 01:38:08 -08:00
|
|
|
`/api/v1/dataProducts/*/assets/add`
|
2024-08-02 10:16:14 +05:30
|
|
|
);
|
|
|
|
await page.getByTestId('save-btn').click();
|
|
|
|
await assetsAddRes;
|
|
|
|
|
|
|
|
await checkAssetsCount(page, assets.length);
|
2025-05-13 15:34:09 +05:30
|
|
|
|
|
|
|
for (const asset of assets) {
|
|
|
|
const fqn = get(asset, 'entityResponseData.fullyQualifiedName');
|
|
|
|
|
|
|
|
await page
|
|
|
|
.locator(
|
|
|
|
`[data-testid="table-data-card_${fqn}"] a[data-testid="entity-link"]`
|
|
|
|
)
|
|
|
|
.click();
|
|
|
|
|
|
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
page
|
|
|
|
.getByTestId('KnowledgePanel.DataProducts')
|
|
|
|
.getByTestId('data-products-list')
|
|
|
|
.getByTestId(`data-product-${dataProductFqn}`)
|
|
|
|
).toBeVisible();
|
|
|
|
|
|
|
|
await page.goBack();
|
|
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
}
|
2024-08-02 10:16:14 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
export const removeAssetsFromDataProduct = async (
|
|
|
|
page: Page,
|
|
|
|
dataProduct: DataProduct['data'],
|
|
|
|
assets: EntityClass[]
|
|
|
|
) => {
|
|
|
|
await page.getByTestId('assets').click();
|
|
|
|
for (const asset of assets) {
|
|
|
|
const fqn = get(asset, 'entityResponseData.fullyQualifiedName');
|
|
|
|
await page.locator(`[data-testid="table-data-card_${fqn}"] input`).check();
|
|
|
|
}
|
|
|
|
|
|
|
|
const assetsRemoveRes = page.waitForResponse(
|
|
|
|
`/api/v1/dataProducts/${encodeURIComponent(
|
|
|
|
dataProduct.fullyQualifiedName ?? ''
|
|
|
|
)}/assets/remove`
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.getByTestId('delete-all-button').click();
|
|
|
|
await assetsRemoveRes;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const setupAssetsForDomain = async (page: Page) => {
|
|
|
|
const { afterAction, apiContext } = await getApiContext(page);
|
|
|
|
const table = new TableClass();
|
|
|
|
const topic = new TopicClass();
|
|
|
|
const dashboard = new DashboardClass();
|
2024-09-05 10:05:54 +05:30
|
|
|
await Promise.all([
|
|
|
|
table.create(apiContext),
|
|
|
|
topic.create(apiContext),
|
|
|
|
dashboard.create(apiContext),
|
|
|
|
]);
|
2024-08-02 10:16:14 +05:30
|
|
|
|
|
|
|
const assetCleanup = async () => {
|
2024-09-05 10:05:54 +05:30
|
|
|
await Promise.all([
|
|
|
|
table.delete(apiContext),
|
|
|
|
topic.delete(apiContext),
|
|
|
|
dashboard.delete(apiContext),
|
|
|
|
]);
|
2024-08-02 10:16:14 +05:30
|
|
|
await afterAction();
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
assets: [table, topic, dashboard],
|
|
|
|
assetCleanup,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export const createDataProduct = async (
|
|
|
|
page: Page,
|
|
|
|
dataProduct: DataProduct['data']
|
|
|
|
) => {
|
2024-12-05 17:53:14 +05:30
|
|
|
// Safety check to close potential domain not found alert
|
|
|
|
// Arrived due to parallel testing
|
|
|
|
await closeFirstPopupAlert(page);
|
|
|
|
|
|
|
|
await page.getByTestId('domain-details-add-button').click();
|
2024-08-02 10:16:14 +05:30
|
|
|
await page.getByRole('menuitem', { name: 'Data Products' }).click();
|
|
|
|
|
|
|
|
await expect(page.getByText('Add Data Product')).toBeVisible();
|
|
|
|
|
|
|
|
await fillCommonFormItems(page, dataProduct);
|
|
|
|
const saveRes = page.waitForResponse('/api/v1/dataProducts');
|
|
|
|
await page.getByTestId('save-data-product').click();
|
|
|
|
await saveRes;
|
|
|
|
};
|
2025-01-08 01:38:08 -08:00
|
|
|
|
|
|
|
export const verifyDataProductAssetsAfterDelete = async (
|
|
|
|
page: Page,
|
|
|
|
{
|
|
|
|
domain,
|
|
|
|
dataProduct1,
|
|
|
|
dataProduct2,
|
|
|
|
assets,
|
|
|
|
subDomain,
|
|
|
|
}: {
|
|
|
|
domain: Domain;
|
|
|
|
dataProduct1: DataProduct;
|
|
|
|
dataProduct2: DataProduct;
|
|
|
|
assets: EntityClass[];
|
|
|
|
subDomain?: SubDomain;
|
|
|
|
}
|
|
|
|
) => {
|
|
|
|
const { apiContext } = await getApiContext(page);
|
2025-07-22 13:04:50 +05:30
|
|
|
const newDataProduct1 = new DataProduct([domain], 'PW_DataProduct_Sales');
|
2025-01-08 01:38:08 -08:00
|
|
|
|
|
|
|
await test.step('Add assets to DataProduct Sales', async () => {
|
|
|
|
await redirectToHomePage(page);
|
|
|
|
await sidebarClick(page, SidebarItem.DOMAIN);
|
|
|
|
if (subDomain) {
|
|
|
|
await selectSubDomain(page, domain.data, subDomain.data);
|
|
|
|
await selectDataProductFromTab(page, dataProduct1.data);
|
|
|
|
} else {
|
|
|
|
await selectDataProduct(page, domain.data, dataProduct1.data);
|
|
|
|
}
|
|
|
|
await addAssetsToDataProduct(
|
|
|
|
page,
|
|
|
|
dataProduct1.responseData.fullyQualifiedName ?? '',
|
|
|
|
assets.slice(0, 2)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
await test.step('Add assets to DataProduct Finance', async () => {
|
|
|
|
await redirectToHomePage(page);
|
|
|
|
await sidebarClick(page, SidebarItem.DOMAIN);
|
|
|
|
if (subDomain) {
|
|
|
|
await selectSubDomain(page, domain.data, subDomain.data);
|
|
|
|
await selectDataProductFromTab(page, dataProduct2.data);
|
|
|
|
} else {
|
|
|
|
await selectDataProduct(page, domain.data, dataProduct2.data);
|
|
|
|
}
|
|
|
|
await addAssetsToDataProduct(
|
|
|
|
page,
|
|
|
|
dataProduct2.responseData.fullyQualifiedName ?? '',
|
|
|
|
[assets[2]]
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
await test.step(
|
|
|
|
'Remove Data Product Sales and Create the same again',
|
|
|
|
async () => {
|
|
|
|
// Remove sales data product
|
|
|
|
await dataProduct1.delete(apiContext);
|
|
|
|
|
|
|
|
// Create sales data product again
|
|
|
|
await redirectToHomePage(page);
|
|
|
|
await sidebarClick(page, SidebarItem.DOMAIN);
|
|
|
|
if (subDomain) {
|
|
|
|
await selectSubDomain(page, domain.data, subDomain.data);
|
|
|
|
} else {
|
|
|
|
await selectDomain(page, domain.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
await createDataProduct(page, newDataProduct1.data);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
await test.step(
|
|
|
|
'Verify assets are not present in the newly created data product',
|
|
|
|
async () => {
|
|
|
|
await redirectToHomePage(page);
|
|
|
|
await sidebarClick(page, SidebarItem.DOMAIN);
|
|
|
|
if (subDomain) {
|
|
|
|
await selectSubDomain(page, domain.data, subDomain.data);
|
|
|
|
await selectDataProductFromTab(page, newDataProduct1.data);
|
|
|
|
} else {
|
|
|
|
await selectDataProduct(page, domain.data, newDataProduct1.data);
|
|
|
|
}
|
|
|
|
await checkAssetsCount(page, 0);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2025-02-26 14:46:58 +05:30
|
|
|
|
|
|
|
export const addTagsAndGlossaryToDomain = async (
|
|
|
|
page: Page,
|
|
|
|
{
|
|
|
|
tagFqn,
|
|
|
|
glossaryTermFqn,
|
|
|
|
isDomain = true,
|
|
|
|
}: {
|
|
|
|
tagFqn: string;
|
|
|
|
glossaryTermFqn: string;
|
|
|
|
isDomain?: boolean;
|
|
|
|
}
|
|
|
|
) => {
|
|
|
|
const addTagOrTerm = async (
|
|
|
|
containerType: 'tags' | 'glossary',
|
|
|
|
value: string
|
|
|
|
) => {
|
|
|
|
const container = `[data-testid="${containerType}-container"]`;
|
|
|
|
|
|
|
|
// Click add button
|
|
|
|
await page.locator(`${container} [data-testid="add-tag"]`).click();
|
|
|
|
|
|
|
|
// Fill and select tag/term
|
|
|
|
const input = page.locator(`${container} #tagsForm_tags`);
|
|
|
|
await input.click();
|
|
|
|
await input.fill(value);
|
2025-05-13 17:05:51 +05:30
|
|
|
const tag = page.getByTestId(`tag-${value}`);
|
|
|
|
if (containerType === 'glossary') {
|
|
|
|
// To avoid clicking on white space between checkbox and text
|
|
|
|
await tag.locator('.ant-select-tree-checkbox').click();
|
|
|
|
} else {
|
|
|
|
await tag.click();
|
|
|
|
}
|
2025-02-26 14:46:58 +05:30
|
|
|
|
|
|
|
// Save and wait for response
|
|
|
|
const updateResponse = page.waitForResponse(
|
|
|
|
(response) =>
|
|
|
|
response
|
|
|
|
.url()
|
|
|
|
.includes(`/api/v1/${isDomain ? 'domains' : 'dataProducts'}/`) &&
|
|
|
|
response.request().method() === 'PATCH'
|
|
|
|
);
|
|
|
|
await page.getByTestId('saveAssociatedTag').click();
|
|
|
|
await updateResponse;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Add tag
|
|
|
|
await addTagOrTerm('tags', tagFqn);
|
|
|
|
|
|
|
|
// Add glossary term
|
|
|
|
await addTagOrTerm('glossary', glossaryTermFqn);
|
|
|
|
};
|
2025-04-11 20:40:26 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies if the active domain is set to All Domains (DEFAULT_DOMAIN_VALUE)
|
|
|
|
*/
|
|
|
|
export const verifyActiveDomainIsDefault = async (page: Page) => {
|
|
|
|
await expect(page.getByTestId('domain-dropdown')).toContainText(
|
|
|
|
'All Domains'
|
|
|
|
);
|
|
|
|
};
|
2025-04-28 13:43:24 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up a complete environment for domain ownership testing
|
|
|
|
* Creates user, policy, role, domain, data product and assigns ownership
|
|
|
|
* Returns all created objects and a cleanup function
|
|
|
|
*/
|
|
|
|
export const setupDomainOwnershipTest = async (apiContext: any) => {
|
|
|
|
// Create all necessary resources
|
|
|
|
const dataConsumerUser = new UserClass();
|
|
|
|
const id = uuid();
|
|
|
|
const domainForTest = new Domain({
|
|
|
|
name: `PW_Domain_Owner_Rule_Testing-${id}`,
|
|
|
|
displayName: `PW_Domain_Owner_Rule_Testing-${id}`,
|
|
|
|
description: 'playwright domain description',
|
|
|
|
domainType: 'Aggregate',
|
|
|
|
fullyQualifiedName: `PW_Domain_Owner_Rule_Testing-${id}`,
|
|
|
|
});
|
|
|
|
const dataProductForTest = new DataProduct(
|
2025-07-22 13:04:50 +05:30
|
|
|
[domainForTest],
|
2025-04-28 13:43:24 +05:30
|
|
|
`PW_DataProduct_Owner_Rule-${id}`
|
|
|
|
);
|
|
|
|
|
|
|
|
await dataConsumerUser.create(apiContext);
|
|
|
|
await domainForTest.create(apiContext);
|
|
|
|
|
|
|
|
// Setup permissions
|
|
|
|
const dataConsumerPolicy = new PolicyClass();
|
|
|
|
const dataConsumerRole = new RolesClass();
|
|
|
|
|
|
|
|
// Create domain access policy
|
|
|
|
const domainRule = [
|
|
|
|
{
|
|
|
|
name: 'DomainRule',
|
|
|
|
description: '',
|
|
|
|
resources: ['dataProduct', 'domain'],
|
|
|
|
operations: ['All'],
|
|
|
|
effect: 'allow',
|
|
|
|
condition: 'isOwner()',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
await dataConsumerPolicy.create(apiContext, domainRule);
|
|
|
|
await dataConsumerRole.create(apiContext, [
|
|
|
|
dataConsumerPolicy.responseData.name,
|
|
|
|
]);
|
|
|
|
|
|
|
|
await dataProductForTest.create(apiContext);
|
|
|
|
|
|
|
|
// Create team for the user
|
|
|
|
const dataConsumerTeam = new TeamClass({
|
|
|
|
name: `PW_data_consumer_team-${id}`,
|
|
|
|
displayName: `PW Data Consumer Team ${id}`,
|
|
|
|
description: 'playwright data consumer team description',
|
|
|
|
teamType: 'Group',
|
|
|
|
users: [dataConsumerUser.responseData.id ?? ''],
|
|
|
|
defaultRoles: [dataConsumerRole.responseData.id ?? ''],
|
|
|
|
});
|
|
|
|
|
|
|
|
await dataConsumerTeam.create(apiContext);
|
|
|
|
|
|
|
|
// Set domain ownership
|
|
|
|
await domainForTest.patch({
|
|
|
|
apiContext,
|
|
|
|
patchData: [
|
|
|
|
{
|
|
|
|
op: 'add',
|
|
|
|
path: '/owners/0',
|
|
|
|
value: {
|
|
|
|
id: dataConsumerUser.responseData.id,
|
|
|
|
type: 'user',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
// Return cleanup function and all created resources
|
|
|
|
const cleanup = async (apiContext1: APIRequestContext) => {
|
|
|
|
await dataProductForTest.delete(apiContext1);
|
|
|
|
await domainForTest.delete(apiContext1);
|
|
|
|
await dataConsumerUser.delete(apiContext1);
|
|
|
|
await dataConsumerTeam.delete(apiContext1);
|
|
|
|
await dataConsumerPolicy.delete(apiContext1);
|
|
|
|
await dataConsumerRole.delete(apiContext1);
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
dataConsumerUser,
|
|
|
|
domainForTest,
|
|
|
|
dataProductForTest,
|
|
|
|
dataConsumerTeam,
|
|
|
|
dataConsumerPolicy,
|
|
|
|
dataConsumerRole,
|
|
|
|
cleanup,
|
|
|
|
};
|
|
|
|
};
|
2025-08-25 15:52:12 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up a complete environment for testing hasDomain() rule condition
|
|
|
|
* Creates user, domain, subdomain, assets, policy with hasDomain(), role, and team
|
|
|
|
* Returns all created objects and a cleanup function
|
|
|
|
*/
|
|
|
|
export const setupDomainHasDomainTest = async (
|
|
|
|
apiContext: APIRequestContext
|
|
|
|
) => {
|
|
|
|
const id = uuid();
|
|
|
|
|
|
|
|
// Create test user
|
|
|
|
const testUser = new UserClass();
|
|
|
|
await testUser.create(apiContext);
|
|
|
|
const mainDomain = new Domain();
|
|
|
|
await mainDomain.create(apiContext);
|
|
|
|
const subDomain = new SubDomain(mainDomain);
|
|
|
|
await subDomain.create(apiContext);
|
|
|
|
|
|
|
|
// Create assets for domain and subdomain
|
|
|
|
const domainTable = new TableClass();
|
|
|
|
const subDomainTable = new TableClass();
|
|
|
|
await domainTable.create(apiContext);
|
|
|
|
await subDomainTable.create(apiContext);
|
|
|
|
|
|
|
|
// Create policy with hasDomain() rule
|
|
|
|
const domainPolicy = new PolicyClass();
|
|
|
|
const domainRule = [
|
|
|
|
{
|
|
|
|
name: 'HasDomainRule',
|
|
|
|
description: '',
|
2025-09-15 21:42:59 +05:30
|
|
|
resources: ['All'],
|
2025-08-25 15:52:12 +05:30
|
|
|
operations: ['All'],
|
|
|
|
effect: 'allow',
|
|
|
|
condition: 'hasDomain()',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
await domainPolicy.create(apiContext, domainRule);
|
|
|
|
|
|
|
|
// Create role with the policy
|
|
|
|
const domainRole = new RolesClass();
|
|
|
|
await domainRole.create(apiContext, [domainPolicy.responseData.name]);
|
|
|
|
|
|
|
|
// Create team with the user and assign the role
|
|
|
|
const domainTeam = new TeamClass({
|
|
|
|
name: `PW_Team_HasDomain_${id}`,
|
|
|
|
displayName: `PW Team HasDomain ${id}`,
|
|
|
|
description: 'Team for hasDomain() rule testing',
|
|
|
|
teamType: 'Group',
|
|
|
|
users: [testUser.responseData.id ?? ''],
|
|
|
|
defaultRoles: [domainRole.responseData.id ?? ''],
|
|
|
|
});
|
|
|
|
await domainTeam.create(apiContext);
|
|
|
|
|
|
|
|
// Add user to domain
|
|
|
|
await testUser.patch({
|
|
|
|
apiContext,
|
|
|
|
patchData: [
|
|
|
|
{
|
|
|
|
op: 'add',
|
|
|
|
path: '/domains/0',
|
|
|
|
value: {
|
|
|
|
id: mainDomain.responseData.id,
|
|
|
|
type: 'domain',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
// Assign assets to domain and subdomain
|
|
|
|
await domainTable.patch({
|
|
|
|
apiContext,
|
|
|
|
patchData: [
|
|
|
|
{
|
|
|
|
op: 'add',
|
|
|
|
path: '/domains/0',
|
|
|
|
value: {
|
|
|
|
id: mainDomain.responseData.id,
|
|
|
|
type: 'domain',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
await subDomainTable.patch({
|
|
|
|
apiContext,
|
|
|
|
patchData: [
|
|
|
|
{
|
|
|
|
op: 'add',
|
|
|
|
path: '/domains/0',
|
|
|
|
value: {
|
|
|
|
id: subDomain.responseData.id,
|
|
|
|
type: 'domain',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
// Cleanup function
|
|
|
|
const cleanup = async (cleanupContext: APIRequestContext) => {
|
|
|
|
await domainTable.delete(cleanupContext);
|
|
|
|
await subDomainTable.delete(cleanupContext);
|
|
|
|
await subDomain.delete(cleanupContext);
|
|
|
|
await mainDomain.delete(cleanupContext);
|
|
|
|
await domainTeam.delete(cleanupContext);
|
|
|
|
await domainRole.delete(cleanupContext);
|
|
|
|
await domainPolicy.delete(cleanupContext);
|
|
|
|
await testUser.delete(cleanupContext);
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
testUser,
|
|
|
|
mainDomain,
|
|
|
|
subDomain,
|
|
|
|
domainTable,
|
|
|
|
subDomainTable,
|
|
|
|
domainPolicy,
|
|
|
|
domainRole,
|
|
|
|
domainTeam,
|
|
|
|
cleanup,
|
|
|
|
};
|
|
|
|
};
|
2025-09-15 21:42:59 +05:30
|
|
|
|
|
|
|
export const setupNoDomainRule = async (apiContext: APIRequestContext) => {
|
|
|
|
const id = uuid();
|
|
|
|
|
|
|
|
// Create test user
|
|
|
|
const testUser = new UserClass();
|
|
|
|
await testUser.create(apiContext);
|
|
|
|
const mainDomain = new Domain();
|
|
|
|
await mainDomain.create(apiContext);
|
|
|
|
|
|
|
|
// Create assets for domain
|
|
|
|
const domainTable = new TableClass();
|
|
|
|
const noDomainTable = new TableClass();
|
|
|
|
await domainTable.create(apiContext);
|
|
|
|
await noDomainTable.create(apiContext);
|
|
|
|
|
|
|
|
// Create policy with hasDomain() rule
|
|
|
|
const domainPolicy = new PolicyClass();
|
|
|
|
const domainRule = [
|
|
|
|
{
|
|
|
|
name: 'NoDomainRule',
|
|
|
|
description: '',
|
|
|
|
resources: ['All'],
|
|
|
|
operations: ['ViewAll'],
|
|
|
|
effect: 'deny',
|
|
|
|
condition: 'noDomain()',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
await domainPolicy.create(apiContext, domainRule);
|
|
|
|
|
|
|
|
// Create role with the policy
|
|
|
|
const domainRole = new RolesClass();
|
|
|
|
await domainRole.create(apiContext, [domainPolicy.responseData.name]);
|
|
|
|
|
|
|
|
// Create team with the user and assign the role
|
|
|
|
const domainTeam = new TeamClass({
|
|
|
|
name: `PW_Team_NoDomain_${id}`,
|
|
|
|
displayName: `PW Team NoDomain ${id}`,
|
|
|
|
description: 'Team for noDomain() rule testing',
|
|
|
|
teamType: 'Group',
|
|
|
|
users: [testUser.responseData.id ?? ''],
|
|
|
|
defaultRoles: [domainRole.responseData.id ?? ''],
|
|
|
|
});
|
|
|
|
await domainTeam.create(apiContext);
|
|
|
|
|
|
|
|
// Add user to domain
|
|
|
|
await testUser.patch({
|
|
|
|
apiContext,
|
|
|
|
patchData: [
|
|
|
|
{
|
|
|
|
op: 'add',
|
|
|
|
path: '/domains/0',
|
|
|
|
value: {
|
|
|
|
id: mainDomain.responseData.id,
|
|
|
|
type: 'domain',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
// Assign assets to domain and subdomain
|
|
|
|
await domainTable.patch({
|
|
|
|
apiContext,
|
|
|
|
patchData: [
|
|
|
|
{
|
|
|
|
op: 'add',
|
|
|
|
path: '/domains/0',
|
|
|
|
value: {
|
|
|
|
id: mainDomain.responseData.id,
|
|
|
|
type: 'domain',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
// Cleanup function
|
|
|
|
const cleanup = async (cleanupContext: APIRequestContext) => {
|
|
|
|
await domainTable.delete(cleanupContext);
|
|
|
|
await noDomainTable.delete(cleanupContext);
|
|
|
|
await mainDomain.delete(cleanupContext);
|
|
|
|
await domainTeam.delete(cleanupContext);
|
|
|
|
await domainRole.delete(cleanupContext);
|
|
|
|
await domainPolicy.delete(cleanupContext);
|
|
|
|
await testUser.delete(cleanupContext);
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
testUser,
|
|
|
|
mainDomain,
|
|
|
|
domainTable,
|
|
|
|
noDomainTable,
|
|
|
|
domainPolicy,
|
|
|
|
domainRole,
|
|
|
|
domainTeam,
|
|
|
|
cleanup,
|
|
|
|
};
|
|
|
|
};
|