OSS changes for adding automator cypress tests (#16611)

This commit is contained in:
Aniket Katkar 2024-06-11 19:57:11 +05:30 committed by GitHub
parent 1d4e3e0825
commit dc31717b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 3 deletions

View File

@ -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 = /[\\[\]#+=&|><!(){}^"~*?:/-]/g;
const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
const getReplacedChar = (char: string) => {
return ES_RESERVED_CHARACTERS[char] ?? char;
};
return text && reHasUnescapedHtml.test(text)
? text.replace(reUnescapedHtml, getReplacedChar)
: text ?? '';
};

View File

@ -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',

View File

@ -483,3 +483,29 @@ export const DOMAIN_QUICK_FILTERS_DETAILS = {
experts: [],
style: {},
};
export const ES_RESERVED_CHARACTERS: Record<string, string> = {
'+': '\\+',
'-': '\\-',
'=': '\\=',
'&': '\\&',
'&&': '\\&&',
'||': '\\||',
'>': '\\>',
'<': '\\<',
'!': '\\!',
'(': '\\(',
')': '\\)',
'{': '\\{',
'}': '\\}',
'[': '\\[',
']': '\\]',
'^': '\\^',
'"': '\\"',
'~': '\\~',
'*': '\\*',
'?': '\\?',
':': '\\:',
'\\': '\\\\',
'/': '\\/',
};

View File

@ -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;