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

Minor: Add playwright test for entity pages with users with different roles #17316

Merged
merged 25 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1081fb2
Add playwright test for a user with DataConsumer role
aniketkatkar97 Aug 6, 2024
65207f0
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 6, 2024
5f0ce3d
Add entity tests for Data Steward role
aniketkatkar97 Aug 6, 2024
457c887
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 6, 2024
daf539b
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 7, 2024
e340db3
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 7, 2024
9834e22
Merge remote-tracking branch 'origin/main' into rolebased-entity-tests
aniketkatkar97 Aug 8, 2024
823ab08
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 8, 2024
7f078f1
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 9, 2024
a4b09ce
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 9, 2024
d8e463c
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 10, 2024
6783c8a
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 10, 2024
fc2799a
Fix flaky playwright tests
aniketkatkar97 Aug 10, 2024
33feca9
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 10, 2024
d6b726f
Fix the playwright for owner actions
aniketkatkar97 Aug 11, 2024
a7e2fa4
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 11, 2024
120478e
playwright config change and minor fix
aniketkatkar97 Aug 11, 2024
4fbeb53
minor testing
ShaileshParmar11 Aug 12, 2024
28eb4f4
minor setting change
ShaileshParmar11 Aug 12, 2024
0ce6739
Merge branch 'main' into rolebased-entity-tests
ShaileshParmar11 Aug 12, 2024
847489a
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 13, 2024
19edd03
Worked improvement comments.
aniketkatkar97 Aug 13, 2024
5c2737d
Fix glossary spec flakiness with Assets count verification step `Rena…
aniketkatkar97 Aug 13, 2024
bd9136f
Merge branch 'main' into rolebased-entity-tests
aniketkatkar97 Aug 13, 2024
3f0faf0
Improved util function argument types
aniketkatkar97 Aug 13, 2024
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
5 changes: 3 additions & 2 deletions openmetadata-ui/src/main/resources/ui/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export default defineConfig({
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: process.env.CI ? 1 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 2 : undefined,
workers: process.env.CI ? 3 : undefined,
maxFailures: 30,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
['list'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* limitations under the License.
*/
import { test } from '@playwright/test';
import { isUndefined } from 'lodash';
import { CustomPropertySupportedEntityList } from '../../constant/customProperty';
import { ApiEndpointClass } from '../../support/entity/ApiEndpointClass';
import { ContainerClass } from '../../support/entity/ContainerClass';
Expand Down Expand Up @@ -113,6 +114,42 @@ entities.forEach((EntityClass) => {
);
});

// Run only if entity has children
if (!isUndefined(entity.childrenTabId)) {
test('Tag Add, Update and Remove for child entities', async ({
page,
}) => {
await page.getByTestId(entity.childrenTabId ?? '').click();

await entity.tagChildren({
page: page,
tag1: 'PersonalData.Personal',
tag2: 'PII.None',
rowId: entity.childrenSelectorId ?? '',
rowSelector:
entity.type === 'MlModel' ? 'data-testid' : 'data-row-key',
});
});
}

// Run only if entity has children
if (!isUndefined(entity.childrenTabId)) {
test('Glossary Term Add, Update and Remove for child entities', async ({
page,
}) => {
await page.getByTestId(entity.childrenTabId ?? '').click();

await entity.glossaryTermChildren({
page: page,
glossaryTerm1: EntityDataClass.glossaryTerm1.responseData,
glossaryTerm2: EntityDataClass.glossaryTerm2.responseData,
rowId: entity.childrenSelectorId ?? '',
rowSelector:
entity.type === 'MlModel' ? 'data-testid' : 'data-row-key',
});
});
}

test(`Announcement create & delete`, async ({ page }) => {
await entity.announcement(
page,
Expand Down Expand Up @@ -148,7 +185,7 @@ entities.forEach((EntityClass) => {

await test.step(`Set ${titleText} Custom Property`, async () => {
for (const type of properties) {
await entity.setCustomProperty(
await entity.updateCustomProperty(
page,
entity.customPropertyValue[type].property,
entity.customPropertyValue[type].value
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* 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, Page, test as base } from '@playwright/test';
import { isUndefined } from 'lodash';
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 { EntityDataClass } from '../../support/entity/EntityDataClass';
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 { UserClass } from '../../support/user/UserClass';
import { performAdminLogin } from '../../utils/admin';
import { redirectToHomePage } from '../../utils/common';

const user = new UserClass();

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

// Create 2 page and authenticate 1 with admin and another with normal user
const test = base.extend<{
page: Page;
}>({
page: async ({ browser }, use) => {
const page = await browser.newPage();
await user.login(page);
await use(page);
await page.close();
},
});

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

test.describe(entity.getType(), () => {
test.beforeAll('Setup pre-requests', async ({ browser }) => {
const { apiContext, afterAction } = await performAdminLogin(browser);

await user.create(apiContext);
await EntityDataClass.preRequisitesForTests(apiContext);
await entity.create(apiContext);
await afterAction();
});

test.beforeEach('Visit entity details page', async ({ page }) => {
await redirectToHomePage(page);
await entity.visitEntityPage(page);
});

test('User as Owner Add, Update and Remove', async ({ page }) => {
test.slow(true);

const OWNER1 = EntityDataClass.user1.getUserName();
const OWNER2 = EntityDataClass.user2.getUserName();
const OWNER3 = EntityDataClass.user3.getUserName();
await entity.owner(page, [OWNER1, OWNER3], [OWNER2], undefined, false);
});

test('No edit owner permission', async ({ page }) => {
await page.reload();
await page.waitForSelector('[data-testid="loader"]', {
state: 'detached',
});

await expect(page.getByTestId('edit-owner')).not.toBeAttached();
});

test('Tier Add, Update and Remove', async ({ page }) => {
await entity.tier(
page,
'Tier1',
EntityDataClass.tierTag1.data.displayName
);
});

test('Update description', async ({ page }) => {
await entity.descriptionUpdate(page);
});

test('Tag Add, Update and Remove', async ({ page }) => {
await entity.tag(page, 'PersonalData.Personal', 'PII.None');
});

test('Glossary Term Add, Update and Remove', async ({ page }) => {
await entity.glossaryTerm(
page,
EntityDataClass.glossaryTerm1.responseData,
EntityDataClass.glossaryTerm2.responseData
);
});

// Run only if entity has children
if (!isUndefined(entity.childrenTabId)) {
test('Tag Add, Update and Remove for child entities', async ({
page,
}) => {
await page.getByTestId(entity.childrenTabId ?? '').click();

await entity.tagChildren({
page,
tag1: 'PersonalData.Personal',
tag2: 'PII.None',
rowId: entity.childrenSelectorId ?? '',
rowSelector:
entity.type === 'MlModel' ? 'data-testid' : 'data-row-key',
});
});
}

// Run only if entity has children
if (!isUndefined(entity.childrenTabId)) {
test('Glossary Term Add, Update and Remove for child entities', async ({
page,
}) => {
await page.getByTestId(entity.childrenTabId ?? '').click();

await entity.glossaryTermChildren({
page,
glossaryTerm1: EntityDataClass.glossaryTerm1.responseData,
glossaryTerm2: EntityDataClass.glossaryTerm2.responseData,
rowId: entity.childrenSelectorId ?? '',
rowSelector:
entity.type === 'MlModel' ? 'data-testid' : 'data-row-key',
});
});
}

test(`UpVote & DownVote entity`, async ({ page }) => {
await entity.upVote(page);
await entity.downVote(page);
});

test(`Follow & Un-follow entity`, async ({ page }) => {
const entityName = entity.entityResponseData?.['displayName'];
await entity.followUnfollowEntity(page, entityName);
});

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