From dc31717b169fe374af3a40c358ab3b7f9500126f Mon Sep 17 00:00:00 2001 From: Aniket Katkar Date: Tue, 11 Jun 2024 19:57:11 +0530 Subject: [PATCH] OSS changes for adding automator cypress tests (#16611) --- .../ui/cypress/common/EntityUtils.ts | 14 ++++++++++ .../ui/cypress/common/Utils/Owner.ts | 11 ++++++-- .../ui/cypress/constants/EntityConstant.ts | 26 +++++++++++++++++++ .../IngestionWorkflow.interface.ts | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/EntityUtils.ts b/openmetadata-ui/src/main/resources/ui/cypress/common/EntityUtils.ts index 7eea0542c65..38c53c67a51 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/EntityUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/EntityUtils.ts @@ -16,6 +16,7 @@ import { DASHBOARD_SERVICE_DETAILS, DATABASE_DETAILS, DATABASE_SERVICE_DETAILS, + ES_RESERVED_CHARACTERS, MESSAGING_SERVICE_DETAILS, ML_MODEL_SERVICE_DETAILS, PIPELINE_SERVICE_DETAILS, @@ -476,3 +477,16 @@ export const getUserCreationDetails = () => { }, }; }; + +export const escapeESReservedCharacters = (text?: string) => { + const reUnescapedHtml = /[\\[\]#+=&|> { + return ES_RESERVED_CHARACTERS[char] ?? char; + }; + + return text && reHasUnescapedHtml.test(text) + ? text.replace(reUnescapedHtml, getReplacedChar) + : text ?? ''; +}; diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts index 3ba6cee3d88..c856d87fa52 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts @@ -64,7 +64,11 @@ export const validateOwnerAndTeamCounts = () => { cy.clickOutside(); }; -export const addOwner = (ownerName: string, dataTestId?: string) => { +export const addOwner = ( + ownerName: string, + dataTestId?: string, + verifyPatchResponse = true +) => { interceptURL('GET', '/api/v1/users?*isBot=false*', 'getUsers'); cy.get('[data-testid="edit-owner"]').click(); @@ -84,7 +88,10 @@ export const addOwner = (ownerName: string, dataTestId?: string) => { interceptURL('PATCH', `/api/v1/**`, 'patchOwner'); cy.get(`.ant-popover [title="${ownerName}"]`).click(); - verifyResponseStatusCode('@patchOwner', 200); + + if (verifyPatchResponse) { + verifyResponseStatusCode('@patchOwner', 200); + } cy.get(`[data-testid=${dataTestId ?? 'owner-link'}]`).should( 'contain', diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/EntityConstant.ts b/openmetadata-ui/src/main/resources/ui/cypress/constants/EntityConstant.ts index 249cff39319..4807a2b0a22 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/EntityConstant.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/EntityConstant.ts @@ -483,3 +483,29 @@ export const DOMAIN_QUICK_FILTERS_DETAILS = { experts: [], style: {}, }; + +export const ES_RESERVED_CHARACTERS: Record = { + '+': '\\+', + '-': '\\-', + '=': '\\=', + '&': '\\&', + '&&': '\\&&', + '||': '\\||', + '>': '\\>', + '<': '\\<', + '!': '\\!', + '(': '\\(', + ')': '\\)', + '{': '\\{', + '}': '\\}', + '[': '\\[', + ']': '\\]', + '^': '\\^', + '"': '\\"', + '~': '\\~', + '*': '\\*', + '?': '\\?', + ':': '\\:', + '\\': '\\\\', + '/': '\\/', +}; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Services/AddIngestion/IngestionWorkflow.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Services/AddIngestion/IngestionWorkflow.interface.ts index 13f61a69487..a3e2ecec966 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Services/AddIngestion/IngestionWorkflow.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Services/AddIngestion/IngestionWorkflow.interface.ts @@ -54,7 +54,7 @@ export interface AddIngestionProps { export type ScheduleIntervalProps = { onChange: (newScheduleInterval: string) => void; status: LoadingState; - scheduleInterval: string; + scheduleInterval?: string; includePeriodOptions?: string[]; submitButtonLabel: string; children?: ReactNode;