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: Cypress improvements and flakiness fixes #15068

Merged
merged 8 commits into from
Feb 7, 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
Expand Up @@ -84,7 +84,8 @@ public class SearchIndexApp extends AbstractNativeApplication {
"webAnalyticEntityViewReportData",
"webAnalyticUserActivityReportData",
"domain",
"storedProcedure");
"storedProcedure",
"storageService");
private final List<PaginatedEntitiesSource> paginatedEntitiesSources = new ArrayList<>();
private final List<PaginatedDataInsightSource> paginatedDataInsightSources = new ArrayList<>();
private Processor entityProcessor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"webAnalyticUserActivityReportData",
"domain",
"storedProcedure",
"storageService",
"dataProduct"
],
"recreateIndex": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"webAnalyticUserActivityReportData",
"domain",
"storedProcedure",
"storageService",
"dataProduct"
],
"recreateIndex": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,9 @@ const checkActionOrFilterDetails = (filters) => {
if (!isEmpty(filter.arguments)) {
filter.arguments.forEach((argument) => {
// Check filter arguments
// TODO: uncomment this when backend API gives the name of the argument
// cy.get(`[data-testid="argument-container-${argument.name}"]`).should(
// 'exist'
// );
cy.get(`[data-testid="argument-container-${argument.name}"]`).should(
'exist'
);
argument.input.forEach((val) => {
cy.get('[data-testid="argument-value"]').should('contain', val);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const addOwner = (ownerName: string, dataTestId?: string) => {

interceptURL(
'GET',
`api/v1/search/query?q=*${encodeURI(ownerName)}*&index=user_search_index`,
`api/v1/search/query?q=*&index=user_search_index*`,
'searchOwner'
);

Expand Down Expand Up @@ -122,13 +122,17 @@ export const updateOwner = (ownerName: string, dataTestId?: string) => {
};

export const removeOwner = (ownerName: string, dataTestId?: string) => {
cy.get('[data-testid="edit-owner"]').click();
cy.get('[data-testid="edit-owner"]').scrollIntoView().click();

cy.get("[data-testid='select-owner-tabs']").should('be.visible');

interceptURL('PATCH', `/api/v1/**`, 'patchOwner');

cy.get('[data-testid="remove-owner"]').scrollIntoView().click();
cy.get('[data-testid="select-owner-tabs"]').should('be.visible');

cy.get(
'[data-testid="select-owner-tabs"] [data-testid="remove-owner"]'
).click();
verifyResponseStatusCode('@patchOwner', 200);

cy.get(`[data-testid=${dataTestId ?? 'owner-link'}]`).should(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// eslint-disable-next-line spaced-comment
/// <reference types="cypress" />

import { uuid } from '../common/common';
import { SEARCH_SERVICE } from '../constants/EntityConstant';

export const TIER = 'Tier1';
export const TAG_1 = {
Expand All @@ -37,6 +40,30 @@ export const USER_CREDENTIALS = {
password: 'User@OMD123',
};

export const POLICY_DETAILS = {
name: `cy-data-steward-policy-${uuid()}`,
rules: [
{
name: 'DataStewardPolicy-EditRule',
resources: ['All'],
operations: [
'EditDescription',
'EditDisplayName',
'EditOwner',
'EditLineage',
'EditTags',
'ViewAll',
],
effect: 'allow',
},
],
};

export const ROLE_DETAILS = {
name: `cy-data-steward-role-${uuid()}`,
policies: [POLICY_DETAILS.name],
};

export const SEARCH_INDEX_DETAILS_FOR_ANNOUNCEMENT = {
term: SEARCH_INDEX_NAME,
displayName: SEARCH_INDEX_DISPLAY_NAME,
Expand All @@ -47,56 +74,56 @@ export const SEARCH_INDEX_DETAILS_FOR_ANNOUNCEMENT = {

export const SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST = {
name: SEARCH_INDEX_NAME,
service: 'elasticsearch_sample',
service: SEARCH_SERVICE.service.name,
fields: [
{
name: 'name',
dataType: 'TEXT',
dataTypeDisplay: 'text',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.name`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.name`,
tags: [],
},
{
name: 'displayName',
dataType: 'TEXT',
dataTypeDisplay: 'text',
description: 'Description for field displayName',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.displayName`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.displayName`,
tags: [],
},
{
name: 'description',
dataType: 'TEXT',
dataTypeDisplay: 'text',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.description`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.description`,
tags: [],
},
{
name: 'columns',
dataType: 'NESTED',
dataTypeDisplay: 'nested',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.columns`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.columns`,
tags: [],
children: [
{
name: 'name',
dataType: 'TEXT',
dataTypeDisplay: 'text',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.columns.name`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.columns.name`,
tags: [],
},
{
name: 'displayName',
dataType: 'TEXT',
dataTypeDisplay: 'text',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.columns.displayName`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.columns.displayName`,
tags: [],
},
{
name: 'description',
dataType: 'TEXT',
dataTypeDisplay: 'text',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.columns.description`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.columns.description`,
tags: [],
},
],
Expand All @@ -106,9 +133,14 @@ export const SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST = {
dataType: 'TEXT',
dataTypeDisplay: 'text',
description: 'Database Schema that this table belongs to.',
fullyQualifiedName: `elasticsearch_sample.${SEARCH_INDEX_NAME}.databaseSchema`,
fullyQualifiedName: `${SEARCH_SERVICE.service.name}.${SEARCH_INDEX_NAME}.databaseSchema`,
tags: [],
},
],
tags: [],
};

export const SEARCH_SERVICE_DETAILS = {
...SEARCH_SERVICE,
entity: SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST,
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
visitGlossaryPage,
} from '../../common/GlossaryUtils';
import { addOwner, removeOwner } from '../../common/Utils/Owner';
import { USER_DETAILS } from '../../constants/EntityConstant';
import { GLOSSARY_OWNER_LINK_TEST_ID } from '../../constants/glossary.constant';
import {
GLOSSARY_FOR_VERSION_TEST,
Expand All @@ -30,31 +31,38 @@ import {
GLOSSARY_TERM_NAME_FOR_VERSION_TEST1,
GLOSSARY_TERM_NAME_FOR_VERSION_TEST2,
GLOSSARY_TERM_PATCH_PAYLOAD2,
OWNER,
REVIEWER,
} from '../../constants/Version.constants';

describe('Glossary and glossary term version pages should work properly', () => {
let glossaryId;
let glossaryTerm1Id;
let glossaryTerm2Id;
let data = {};

before(() => {
cy.login();
cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;
cy.getAllLocalStorage().then((storageData) => {
const token = Object.values(storageData)[0].oidcIdToken;
// Create a new user
cy.request({
method: 'POST',
url: `/api/v1/users/signup`,
headers: { Authorization: `Bearer ${token}` },
body: USER_DETAILS,
}).then((response) => {
data.user = response.body;
});

// Create Glossary
cy.request({
method: 'PUT',
url: `/api/v1/glossaries`,
headers: { Authorization: `Bearer ${token}` },
body: GLOSSARY_FOR_VERSION_TEST,
}).then((response) => {
glossaryId = response.body.id;
data.glossary = response.body;

cy.request({
method: 'PATCH',
url: `/api/v1/glossaries/${glossaryId}`,
url: `/api/v1/glossaries/${data.glossary.id}`,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json-patch+json',
Expand All @@ -70,7 +78,7 @@ describe('Glossary and glossary term version pages should work properly', () =>
headers: { Authorization: `Bearer ${token}` },
body: GLOSSARY_TERM_FOR_VERSION_TEST1,
}).then((response) => {
glossaryTerm1Id = response.body.id;
data.glossaryTerm1 = response.body;
});

// Create Second Glossary Term
Expand All @@ -80,13 +88,13 @@ describe('Glossary and glossary term version pages should work properly', () =>
headers: { Authorization: `Bearer ${token}` },
body: GLOSSARY_TERM_FOR_VERSION_TEST2,
}).then((response) => {
glossaryTerm2Id = response.body.id;
data.glossaryTerm2 = response.body;

const relatedTermsPatchValue = {
op: 'add',
path: '/relatedTerms/0',
value: {
id: glossaryTerm1Id,
id: data.glossaryTerm1.id,
type: 'glossaryTerm',
displayName: GLOSSARY_TERM_NAME_FOR_VERSION_TEST1,
name: GLOSSARY_TERM_NAME_FOR_VERSION_TEST1,
Expand All @@ -95,7 +103,7 @@ describe('Glossary and glossary term version pages should work properly', () =>

cy.request({
method: 'PATCH',
url: `/api/v1/glossaryTerms/${glossaryTerm2Id}`,
url: `/api/v1/glossaryTerms/${data.glossaryTerm2.id}`,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json-patch+json',
Expand All @@ -113,6 +121,20 @@ describe('Glossary and glossary term version pages should work properly', () =>
visitGlossaryPage();
});

after(() => {
cy.login();
cy.getAllLocalStorage().then((storageData) => {
const token = Object.values(storageData)[0].oidcIdToken;

// Delete created user
cy.request({
method: 'DELETE',
url: `/api/v1/users/${data.user.id}?hardDelete=true&recursive=false`,
headers: { Authorization: `Bearer ${token}` },
});
});
});

it('Glossary version page should display the version changes properly', () => {
cy.get(`[data-menu-id*=${GLOSSARY_FOR_VERSION_TEST.displayName}]`).click();

Expand Down Expand Up @@ -140,7 +162,7 @@ describe('Glossary and glossary term version pages should work properly', () =>

cy.get('[data-testid="version-button"]').contains('0.2');

addOwner(OWNER, GLOSSARY_OWNER_LINK_TEST_ID);
addOwner(data.user.displayName, GLOSSARY_OWNER_LINK_TEST_ID);

interceptURL('GET', `/api/v1/glossaries/*/versions`, 'getVersionsList');
interceptURL(
Expand All @@ -165,7 +187,7 @@ describe('Glossary and glossary term version pages should work properly', () =>
verifyResponseStatusCode('@getGlossaryDetails', 200);
verifyResponseStatusCode('@getGlossaryTerms', 200);

removeOwner(OWNER, GLOSSARY_OWNER_LINK_TEST_ID);
removeOwner(data.user.displayName, GLOSSARY_OWNER_LINK_TEST_ID);

addReviewer(REVIEWER, 'glossaries');

Expand Down Expand Up @@ -269,7 +291,7 @@ describe('Glossary and glossary term version pages should work properly', () =>

cy.get('[data-testid="version-button"]').contains('0.2');

addOwner(OWNER, GLOSSARY_OWNER_LINK_TEST_ID);
addOwner(data.user.displayName, GLOSSARY_OWNER_LINK_TEST_ID);

interceptURL('GET', `/api/v1/glossaryTerms/*/versions`, 'getVersionsList');
interceptURL(
Expand All @@ -294,7 +316,7 @@ describe('Glossary and glossary term version pages should work properly', () =>
verifyResponseStatusCode('@getGlossaryTermParents', 200);
verifyResponseStatusCode('@getChildGlossaryTerms', 200);

removeOwner(OWNER, GLOSSARY_OWNER_LINK_TEST_ID);
removeOwner(data.user.displayName, GLOSSARY_OWNER_LINK_TEST_ID);

addReviewer(REVIEWER, 'glossaryTerms');

Expand Down
Loading
Loading