Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrate recently viewed spec to playwright #17741

Merged
merged 7 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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 { expect, test } from '@playwright/test';
import { ApiEndpointClass } from '../../support/entity/ApiEndpointClass';
import { ContainerClass } from '../../support/entity/ContainerClass';
import { DashboardClass } from '../../support/entity/DashboardClass';
import { DashboardDataModelClass } from '../../support/entity/DashboardDataModelClass';
import { MlModelClass } from '../../support/entity/MlModelClass';
import { PipelineClass } from '../../support/entity/PipelineClass';
import { SearchIndexClass } from '../../support/entity/SearchIndexClass';
import { StoredProcedureClass } from '../../support/entity/StoredProcedureClass';
import { TableClass } from '../../support/entity/TableClass';
import { TopicClass } from '../../support/entity/TopicClass';
import { createNewPage, redirectToHomePage } from '../../utils/common';

const entities = [
new ApiEndpointClass(),
new TableClass(),
new StoredProcedureClass(),
new DashboardClass(),
new PipelineClass(),
new TopicClass(),
new MlModelClass(),
new ContainerClass(),
new SearchIndexClass(),
new DashboardDataModelClass(),
] as const;

// use the admin user to login
test.use({ storageState: 'playwright/.auth/admin.json' });

test.describe('Recently viewed data assets', () => {
test.beforeEach(async ({ page }) => {
await redirectToHomePage(page);
});

test.beforeAll(async ({ browser }) => {
const { afterAction, apiContext } = await createNewPage(browser);
for await (const entity of entities) {
await entity.create(apiContext);
}
await afterAction();
});

test.afterAll(async ({ browser }) => {
const { afterAction, apiContext } = await createNewPage(browser);
for await (const entity of entities) {
await entity.delete(apiContext);
}
await afterAction();
});

test('Recently viewed widget should be visible on the home page', async ({
page,
}) => {
test.slow(true);

for await (const entity of entities) {
await test.step(
`Check ${entity.getType()} in recently viewed widget `,
async () => {
await entity.visitEntityPage(page);

await page.waitForSelector(`[data-testid="breadcrumb"]`);

await redirectToHomePage(page);

await page.waitForSelector(`[data-testid="recently-viewed-widget"]`);

const selector = `[data-testid="recently-viewed-widget"] [title="${entity.entity.name}"]`;

await expect(page.locator(selector)).toBeVisible();
}
);
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { EntityTypeEndpoint } from './Entity.interface';
import { EntityClass } from './EntityClass';

export class ContainerClass extends EntityClass {
private containerName = `pw-container-${uuid()}`;
service = {
name: `pw-storage-service-${uuid()}`,
serviceType: 'S3',
Expand All @@ -35,8 +36,8 @@ export class ContainerClass extends EntityClass {
},
};
entity = {
name: `pw-container-${uuid()}`,
displayName: `pw-container-${uuid()}`,
name: this.containerName,
displayName: this.containerName,
service: this.service.name,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { EntityTypeEndpoint } from './Entity.interface';
import { EntityClass } from './EntityClass';

export class DashboardClass extends EntityClass {
private dashboardName = `pw-dashboard-${uuid()}`;
service = {
name: `pw-dashboard-service-${uuid()}`,
serviceType: 'Superset',
Expand All @@ -40,8 +41,8 @@ export class DashboardClass extends EntityClass {
service: this.service.name,
};
entity = {
name: `pw-dashboard-${uuid()}`,
displayName: `pw-dashboard-${uuid()}`,
name: this.dashboardName,
displayName: this.dashboardName,
service: this.service.name,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { EntityTypeEndpoint } from './Entity.interface';
import { EntityClass } from './EntityClass';

export class DashboardDataModelClass extends EntityClass {
private dashboardDataModelName = `pw-dashboard-data-model-${uuid()}`;
service = {
name: `pw-dashboard-service-${uuid()}`,
serviceType: 'Superset',
Expand Down Expand Up @@ -46,8 +47,8 @@ export class DashboardDataModelClass extends EntityClass {
];

entity = {
name: `pw-dashboard-data-model-${uuid()}`,
displayName: `pw-dashboard-data-model-${uuid()}`,
name: this.dashboardDataModelName,
displayName: this.dashboardDataModelName,
service: this.service.name,
columns: this.children,
dataModelType: 'SupersetDataModel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ResponseDataType = {
};

export class MlModelClass extends EntityClass {
private mlModelName = `pw-mlmodel-${uuid()}`;
service = {
name: `pw-ml-model-service-${uuid()}`,
serviceType: 'Mlflow',
Expand All @@ -49,8 +50,8 @@ export class MlModelClass extends EntityClass {
];

entity = {
name: `pw-mlmodel-${uuid()}`,
displayName: `pw-mlmodel-${uuid()}`,
name: this.mlModelName,
displayName: this.mlModelName,
service: this.service.name,
algorithm: 'Time Series',
mlFeatures: this.children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { EntityTypeEndpoint } from './Entity.interface';
import { EntityClass } from './EntityClass';

export class PipelineClass extends EntityClass {
private pipelineName = `pw-pipeline-${uuid()}`;
service = {
name: `pw-pipeline-service-${uuid()}`,
serviceType: 'Dagster',
Expand All @@ -35,8 +36,8 @@ export class PipelineClass extends EntityClass {
children = [{ name: 'snowflake_task' }];

entity = {
name: `pw-pipeline-${uuid()}`,
displayName: `pw-pipeline-${uuid()}`,
name: this.pipelineName,
displayName: this.pipelineName,
service: this.service.name,
tasks: this.children,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class SearchIndexClass extends EntityClass {

entity = {
name: this.searchIndexName,
displayName: `pw-search-index-${uuid()}`,
displayName: this.searchIndexName,
service: this.service.name,
fields: this.children,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from '../../context/PermissionProvider/PermissionProvider.interface';
import { ClientErrors } from '../../enums/Axios.enum';
import { ERROR_PLACEHOLDER_TYPE } from '../../enums/common.enum';
import { TabSpecificField } from '../../enums/entity.enum';
import { EntityType, TabSpecificField } from '../../enums/entity.enum';
import { CreateThread } from '../../generated/api/feed/createThread';
import { Tag } from '../../generated/entity/classification/tag';
import { DashboardDataModel } from '../../generated/entity/data/dashboardDataModel';
Expand All @@ -53,10 +53,12 @@ import {
} from '../../rest/dataModelsAPI';
import { postThread } from '../../rest/feedsAPI';
import {
addToRecentViewed,
getEntityMissingError,
sortTagsCaseInsensitive,
} from '../../utils/CommonUtils';
import { getSortedDataModelColumnTags } from '../../utils/DataModelsUtils';
import { getEntityName } from '../../utils/EntityUtils';
import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils';
import { getTierTags } from '../../utils/TableUtils';
import { updateTierTag } from '../../utils/TagsUtils';
Expand Down Expand Up @@ -134,6 +136,15 @@ const DataModelsPage = () => {
include: Include.All,
});
setDataModelData(response);

addToRecentViewed({
displayName: getEntityName(response),
entityType: EntityType.DASHBOARD_DATA_MODEL,
fqn: response.fullyQualifiedName ?? '',
serviceType: response.serviceType,
timestamp: 0,
id: response.id,
});
} catch (error) {
showErrorToast(error as AxiosError);
setHasError(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jest.mock('../../rest/feedsAPI', () => ({
}));

jest.mock('../../utils/CommonUtils', () => ({
addToRecentViewed: jest.fn(),
getEntityMissingError: jest.fn(() => ENTITY_MISSING_ERROR),
sortTagsCaseInsensitive: jest.fn((tags) => tags),
}));
Expand Down
Loading