Minor: fixed AUT test of main (#17293)

This commit is contained in:
Shailesh Parmar 2024-08-06 10:37:04 +05:30 committed by GitHub
parent 40009dbeae
commit e97300dc5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 122 additions and 48 deletions

View File

@ -149,6 +149,9 @@ export const triggerTestCasePipeline = ({
verifyResponseStatusCode('@waitForPageLoad', 200);
cy.get('[data-testid="profiler"]').should('be.visible').click();
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Table Profile')
.click();
interceptURL(
'GET',

View File

@ -99,12 +99,12 @@ const createCustomMetric = ({
});
// Click on create custom metric button
cy.get('[data-testid="profiler"]').click();
verifyResponseStatusCode('@getCustomMetric', 200);
if (isColumnMetric) {
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Column Profile')
.click();
}
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains(isColumnMetric ? 'Column Profile' : 'Table Profile')
.click();
cy.get('[data-testid="profiler-add-table-test-btn"]').click();
cy.get('[data-testid="custom-metric"]').click();
@ -175,11 +175,12 @@ const editCustomMetric = ({
entity,
});
cy.get('[data-testid="profiler"]').click();
verifyResponseStatusCode('@getCustomMetric', 200);
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains(isColumnMetric ? 'Column Profile' : 'Table Profile')
.click();
if (isColumnMetric) {
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Column Profile')
.click();
metric.column &&
cy.get('[data-row-key="user_id"]').contains(metric.column).click();
}
@ -229,11 +230,12 @@ const deleteCustomMetric = ({
entity,
});
cy.get('[data-testid="profiler"]').click();
verifyResponseStatusCode('@getCustomMetric', 200);
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains(isColumnMetric ? 'Column Profile' : 'Table Profile')
.click();
if (isColumnMetric) {
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Column Profile')
.click();
metric.column &&
cy.get('[data-row-key="user_id"]').contains(metric.column).click();
}

View File

@ -48,6 +48,9 @@ const goToProfilerTab = () => {
verifyResponseStatusCode('@waitForPageLoad', 200);
cy.get('[data-testid="profiler"]').should('be.visible').click();
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Table Profile')
.click();
};
const acknowledgeTask = (testCase: string) => {

View File

@ -40,8 +40,10 @@ const queryTable = {
};
const table1 = generateRandomTable();
const table2 = generateRandomTable();
const user = generateRandomUser();
let userId = '';
const user1 = generateRandomUser();
const user2 = generateRandomUser();
const owner = `${user2.firstName}${user2.lastName}`;
const userIds: string[] = [];
const DATA = {
...queryTable,
@ -92,9 +94,17 @@ describe('Query Entity', { tags: 'DataAssets' }, () => {
method: 'POST',
url: `/api/v1/users/signup`,
headers: { Authorization: `Bearer ${token}` },
body: user,
body: user1,
}).then((response) => {
userId = response.body.id;
userIds.push(response.body.id);
});
cy.request({
method: 'POST',
url: `/api/v1/users/signup`,
headers: { Authorization: `Bearer ${token}` },
body: user2,
}).then((response) => {
userIds.push(response.body.id);
});
});
});
@ -111,10 +121,12 @@ describe('Query Entity', { tags: 'DataAssets' }, () => {
});
// Delete created user
cy.request({
method: 'DELETE',
url: `/api/v1/users/${userId}?hardDelete=true&recursive=false`,
headers: { Authorization: `Bearer ${token}` },
userIds.forEach((userId) => {
cy.request({
method: 'DELETE',
url: `/api/v1/users/${userId}?hardDelete=true&recursive=false`,
headers: { Authorization: `Bearer ${token}` },
});
});
});
});
@ -184,17 +196,13 @@ describe('Query Entity', { tags: 'DataAssets' }, () => {
cy.get(':nth-child(2) > [data-testid="edit-owner"]').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get('[data-testid="loader"]').should('not.exist');
interceptURL(
'GET',
`api/v1/search/query?q=*${encodeURI(DATA.owner)}*`,
'searchOwner'
);
cy.get('[data-testid="owner-select-users-search-bar"]').type(DATA.owner);
interceptURL('GET', `api/v1/search/query?q=*`, 'searchOwner');
cy.get('[data-testid="owner-select-users-search-bar"]').type(owner);
verifyResponseStatusCode('@searchOwner', 200);
cy.get(`.ant-popover [title="${DATA.owner}"]`).click();
cy.get(`.ant-popover [title="${owner}"]`).click();
cy.get('[data-testid="selectable-list-update-btn"]').click();
verifyResponseStatusCode('@patchQuery', 200);
cy.get('[data-testid="owner-link"]').should('contain', DATA.owner);
cy.get('[data-testid="owner-link"]').should('contain', owner);
// Update Description
cy.get('[data-testid="edit-description"]').filter(':visible').click();
@ -218,7 +226,7 @@ describe('Query Entity', { tags: 'DataAssets' }, () => {
});
cy.get('[data-testid="table_queries"]').click();
verifyResponseStatusCode('@fetchQuery', 200);
const userName = `${user.firstName}${user.lastName}`;
const userName = `${user1.firstName}${user1.lastName}`;
interceptURL(
'GET',
`/api/v1/search/query?*${encodeURI(
@ -227,20 +235,20 @@ describe('Query Entity', { tags: 'DataAssets' }, () => {
'searchUserName'
);
queryFilters({
filter: `${user.firstName}${user.lastName}`,
filter: `${user1.firstName}${user1.lastName}`,
apiKey: '@searchUserName',
key: 'Owner',
});
interceptURL(
'GET',
`/api/v1/search/query?*${encodeURI(
DATA.owner
owner
)}*index=user_search_index,team_search_index*`,
'searchOwner'
);
cy.get('[data-testid="no-data-placeholder"]').should('be.visible');
queryFilters({
filter: DATA.owner,
filter: owner,
apiKey: '@searchOwner',
key: 'Owner',
});

View File

@ -77,6 +77,9 @@ const goToProfilerTab = (data?: { service: string; entityName: string }) => {
verifyResponseStatusCode('@waitForPageLoad', 200);
cy.get('[data-testid="profiler"]').should('be.visible').click();
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Table Profile')
.click();
};
const visitTestSuiteDetailsPage = (testSuiteName: string) => {
@ -688,6 +691,9 @@ describe(
.should('be.visible');
cy.get('[data-testid="profiler"]').should('be.visible').click();
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Table Profile')
.click();
interceptURL(
'GET',
'/api/v1/tables/*/columnProfile?*',
@ -1210,6 +1216,9 @@ describe(
entity: EntityType.Table,
});
cy.get('[data-testid="profiler"]').should('be.visible').click();
cy.get('[data-testid="profiler-tab-left-panel"]')
.contains('Table Profile')
.click();
verifyResponseStatusCode('@tableProfiler', 200);
verifyResponseStatusCode('@systemProfiler', 200);
cy.get('[data-testid="profiler-setting-btn"]').click();

View File

@ -0,0 +1,18 @@
/*
* 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 JWT_EXPIRY_TIME_MAP = {
'1 hour': 3600,
'2 hours': 7200,
'3 hours': 10800,
'4 hours': 14400,
};

View File

@ -11,7 +11,10 @@
* limitations under the License.
*/
import { test as setup } from '@playwright/test';
import { JWT_EXPIRY_TIME_MAP } from '../constant/login';
import { AdminClass } from '../support/user/AdminClass';
import { getApiContext } from '../utils/common';
import { updateJWTTokenExpiryTime } from '../utils/login';
const adminFile = 'playwright/.auth/admin.json';
setup('authenticate as admin', async ({ page }) => {
@ -20,6 +23,9 @@ setup('authenticate as admin', async ({ page }) => {
// login with admin user
await admin.login(page);
await page.waitForURL('**/my-data');
const { apiContext, afterAction } = await getApiContext(page);
await updateJWTTokenExpiryTime(apiContext, JWT_EXPIRY_TIME_MAP['4 hours']);
await afterAction();
// End of authentication steps.
await page.context().storageState({ path: adminFile });

View File

@ -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.
*/
import { APIRequestContext } from '@playwright/test';
export const updateJWTTokenExpiryTime = async (
apiContext: APIRequestContext,
expiryTime: number
) => {
await apiContext.put('/api/v1/system/settings', {
data: {
config_type: 'loginConfiguration',
config_value: {
maxLoginFailAttempts: 3,
accessBlockTime: 600,
jwtTokenExpiryTime: expiryTime,
},
},
});
};

View File

@ -100,23 +100,19 @@ const AddCustomMetricPage = () => {
);
const handleBackClick = () => {
if (isColumnMetric) {
history.push({
pathname: getEntityDetailsPath(
EntityType.TABLE,
entityFqn,
EntityTabs.PROFILER
),
search: QueryString.stringify({
activeTab: TableProfilerTab.COLUMN_PROFILE,
activeColumnFqn,
}),
});
} else {
history.push(
getEntityDetailsPath(EntityType.TABLE, entityFqn, EntityTabs.PROFILER)
);
}
history.push({
pathname: getEntityDetailsPath(
EntityType.TABLE,
entityFqn,
EntityTabs.PROFILER
),
search: QueryString.stringify({
activeTab: isColumnMetric
? TableProfilerTab.COLUMN_PROFILE
: TableProfilerTab.TABLE_PROFILE,
activeColumnFqn,
}),
});
};
const handleFormSubmit = async (values: CustomMetric) => {