fix playwright test issues (#17836)

* fix playwright test issues

* cleanup

* fixed wait issue in test cases spec

* fix AddRoleAndAssignToUser spec failure

---------

Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
Karan Hotchandani 2024-09-13 20:12:56 +05:30 committed by Shailesh Parmar
parent aa6bcc4228
commit 04c289ce41
10 changed files with 31 additions and 82 deletions

View File

@ -1,57 +0,0 @@
/*
* 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 { interceptURL, verifyResponseStatusCode } from '../../common/common';
import { SidebarItem } from '../../constants/Entity.interface';
describe.skip('Explore Page', { tags: 'DataAssets' }, () => {
before(() => {
cy.login();
});
it('should verify order of search results', () => {
const searchText = 'customer';
interceptURL(
'GET',
`api/v1/search/query?q=**&index=dataAsset**`,
'suggestAPI'
);
interceptURL(
'GET',
`api/v1/search/query?q=**&index=table_search_index**`,
'searchAPI'
);
cy.sidebarClick(SidebarItem.EXPLORE);
cy.get('[data-testid="searchBox"]').clear();
cy.get('[data-testid="searchBox"]').type(searchText);
verifyResponseStatusCode('@suggestAPI', 200);
const linksArray = [];
cy.get('[data-testid="group-table_search_index"] button a').each(
($link) => {
linksArray.push($link.attr('href'));
}
);
cy.get('[data-testid="searchBox"]').type('{enter}');
verifyResponseStatusCode('@searchAPI', 200);
cy.wrap(linksArray).each((link, index) => {
cy.get(`[data-testid="entity-link"]`)
.eq(index)
.should('have.attr', 'href', link);
});
});
});

View File

@ -22,6 +22,7 @@ import {
uuid,
} from '../../utils/common';
import { settingClick } from '../../utils/sidebar';
import { visitUserProfilePage } from '../../utils/user';
const roleName = `Role-test-${uuid()}`;
const user = generateRandomUsername();
@ -29,7 +30,7 @@ const userDisplayName = user.firstName + ' ' + user.lastName;
const userName = user.email.split('@')[0].toLowerCase();
// use the admin user to login
test.use({ storageState: 'playwright/.auth/admin.json', trace: 'off' });
test.use({ storageState: 'playwright/.auth/admin.json' });
test.describe.serial('Add role and assign it to the user', () => {
test.beforeEach(async ({ page }) => {
@ -47,6 +48,7 @@ test.describe.serial('Add role and assign it to the user', () => {
test('Create role', async ({ page }) => {
await settingClick(page, GlobalSettingOptions.ROLES);
await page.waitForLoadState('networkidle');
await page.click('[data-testid="add-role"]');
@ -79,12 +81,18 @@ test.describe.serial('Add role and assign it to the user', () => {
test('Create new user and assign new role to him', async ({ page }) => {
await settingClick(page, GlobalSettingOptions.USERS);
await page.waitForLoadState('networkidle');
await page.click('[data-testid="add-user"]');
await page.fill('[data-testid="email"]', user.email);
await page.fill('[data-testid="displayName"]', userDisplayName);
await page.fill(descriptionBox, 'Adding user');
const generatePasswordResponse = page.waitForResponse(
`/api/v1/users/generateRandomPwd`
);
await page.click('[data-testid="password-generator"]');
await generatePasswordResponse;
await page.click('[data-testid="roles-dropdown"]');
await page.fill('#roles', roleName);
@ -98,26 +106,15 @@ test.describe.serial('Add role and assign it to the user', () => {
});
test('Verify assigned role to new user', async ({ page }) => {
await settingClick(page, GlobalSettingOptions.USERS);
await visitUserProfilePage(page, userName);
const searchUser = page.waitForResponse(
`/api/v1/search/query?q=*${encodeURIComponent(userDisplayName)}*`
);
await page.waitForSelector('[data-testid="searchbar"]');
await page.fill('[data-testid="searchbar"]', userDisplayName);
await searchUser;
await page.waitForSelector(`[data-testid="${userName}"]`);
await page.click(`[data-testid="${userName}"]`);
await page.waitForSelector('[data-testid="user-profile"]');
await page.click(
'[data-testid="user-profile"] .ant-collapse-expand-icon > .anticon'
);
expect(
await page.textContent(
'[data-testid="user-profile"] [data-testid="user-profile-roles"]'
)
).toContain(roleName);
await expect(
page.getByTestId('user-profile').getByTestId('user-profile-roles')
).toContainText(roleName);
});
});

View File

@ -133,6 +133,8 @@ entities.forEach((EntityClass) => {
});
test('User as Owner with unsorted list', async ({ page }) => {
test.slow(true);
const { afterAction, apiContext } = await getApiContext(page);
const owner1Data = generateRandomUsername('PW_A_');
const owner2Data = generateRandomUsername('PW_B_');

View File

@ -54,14 +54,15 @@ test('Table difference test case', async ({ page }) => {
await page.getByTestId('test-case-name').fill(testCase.name);
await page.getByTestId('test-type').click();
await page.getByTitle('Compare 2 tables for').click();
const tableSearchResponse = page.waitForResponse(
`/api/v1/search/query?q=*${encodeURIComponent(
testCase.table2
)}*index=table_search_index*`
);
await page.click('#tableTestForm_params_table2');
const tableSearchResponse = page.waitForResponse(
`/api/v1/search/query?q=*index=table_search_index*`
);
await page.fill(`#tableTestForm_params_table2`, testCase.table2);
await tableSearchResponse;
// The 'networkidle' parameter tells Playwright to wait until there are no network connections
// for at least 500 ms.
await page.waitForLoadState('networkidle');
await page
.getByTitle(table2.entityResponseData?.['fullyQualifiedName'])
.click();

View File

@ -173,7 +173,6 @@ export const setupEntitiesForLineage = async (
for (const entity of entities) {
await entity.create(apiContext);
}
await currentEntity.create(apiContext);
const cleanup = async () => {

View File

@ -178,6 +178,7 @@ const DocumentationTab = ({
children: (
<div className="p-md domain-content-container">
<DescriptionV1
removeBlur
description={description}
entityName={getEntityName(domain)}
entityType={EntityType.DOMAIN}

View File

@ -94,7 +94,7 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
JSON.stringify(combinedQueryFilter)
),
key === TIER_FQN_KEY
? getTags({ parent: 'Tier' })
? getTags({ parent: 'Tier', limit: 50 })
: Promise.resolve(null),
]);

View File

@ -12,6 +12,7 @@
*/
import { Col, Row, Space, Tabs } from 'antd';
import classNames from 'classnames';
import { isEmpty, noop } from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@ -271,7 +272,11 @@ const GlossaryDetails = ({
className="glossary-details"
data-testid="glossary-details"
gutter={[0, 16]}>
<Col className="p-x-md p-l-xl" span={24}>
<Col
className={classNames('p-x-md', {
'p-l-xl': !isVersionView,
})}
span={24}>
<GlossaryHeader
isGlossary
isVersionView={isVersionView}

View File

@ -571,7 +571,7 @@ const GlossaryHeader = ({
</Col>
<Col flex="360px">
<div className="d-flex gap-2 justify-end">
{createButtons}
{!isVersionView && createButtons}
<ButtonGroup className="p-l-xs" size="small">
{updateVote && (

View File

@ -417,6 +417,7 @@ export const getTierOptions: () => Promise<AsyncFetchListValues> = async () => {
try {
const { data: tiers } = await getTags({
parent: 'Tier',
limit: 50,
});
const tierFields = tiers.map((tier) => ({