fix(test): flaky customize details page test (#23679)

This commit is contained in:
Chirag Madlani 2025-10-02 19:29:23 +05:30 committed by GitHub
parent 5e09fc6e15
commit 3cd15bd053
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 85 additions and 21 deletions

View File

@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { expect, Page, test as base } from '@playwright/test';
import { test as base, expect, Page } from '@playwright/test';
import {
ECustomizedDataAssets,
ECustomizedGovernance,
@ -32,6 +32,7 @@ import {
checkDefaultStateForNavigationTree,
validateLeftSidebarWithHiddenItems,
} from '../../utils/customizeNavigation';
import { navigateToPersonaWithPagination } from '../../utils/persona';
import { settingClick } from '../../utils/sidebar';
const persona = new PersonaClass();
@ -345,11 +346,19 @@ test.describe('Persona customization', () => {
await test.step(
`should show all the tabs & widget as default when no customization is done`,
async () => {
const personaListResponse =
adminPage.waitForResponse(`/api/v1/personas?*`);
await settingClick(adminPage, GlobalSettingOptions.PERSONA);
await adminPage.waitForLoadState('networkidle');
await adminPage
.getByTestId(`persona-details-card-${persona.data.name}`)
.click();
await personaListResponse;
// Need to find persona card and click as the list might get paginated
await navigateToPersonaWithPagination(
adminPage,
persona.data.name,
true,
3
);
await adminPage.getByRole('tab', { name: 'Customize UI' }).click();
await adminPage.waitForLoadState('networkidle');
await adminPage.getByText('Data Assets').click();
@ -447,11 +456,18 @@ test.describe('Persona customization', () => {
await test.step(
`should show all the tabs & widget as default when no customization is done`,
async () => {
const personaListResponse =
adminPage.waitForResponse(`/api/v1/personas?*`);
await settingClick(adminPage, GlobalSettingOptions.PERSONA);
await adminPage.waitForLoadState('networkidle');
await adminPage
.getByTestId(`persona-details-card-${persona.data.name}`)
.click();
await personaListResponse;
// Need to find persona card and click as the list might get paginated
await navigateToPersonaWithPagination(
adminPage,
persona.data.name,
true,
3
);
await adminPage.getByRole('tab', { name: 'Customize UI' }).click();
await adminPage.waitForLoadState('networkidle');
await adminPage.getByText('Governance').click();
@ -542,11 +558,18 @@ test.describe('Persona customization', () => {
test.slow();
await test.step('apply customization', async () => {
const personaListResponse =
adminPage.waitForResponse(`/api/v1/personas?*`);
await settingClick(adminPage, GlobalSettingOptions.PERSONA);
await adminPage.waitForLoadState('networkidle');
await adminPage
.getByTestId(`persona-details-card-${persona.data.name}`)
.click();
await personaListResponse;
// Need to find persona card and click as the list might get paginated
await navigateToPersonaWithPagination(
adminPage,
persona.data.name,
true,
3
);
await adminPage.getByRole('tab', { name: 'Customize UI' }).click();
await adminPage.waitForLoadState('networkidle');
await adminPage.getByText('Governance').click();
@ -608,11 +631,18 @@ test.describe('Persona customization', () => {
userPage,
}) => {
await test.step('apply tab label customization for Table', async () => {
const personaListResponse =
adminPage.waitForResponse(`/api/v1/personas?*`);
await settingClick(adminPage, GlobalSettingOptions.PERSONA);
await adminPage.waitForLoadState('networkidle');
await adminPage
.getByTestId(`persona-details-card-${persona.data.name}`)
.click();
await personaListResponse;
// Need to find persona card and click as the list might get paginated
await navigateToPersonaWithPagination(
adminPage,
persona.data.name,
true,
3
);
await adminPage.getByRole('tab', { name: 'Customize UI' }).click();
await adminPage.waitForLoadState('networkidle');
await adminPage.getByText('Data Assets').click();

View File

@ -1117,11 +1117,12 @@ test.describe('User Profile Persona Interactions', () => {
await persona2OptionTestId.click();
const personaEditResponse = adminPage.waitForResponse('/api/v1/users/*');
// Save the changes
await adminPage
.locator('[data-testid="user-profile-persona-edit-save"]')
.click();
await adminPage.waitForResponse('/api/v1/users/*');
await personaEditResponse;
});
// Test adding default persona

View File

@ -38,14 +38,20 @@ type ResponseDataType = {
};
export class Domain extends EntityClass {
id: string;
data: ResponseDataType;
id: string = uuid();
data: ResponseDataType = {
name: `PW%domain.${this.id}`,
displayName: `PW Domain ${this.id}`,
description: 'playwright domain description',
domainType: 'Aggregate',
// eslint-disable-next-line no-useless-escape
fullyQualifiedName: `\"PW%domain.${this.id}\"`,
};
responseData: ResponseDataType = {} as ResponseDataType;
constructor(data?: ResponseDataType) {
super(EntityTypeEndpoint.Domain);
this.id = uuid();
this.data = data ?? {
name: `PW%domain.${this.id}`,
displayName: `PW Domain ${this.id}`,

View File

@ -112,3 +112,30 @@ export const removePersonaDefault = async (
await removeDefaultConfirmationModal.getByText('Yes').click();
await removeDefaultResponse;
};
export const navigateToPersonaWithPagination = async (
page: Page,
personaName: string,
click = true,
maxPages = 15
) => {
for (let currentPage = 0; currentPage < maxPages; currentPage++) {
const locator = page.getByTestId(`persona-details-card-${personaName}`);
// Check if element is visible on current page
if (await locator.isVisible()) {
if (click) {
await locator.click();
}
return;
}
const nextBtn = page.locator('[data-testid="next"]');
await nextBtn.waitFor({ state: 'visible' });
await nextBtn.click();
await page.waitForLoadState('networkidle');
}
};