mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-11-03 20:19:31 +00:00 
			
		
		
		
	fix schema table playwright test (#22918)
This commit is contained in:
		
							parent
							
								
									851ed11fb1
								
							
						
					
					
						commit
						a0b05dacf4
					
				@ -13,49 +13,17 @@
 | 
			
		||||
import { expect, Page } from '@playwright/test';
 | 
			
		||||
import { test } from '../fixtures/pages';
 | 
			
		||||
 | 
			
		||||
import { get } from 'lodash';
 | 
			
		||||
import { EntityTypeEndpoint } from '../../support/entity/Entity.interface';
 | 
			
		||||
import { TableClass } from '../../support/entity/TableClass';
 | 
			
		||||
import { performAdminLogin } from '../../utils/admin';
 | 
			
		||||
import { redirectToHomePage } from '../../utils/common';
 | 
			
		||||
import {
 | 
			
		||||
  addOwner,
 | 
			
		||||
  updateDisplayNameForEntityChildren,
 | 
			
		||||
} from '../../utils/entity';
 | 
			
		||||
 | 
			
		||||
test.beforeEach(
 | 
			
		||||
  async ({ editDescriptionPage, editTagsPage, editGlossaryTermPage }) => {
 | 
			
		||||
    await redirectToHomePage(editDescriptionPage);
 | 
			
		||||
    await redirectToHomePage(editTagsPage);
 | 
			
		||||
    await redirectToHomePage(editGlossaryTermPage);
 | 
			
		||||
  }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
// Setup owner for the table
 | 
			
		||||
test.beforeAll(async ({ ownerPage, page }) => {
 | 
			
		||||
  // Get logged in user
 | 
			
		||||
  const loggedInUserRequest = ownerPage.waitForResponse(
 | 
			
		||||
    `/api/v1/users/loggedInUser*`
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  await redirectToHomePage(ownerPage);
 | 
			
		||||
  const loggedInUserResponse = await loggedInUserRequest;
 | 
			
		||||
  const loggedInUser = await loggedInUserResponse.json();
 | 
			
		||||
 | 
			
		||||
  // User admin page to assign owner to the table
 | 
			
		||||
  await page.goto(
 | 
			
		||||
    '/table/sample_data.ecommerce_db.shopify.performance_test_table'
 | 
			
		||||
  );
 | 
			
		||||
  await page.waitForLoadState('networkidle');
 | 
			
		||||
 | 
			
		||||
  await addOwner({
 | 
			
		||||
    page,
 | 
			
		||||
    owner: loggedInUser.displayName,
 | 
			
		||||
    type: 'Users',
 | 
			
		||||
    endpoint: EntityTypeEndpoint.Table,
 | 
			
		||||
    dataTestId: 'data-assets-header',
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  await page.close();
 | 
			
		||||
  await ownerPage.close();
 | 
			
		||||
});
 | 
			
		||||
const table = new TableClass();
 | 
			
		||||
 | 
			
		||||
const crudColumnDisplayName = async (
 | 
			
		||||
  page: Page,
 | 
			
		||||
@ -64,7 +32,7 @@ const crudColumnDisplayName = async (
 | 
			
		||||
  rowSelector: string
 | 
			
		||||
) => {
 | 
			
		||||
  const searchResponse = page.waitForResponse(
 | 
			
		||||
    `/api/v1/tables/name/sample_data.ecommerce_db.shopify.performance_test_table/columns/search?q=${columnName}&limit=50&offset=0&fields=tags%2CcustomMetrics&include=all`
 | 
			
		||||
    `/api/v1/tables/name/*/columns/search?q=${columnName}&**`
 | 
			
		||||
  );
 | 
			
		||||
  await page.getByTestId('searchbar').fill(columnName);
 | 
			
		||||
  await searchResponse;
 | 
			
		||||
@ -104,26 +72,79 @@ const crudColumnDisplayName = async (
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
test.beforeEach(
 | 
			
		||||
  async ({ editDescriptionPage, editTagsPage, editGlossaryTermPage }) => {
 | 
			
		||||
    await redirectToHomePage(editDescriptionPage);
 | 
			
		||||
    await redirectToHomePage(editTagsPage);
 | 
			
		||||
    await redirectToHomePage(editGlossaryTermPage);
 | 
			
		||||
  }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
test.beforeAll(async ({ browser }) => {
 | 
			
		||||
  const { apiContext, afterAction } = await performAdminLogin(browser);
 | 
			
		||||
  await table.create(apiContext);
 | 
			
		||||
  await afterAction();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test.afterAll('Cleanup', async ({ browser }) => {
 | 
			
		||||
  const { apiContext, afterAction } = await performAdminLogin(browser);
 | 
			
		||||
  await table.delete(apiContext);
 | 
			
		||||
 | 
			
		||||
  await afterAction();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test('schema table test', async ({ dataStewardPage, ownerPage, page }) => {
 | 
			
		||||
  test.slow();
 | 
			
		||||
 | 
			
		||||
  const pages = [dataStewardPage, page, ownerPage];
 | 
			
		||||
  const tableUrl =
 | 
			
		||||
    '/table/sample_data.ecommerce_db.shopify.performance_test_table';
 | 
			
		||||
  const columnFqn =
 | 
			
		||||
    'sample_data.ecommerce_db.shopify.performance_test_table.test_col_2000';
 | 
			
		||||
  const columnName = 'test_col_2000';
 | 
			
		||||
 | 
			
		||||
  for (const currentPage of pages) {
 | 
			
		||||
    await currentPage.goto(tableUrl);
 | 
			
		||||
    await currentPage.waitForLoadState('networkidle');
 | 
			
		||||
    await crudColumnDisplayName(
 | 
			
		||||
      currentPage,
 | 
			
		||||
      columnFqn,
 | 
			
		||||
      columnName,
 | 
			
		||||
      'data-row-key'
 | 
			
		||||
  await test.step('set owner', async () => {
 | 
			
		||||
    const loggedInUserRequest = ownerPage.waitForResponse(
 | 
			
		||||
      `/api/v1/users/loggedInUser*`
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
    await redirectToHomePage(ownerPage);
 | 
			
		||||
    const loggedInUserResponse = await loggedInUserRequest;
 | 
			
		||||
    const loggedInUser = await loggedInUserResponse.json();
 | 
			
		||||
 | 
			
		||||
    await redirectToHomePage(page);
 | 
			
		||||
 | 
			
		||||
    await table.visitEntityPage(page);
 | 
			
		||||
    await page.waitForLoadState('networkidle');
 | 
			
		||||
    await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
 | 
			
		||||
 | 
			
		||||
    await addOwner({
 | 
			
		||||
      page,
 | 
			
		||||
      owner: loggedInUser.displayName,
 | 
			
		||||
      type: 'Users',
 | 
			
		||||
      endpoint: EntityTypeEndpoint.Table,
 | 
			
		||||
      dataTestId: 'data-assets-header',
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  await test.step('set the description', async () => {
 | 
			
		||||
    const pages = [dataStewardPage, page, ownerPage];
 | 
			
		||||
 | 
			
		||||
    const columnFqn = get(
 | 
			
		||||
      table,
 | 
			
		||||
      'entityResponseData.columns[2].fullyQualifiedName'
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const columnName = table.columnsName[2];
 | 
			
		||||
 | 
			
		||||
    for (const currentPage of pages) {
 | 
			
		||||
      await redirectToHomePage(currentPage);
 | 
			
		||||
 | 
			
		||||
      await table.visitEntityPage(currentPage);
 | 
			
		||||
      await currentPage.waitForLoadState('networkidle');
 | 
			
		||||
      await page.waitForSelector('[data-testid="loader"]', {
 | 
			
		||||
        state: 'detached',
 | 
			
		||||
      });
 | 
			
		||||
      await crudColumnDisplayName(
 | 
			
		||||
        currentPage,
 | 
			
		||||
        columnFqn,
 | 
			
		||||
        columnName,
 | 
			
		||||
        'data-row-key'
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test('Schema Table Pagination should work Properly', async ({ page }) => {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user