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

playwright: migrate announcement, rename, soft delete and hard delete test #16542

Merged
merged 3 commits into from
Jun 5, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.
*/
export const LIST_OF_FIELDS_TO_EDIT_NOT_TO_BE_PRESENT = [
{
containerSelector: '[data-testid="header-domain-container"]',
elementSelector: '[data-testid="add-domain"]',
},
{
containerSelector: '[data-testid="owner-label"]',
elementSelector: '[data-testid="edit-owner"]',
},
{
containerSelector: '[data-testid="header-tier-container"]',
elementSelector: '[data-testid="edit-tier"]',
},
{
containerSelector: '[data-testid="asset-description-container"]',
elementSelector: '[data-testid="edit-description"]',
},
{
containerSelector:
'[data-testid="entity-right-panel"] [data-testid="tags-container"]',
elementSelector: '[data-testid="add-tag"]',
},
{
containerSelector:
'[data-testid="entity-right-panel"] [data-testid="glossary-container"]',
elementSelector: '[data-testid="add-tag"]',
},
];

export const LIST_OF_FIELDS_TO_EDIT_TO_BE_DISABLED = [
{
containerSelector: '[data-testid="asset-header-btn-group"]',
elementSelector: '[data-testid="up-vote-btn"]',
},
{
containerSelector: '[data-testid="asset-header-btn-group"]',
elementSelector: '[data-testid="down-vote-btn"]',
},
{
containerSelector: '[data-testid="asset-header-btn-group"]',
elementSelector: '[data-testid="entity-follow-button"]',
},
];

export const ENTITIES_WITHOUT_FOLLOWING_BUTTON = [
'databases',
'databaseSchemas',
'services/databaseServices',
'services/messagingServices',
'services/pipelineServices',
'services/dashboardServices',
'services/mlmodelServices',
'services/storageServices',
'services/metadataServices',
'services/searchServices',
];
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,30 @@ import { MlModelClass } from '../../support/entity/MlModelClass';
import { PipelineClass } from '../../support/entity/PipelineClass';
import { SearchIndexClass } from '../../support/entity/SearchIndexClass';
import { TopicClass } from '../../support/entity/TopicClass';
import { createNewPage, redirectToHomePage } from '../../utils/common';
import {
createNewPage,
getAuthContext,
getToken,
redirectToHomePage,
} from '../../utils/common';

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

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

entities.forEach((entity) => {
entities.forEach((EntityClass) => {
const entity = new EntityClass();
const deleteEntity = new EntityClass();

test.describe(entity.getType(), () => {
test.beforeAll('Setup pre-requests', async ({ browser }) => {
const { apiContext, afterAction } = await createNewPage(browser);
Expand Down Expand Up @@ -89,6 +97,17 @@ entities.forEach((entity) => {
);
});

test(`Announcement create & delete`, async ({ page }) => {
await entity.announcement(
page,
entity.entityResponseData?.['fullyQualifiedName']
);
});

test(`Inactive Announcement create & delete`, async ({ page }) => {
await entity.inactiveAnnouncement(page);
});

test(`UpVote & DownVote entity`, async ({ page }) => {
await entity.upVote(page);
await entity.downVote(page);
Expand All @@ -99,11 +118,43 @@ entities.forEach((entity) => {
await entity.followUnfollowEntity(page, entityName);
});

test(`Update displayName`, async ({ page }) => {
await entity.renameEntity(page, entity.entity.name);
});

test.afterAll('Cleanup', async ({ browser }) => {
const { apiContext, afterAction } = await createNewPage(browser);
await entity.delete(apiContext);
await EntityDataClass.postRequisitesForTests(apiContext);
await afterAction();
});
});

test(`Delete ${deleteEntity.getType()}`, async ({ page }) => {
await redirectToHomePage(page);
// get the token from localStorage
const token = await getToken(page);

// create a new context with the token
const apiContext = await getAuthContext(token);
await deleteEntity.create(apiContext);
await redirectToHomePage(page);
await deleteEntity.visitEntityPage(page);

await test.step('Soft delete', async () => {
await deleteEntity.softDeleteEntity(
page,
deleteEntity.entity.name,
deleteEntity.entityResponseData?.['displayName']
);
});

await test.step('Hard delete', async () => {
await deleteEntity.hardDeleteEntity(
page,
deleteEntity.entity.name,
deleteEntity.entityResponseData?.['displayName']
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ import {
assignGlossaryTerm,
assignTag,
assignTier,
createAnnouncement,
createInactiveAnnouncement,
deleteAnnouncement,
downVote,
followEntity,
hardDeleteEntity,
removeGlossaryTerm,
removeOwner,
removeTag,
removeTier,
replyAnnouncement,
softDeleteEntity,
unFollowEntity,
updateDescription,
updateDisplayNameForEntity,
updateOwner,
upVote,
validateFollowedEntityToWidget,
Expand Down Expand Up @@ -132,4 +139,42 @@ export class EntityClass {
await unFollowEntity(page, this.endpoint);
await validateFollowedEntityToWidget(page, entity, false);
}

async announcement(page: Page, entityFqn: string) {
await createAnnouncement(page, entityFqn, {
title: 'Playwright Test Announcement',
description: 'Playwright Test Announcement Description',
});
await replyAnnouncement(page);
await deleteAnnouncement(page);
}

async inactiveAnnouncement(page: Page) {
await createInactiveAnnouncement(page, {
title: 'Inactive Playwright announcement',
description: 'Inactive Playwright announcement description',
});
await deleteAnnouncement(page);
}

async renameEntity(page: Page, entityName: string) {
await updateDisplayNameForEntity(
page,
`Cypress ${entityName} updated`,
this.endpoint
);
}

async softDeleteEntity(page: Page, entityName: string, displayName?: string) {
await softDeleteEntity(
page,
entityName,
this.endpoint,
displayName ?? entityName
);
}

async hardDeleteEntity(page: Page, entityName: string, displayName?: string) {
await hardDeleteEntity(page, displayName ?? entityName, this.endpoint);
}
}
Loading
Loading