fix tests

This commit is contained in:
karanh37 2025-09-26 20:31:39 +05:30
parent 56a44c5463
commit 6f0e33dcf7
5 changed files with 60 additions and 56 deletions

View File

@ -20,6 +20,8 @@ export enum SidebarItem {
DOMAIN = 'domain', DOMAIN = 'domain',
GOVERNANCE = 'governance', GOVERNANCE = 'governance',
GLOSSARY = 'glossary', GLOSSARY = 'glossary',
DOMAINS = 'domains-section',
DATA_PRODUCTS = 'data-products',
TAGS = 'tags', TAGS = 'tags',
INSIGHTS = 'data-insight', INSIGHTS = 'data-insight',
SETTINGS = 'settings', SETTINGS = 'settings',
@ -44,6 +46,7 @@ export const SIDEBAR_LIST_ITEMS = {
[SidebarItem.GLOSSARY]: [SidebarItem.GOVERNANCE, SidebarItem.GLOSSARY], [SidebarItem.GLOSSARY]: [SidebarItem.GOVERNANCE, SidebarItem.GLOSSARY],
[SidebarItem.TAGS]: [SidebarItem.GOVERNANCE, SidebarItem.TAGS], [SidebarItem.TAGS]: [SidebarItem.GOVERNANCE, SidebarItem.TAGS],
[SidebarItem.METRICS]: [SidebarItem.GOVERNANCE, SidebarItem.METRICS], [SidebarItem.METRICS]: [SidebarItem.GOVERNANCE, SidebarItem.METRICS],
[SidebarItem.DOMAIN]: [SidebarItem.DOMAINS, SidebarItem.DOMAIN],
// Profile Dropdown // Profile Dropdown
'user-name': ['dropdown-profile', 'user-name'], 'user-name': ['dropdown-profile', 'user-name'],

View File

@ -10,18 +10,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*
* Copyright 2024 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
* 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.
*/
import base, { APIRequestContext, expect, Page } from '@playwright/test'; import base, { APIRequestContext, expect, Page } from '@playwright/test';
import { Operation } from 'fast-json-patch'; import { Operation } from 'fast-json-patch';
import { get } from 'lodash'; import { get } from 'lodash';
@ -169,6 +157,12 @@ test.describe('Domains', () => {
await test.step('Create domain', async () => { await test.step('Create domain', async () => {
await sidebarClick(page, SidebarItem.DOMAIN); await sidebarClick(page, SidebarItem.DOMAIN);
await page.waitForLoadState('networkidle');
await page.waitForSelector('[data-testid="loader"]', {
state: 'detached',
});
await createDomain(page, domain.data, false); await createDomain(page, domain.data, false);
await verifyDomain(page, domain.data); await verifyDomain(page, domain.data);
}); });

View File

@ -33,13 +33,14 @@ import {
NAME_MAX_LENGTH_VALIDATION_ERROR, NAME_MAX_LENGTH_VALIDATION_ERROR,
NAME_VALIDATION_ERROR, NAME_VALIDATION_ERROR,
redirectToHomePage, redirectToHomePage,
toastNotification,
uuid, uuid,
} from './common'; } from './common';
import { addOwner, waitForAllLoadersToDisappear } from './entity'; import { addOwner, waitForAllLoadersToDisappear } from './entity';
import { sidebarClick } from './sidebar'; import { sidebarClick } from './sidebar';
export const assignDomain = async (page: Page, domain: Domain['data']) => { export const assignDomain = async (page: Page, domain: Domain['data']) => {
await page.getByTestId('add-domain').click(); await page.getByTestId('add-entity-button').click();
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' }); await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
const searchDomain = page.waitForResponse( const searchDomain = page.waitForResponse(
`/api/v1/search/query?q=*${encodeURIComponent(domain.name)}*` `/api/v1/search/query?q=*${encodeURIComponent(domain.name)}*`
@ -65,7 +66,7 @@ export const assignDomain = async (page: Page, domain: Domain['data']) => {
}; };
export const updateDomain = async (page: Page, domain: Domain['data']) => { export const updateDomain = async (page: Page, domain: Domain['data']) => {
await page.getByTestId('add-domain').click(); await page.getByTestId('add-entity-button').click();
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' }); await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
await page.getByTestId('selectable-list').getByTestId('searchbar').clear(); await page.getByTestId('selectable-list').getByTestId('searchbar').clear();
const searchDomain = page.waitForResponse( const searchDomain = page.waitForResponse(
@ -84,7 +85,7 @@ export const updateDomain = async (page: Page, domain: Domain['data']) => {
}; };
export const removeDomain = async (page: Page) => { export const removeDomain = async (page: Page) => {
await page.getByTestId('add-domain').click(); await page.getByTestId('add-entity-button').click();
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' }); await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
await expect(page.getByTestId('remove-owner').locator('path')).toBeVisible(); await expect(page.getByTestId('remove-owner').locator('path')).toBeVisible();
@ -117,27 +118,24 @@ export const validateDomainForm = async (page: Page) => {
await expect(page.locator('#name_help')).toHaveText(NAME_VALIDATION_ERROR); await expect(page.locator('#name_help')).toHaveText(NAME_VALIDATION_ERROR);
}; };
export const selectDomain = async ( export const selectDomain = async (page: Page, domain: Domain['data']) => {
page: Page, const searchBox = page
domain: Domain['data'], .getByTestId('page-layout-v1')
bWaitForResponse = true .getByRole('textbox', { name: 'Search' });
) => {
const menuItem = page.getByRole('menuitem', { name: domain.displayName }); const domainRes = page.waitForResponse(
const isSelected = await menuItem.evaluate((element) => { '/api/v1/search/query?q=*&index=domain_search_index*'
return element.classList.contains('ant-menu-item-selected'); );
await searchBox.fill(domain.name);
await domainRes;
await page.waitForSelector('[data-testid="loader"]', {
state: 'detached',
}); });
if (!isSelected) { await page.getByRole('row', { name: domain.displayName }).click();
if (bWaitForResponse) {
const domainRes = page.waitForResponse(
'/api/v1/domains/name/*?fields=children%2Cowners%2Cparent%2Cexperts%2Ctags%2Cfollowers%2Cextension'
);
await menuItem.click();
await domainRes;
} else {
await menuItem.click();
}
}
await page.waitForLoadState('networkidle'); await page.waitForLoadState('networkidle');
@ -220,7 +218,7 @@ export const selectDataProduct = async (
const goToAssetsTab = async (page: Page, domain: Domain['data']) => { const goToAssetsTab = async (page: Page, domain: Domain['data']) => {
await selectDomain(page, domain); await selectDomain(page, domain);
await checkDomainDisplayName(page, domain.displayName); await checkDomainDisplayName(page, domain.displayName);
await page.getByTestId('assets').click(); await page.getByRole('tab', { name: /Assets/ }).click();
await waitForAllLoadersToDisappear(page); await waitForAllLoadersToDisappear(page);
}; };
@ -228,8 +226,8 @@ const fillCommonFormItems = async (
page: Page, page: Page,
entity: Domain['data'] | DataProduct['data'] | SubDomain['data'] entity: Domain['data'] | DataProduct['data'] | SubDomain['data']
) => { ) => {
await page.locator('[data-testid="name"]').fill(entity.name); await page.locator('#root\\/name').fill(entity.name);
await page.locator('[data-testid="display-name"]').fill(entity.displayName); await page.locator('#root\\/displayName').fill(entity.displayName);
await page.locator(descriptionBox).fill(entity.description); await page.locator(descriptionBox).fill(entity.description);
if (!isEmpty(entity.owners) && !isUndefined(entity.owners)) { if (!isEmpty(entity.owners) && !isUndefined(entity.owners)) {
await addOwner({ await addOwner({
@ -249,16 +247,11 @@ export const fillDomainForm = async (
isDomain = true isDomain = true
) => { ) => {
await fillCommonFormItems(page, entity); await fillCommonFormItems(page, entity);
if (isDomain) {
await page.click('[data-testid="domainType"]'); const domainTypeCombo = page.getByRole('combobox', { name: 'Domain Type' });
} else { await domainTypeCombo.click();
await page
.getByLabel('Add Sub Domain') await page.getByRole('option', { name: entity.domainType }).click();
.getByTestId('domainType')
.locator('div')
.click();
}
await page.getByTitle(entity.domainType).locator('div').click();
}; };
export const checkDomainDisplayName = async ( export const checkDomainDisplayName = async (
@ -319,24 +312,29 @@ export const createDomain = async (
domain: Domain['data'], domain: Domain['data'],
validate = false validate = false
) => { ) => {
await page.click('[data-testid="add-domain"]'); await page.click('[data-testid="add-entity-button"]');
await page.waitForSelector('[data-testid="form-heading"]');
await expect(page.locator('[data-testid="form-heading"]')).toHaveText( await page.waitForSelector('h6:has-text("Add Domain")', { timeout: 5000 });
'Add Domain'
);
await page.click('[data-testid="save-domain"]'); await expect(page.locator('h6:has-text("Add Domain")')).toBeVisible();
const saveButton = page.getByRole('button', { name: 'Save' });
if (validate) { if (validate) {
await saveButton.click();
await validateDomainForm(page); await validateDomainForm(page);
} }
await fillDomainForm(page, domain); await fillDomainForm(page, domain);
const domainRes = page.waitForResponse('/api/v1/domains'); const domainRes = page.waitForResponse('/api/v1/domains');
await page.click('[data-testid="save-domain"]'); await saveButton.click();
await domainRes; await domainRes;
await toastNotification(page, /Domain created successfully/);
await selectDomain(page, domain);
await checkDomainDisplayName(page, domain.displayName); await checkDomainDisplayName(page, domain.displayName);
await checkAssetsCount(page, 0); await checkAssetsCount(page, 0);
await checkDataProductCount(page, 0); await checkDataProductCount(page, 0);

View File

@ -22,6 +22,7 @@ import {
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import Loader from '../../Loader/Loader';
import { TableViewConfig } from '../shared/types'; import { TableViewConfig } from '../shared/types';
import { useTableRow } from './useTableRow'; import { useTableRow } from './useTableRow';
@ -73,7 +74,15 @@ export const useDataTable = <T extends { id: string }>(
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{isEmpty(listing.entities) && hasActiveFiltersOrSearch ? ( {listing.loading ? (
<TableRow>
<TableCell
align="center"
colSpan={listing.columns.length + (enableSelection ? 1 : 0)}>
<Loader />
</TableCell>
</TableRow>
) : isEmpty(listing.entities) && hasActiveFiltersOrSearch ? (
<TableRow> <TableRow>
<TableCell <TableCell
align="center" align="center"

View File

@ -101,7 +101,7 @@ export const SIDEBAR_LIST: Array<LeftSidebarItem> = [
key: 'domains-section', key: 'domains-section',
title: 'label.domain-plural', title: 'label.domain-plural',
icon: DomainsIcon, icon: DomainsIcon,
dataTestId: `app-bar-item-${SidebarItem.DOMAINS_SECTION}`, dataTestId: SidebarItem.DOMAINS_SECTION,
children: [ children: [
{ {
key: ROUTES.DOMAIN, key: ROUTES.DOMAIN,