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(e2e): Explore page tests #19074

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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,29 @@
/*
* 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 EXPECTED_BUCKETS = [
'table',
pranita09 marked this conversation as resolved.
Show resolved Hide resolved
'databaseSchema',
'chart',
'storedProcedure',
'database',
'pipeline',
'dashboard',
'container',
'tag',
'dashboardDataModel',
'apiEndpoint',
'topic',
'apiCollection',
'searchIndex',
'mlmodel',
];
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@
import test, { expect } from '@playwright/test';
import { get } from 'lodash';
import { SidebarItem } from '../../constant/sidebar';
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 { EntityTypeEndpoint } from '../../support/entity/Entity.interface';
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 { getApiContext, redirectToHomePage } from '../../utils/common';
import { updateDisplayNameForEntity } from '../../utils/entity';
import { validateBucketsForIndex } from '../../utils/explore';
import { sidebarClick } from '../../utils/sidebar';

// use the admin user to login
Expand Down Expand Up @@ -192,6 +202,47 @@ test.describe('Explore Tree scenarios ', () => {
});

test.describe('Explore page', () => {
const table = new TableClass();
const dashboard = new DashboardClass();
const storedProcedure = new StoredProcedureClass();
const pipeline = new PipelineClass();
const container = new ContainerClass();
const apiEndpoint = new ApiEndpointClass();
const topic = new TopicClass();
const searchIndex = new SearchIndexClass();
const dashboardDataModel = new DashboardDataModelClass();
const mlModel = new MlModelClass();
pranita09 marked this conversation as resolved.
Show resolved Hide resolved

test.beforeEach('Setup pre-requisits', async ({ page }) => {
const { apiContext, afterAction } = await getApiContext(page);
await table.create(apiContext);
await dashboard.create(apiContext);
await storedProcedure.create(apiContext);
await pipeline.create(apiContext);
await container.create(apiContext);
await apiEndpoint.create(apiContext);
await topic.create(apiContext);
await searchIndex.create(apiContext);
await dashboardDataModel.create(apiContext);
await mlModel.create(apiContext);
await afterAction();
});

test.afterEach('Cleanup', async ({ page }) => {
const { apiContext, afterAction } = await getApiContext(page);
await table.delete(apiContext);
await dashboard.delete(apiContext);
await storedProcedure.delete(apiContext);
await pipeline.delete(apiContext);
await container.delete(apiContext);
await apiEndpoint.delete(apiContext);
await topic.delete(apiContext);
await searchIndex.delete(apiContext);
await dashboardDataModel.delete(apiContext);
await mlModel.delete(apiContext);
await afterAction();
});

test('Check the listing of tags', async ({ page }) => {
await page
.locator('div')
Expand All @@ -214,4 +265,14 @@ test.describe('Explore page', () => {

expect(jsonResponse.hits.hits.length).toBeGreaterThan(0);
});

test('Check listing of entities when index is dataAsset', async ({
page,
}) => {
await validateBucketsForIndex(page, 'dataAsset');
});

test('Check listing of entities when index is all', async ({ page }) => {
await validateBucketsForIndex(page, 'all');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
*/
import { expect } from '@playwright/test';
import { Page } from 'playwright';
import { EXPECTED_BUCKETS } from '../constant/explore';
import { getApiContext } from './common';

export interface Bucket {
key: string;
doc_count: number;
}

export const searchAndClickOnOption = async (
page: Page,
Expand Down Expand Up @@ -116,3 +123,36 @@ export const selectDataAssetFilter = async (
await page.getByTestId(`${filterValue}-checkbox`).check();
await page.getByTestId('update-btn').click();
};

export const validateBucketsForIndex = async (page: Page, index: string) => {
const { apiContext } = await getApiContext(page);

return await expect
.poll(
pranita09 marked this conversation as resolved.
Show resolved Hide resolved
async () => {
const response = await apiContext
.get(
`/api/v1/search/query?q=&index=${index}&from=0&size=10&deleted=false&query_filter=%7B%22query%22:%7B%22bool%22:%7B%7D%7D%7D&sort_field=totalVotes&sort_order=desc`
)
.then((res) => res.json());

const buckets =
response.aggregations?.['sterms#entityType']?.buckets || [];

// Check if each key in expectedBuckets has a doc_count > 0
const validBuckets = EXPECTED_BUCKETS.every((expectedKey) => {
const bucket = buckets.find((b: Bucket) => b.key === expectedKey);

return bucket ? bucket.doc_count > 0 : false;
});

return validBuckets;
},
{
message: `Waiting for the expected buckets with doc_count > 0 for index "${index}"`,
timeout: 350_000,
intervals: [40_000, 30_000],
}
)
.toBe(true);
};
Loading