playwright: fixed failing aut test in main (#17818)

* playwright: fixed failing aut test in main

* fix myData spec failure

---------

Co-authored-by: Ashish Gupta <ashish@getcollate.io>
Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
Shailesh Parmar 2024-09-12 23:42:20 +05:30 committed by GitHub
parent 16e25bc469
commit fda7e1ecb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 77 additions and 61 deletions

View File

@ -14,8 +14,7 @@ import { expect, Page, test as base } from '@playwright/test';
import { TableClass } from '../../support/entity/TableClass';
import { UserClass } from '../../support/user/UserClass';
import { performAdminLogin } from '../../utils/admin';
import { redirectToHomePage } from '../../utils/common';
import { addMultiOwner, followEntity } from '../../utils/entity';
import { redirectToHomePage, removeLandingBanner } from '../../utils/common';
import { verifyEntities } from '../../utils/myData';
const user = new UserClass();
@ -38,6 +37,25 @@ test.describe('My Data page', () => {
await user.create(apiContext);
for (const table of TableEntities) {
await table.create(apiContext);
await table.patch({
apiContext,
patchData: [
{
op: 'add',
path: '/owners/0',
value: {
id: user.responseData.id,
type: 'user',
deleted: false,
displayName: user.responseData.displayName,
fullyQualifiedName: user.responseData.fullyQualifiedName,
href: user.responseData['href'] ?? '',
name: user.responseData.name,
},
},
],
});
await table.followTable(apiContext, user.responseData.id);
}
await afterAction();
});
@ -53,67 +71,40 @@ test.describe('My Data page', () => {
test.beforeEach('Visit entity details page', async ({ page }) => {
await redirectToHomePage(page);
await removeLandingBanner(page);
});
test('Verify MyData and Following widget', async ({ page }) => {
test.slow(true);
test('Verify my data widget', async ({ page }) => {
// Verify total count
await expect(
page.locator('[data-testid="my-data-total-count"]')
).toContainText('(20)');
await test.step(
'Set user as the Owner of the Table and also Follow it',
async () => {
for (const table of TableEntities) {
await table.visitEntityPage(page);
await addMultiOwner({
page,
ownerNames: [user.getUserName()],
activatorBtnDataTestId: 'edit-owner',
resultTestId: 'data-assets-header',
endpoint: table.endpoint,
type: 'Users',
});
await followEntity(page, table.endpoint);
}
}
await page
.locator('[data-testid="my-data-widget"] [data-testid="view-all-link"]')
.click();
// Verify entities
await verifyEntities(
page,
'/api/v1/search/query?q=*&index=all&from=0&size=25',
TableEntities
);
});
await test.step('Verify my data widget', async () => {
await redirectToHomePage(page);
// Verify total count
const totalCount = await page
.locator('[data-testid="my-data-total-count"]')
.innerText();
test('Verify following widget', async ({ page }) => {
// Verify total count
await expect(
page.locator('[data-testid="following-data-total-count"]')
).toContainText('(20)');
expect(totalCount).toBe('(20)');
await page.locator('[data-testid="following-data"]').click();
await page
.locator('[data-testid="my-data-widget"] [data-testid="view-all-link"]')
.click();
// Verify entities
await verifyEntities(
page,
'/api/v1/search/query?q=*&index=all&from=0&size=25',
TableEntities
);
});
await test.step('Verify following widget', async () => {
await redirectToHomePage(page);
// Verify total count
const totalCount = await page
.locator('[data-testid="following-data-total-count"]')
.innerText();
expect(totalCount).toBe('(20)');
await page.locator('[data-testid="following-data"]').click();
// Verify entities
await verifyEntities(
page,
'/api/v1/search/query?q=*followers:*&index=all&from=0&size=25',
TableEntities
);
});
// Verify entities
await verifyEntities(
page,
'/api/v1/search/query?q=*followers:*&index=all&from=0&size=25',
TableEntities
);
});
});

View File

@ -53,8 +53,6 @@ const permanentDeleteModal = async (page: Page, entity: string) => {
await page.click('[data-testid="confirm-button"]');
};
test.describe.configure({ mode: 'serial' });
// use the admin user to login
test.use({ storageState: 'playwright/.auth/admin.json' });
@ -77,6 +75,8 @@ test.beforeEach(async ({ page }) => {
});
test('Classification Page', async ({ page }) => {
test.slow();
await test.step('Should render basic elements on page', async () => {
const getTags = page.waitForResponse('/api/v1/tags*');
await sidebarClick(page, SidebarItem.TAGS);

View File

@ -55,6 +55,8 @@ test.beforeEach(async ({ page }) => {
});
test('Logical TestSuite', async ({ page }) => {
test.slow();
const NEW_TEST_SUITE = {
name: `mysql_matrix-${uuid()}`,
description: 'mysql critical matrix',

View File

@ -302,6 +302,18 @@ export class TableClass extends EntityClass {
};
}
async followTable(apiContext: APIRequestContext, userId: string) {
await apiContext.put(
`/api/v1/tables/${this.entityResponseData?.['id']}/followers`,
{
data: userId,
headers: {
'Content-Type': 'application/json',
},
}
);
}
async delete(apiContext: APIRequestContext) {
const serviceResponse = await apiContext.delete(
`/api/v1/services/databaseServices/name/${encodeURIComponent(

View File

@ -57,6 +57,12 @@ export const redirectToHomePage = async (page: Page) => {
await page.waitForURL('**/my-data');
};
export const removeLandingBanner = async (page: Page) => {
const widgetResponse = page.waitForResponse('/api/v1/search/query?q=**');
await page.click('[data-testid="welcome-screen-close-btn"]');
await widgetResponse;
};
export const createNewPage = async (browser: Browser) => {
// create a new page
const page = await browser.newPage();

View File

@ -19,8 +19,8 @@ export const verifyEntities = async (
tables: TableClass[]
) => {
// Change pagination size to 25
const fetchResponse = page.waitForResponse(url);
await page.locator('[data-testid="pagination"] .ant-btn-default').click();
const fetchResponse = page.waitForResponse(url);
await page.locator('[role="menu"] [value="25"]').click();
await fetchResponse;

View File

@ -245,6 +245,7 @@ const TestSuitePipelineTab = ({ testSuite }: Props) => {
pipelineIdToFetchStatus={pipelineIdToFetchStatus}
serviceCategory={ServiceCategory.DATABASE_SERVICES}
serviceName={getServiceFromTestSuiteFQN(testSuiteFQN)}
tableClassName="test-suite-pipeline-tab"
triggerIngestion={handleTriggerIngestion}
onIngestionWorkflowsUpdate={getAllIngestionWorkflows}
/>

View File

@ -55,4 +55,5 @@ export interface IngestionListTableProps {
text: string,
record: IngestionPipeline
) => ReactNode;
tableClassName?: string;
}

View File

@ -79,6 +79,7 @@ function IngestionListTable({
showDescriptionCol,
triggerIngestion,
customRenderNameField,
tableClassName,
}: Readonly<IngestionListTableProps>) {
const { t } = useTranslation();
const { theme } = useApplicationStore();
@ -333,6 +334,7 @@ function IngestionListTable({
<Col span={24}>
<Table
bordered
className={tableClassName}
columns={tableColumn}
data-testid="ingestion-list-table"
dataSource={ingestionData}

View File

@ -808,7 +808,8 @@ a[href].link-text-grey,
// Right side padding 20 + 64 width of sidebar
margin-right: 84px;
}
.test-case-table-container {
.test-case-table-container,
.test-suite-pipeline-tab {
margin-right: 64px;
}