diff --git a/src/lib/utilities/query/to-list-workflow-filters.test.ts b/src/lib/utilities/query/to-list-workflow-filters.test.ts index 544c60793..65cfbdf66 100644 --- a/src/lib/utilities/query/to-list-workflow-filters.test.ts +++ b/src/lib/utilities/query/to-list-workflow-filters.test.ts @@ -8,29 +8,29 @@ import { toListWorkflowFilters, } from './to-list-workflow-filters'; -const executionStatusQuery = 'ExecutionStatus="Completed"'; +const executionStatusQuery = '`ExecutionStatus`="Completed"'; const multipleExecutionStatusQuery = - '(ExecutionStatus="Canceled" OR ExecutionStatus="Failed" OR ExecutionStatus="Completed")'; + '(`ExecutionStatus`="Canceled" OR `ExecutionStatus`="Failed" OR `ExecutionStatus`="Completed")'; -const workflowIdQuery = 'WorkflowId="Hello world"'; -const workflowTypeQuery = 'WorkflowType="World"'; -const workflowQuery1 = 'WorkflowId="Hello world" AND WorkflowType="World"'; -const startTimeQuery = 'StartTime > "2022-04-18T17:45:18-06:00"'; -const closeTimeQuery = 'CloseTime > "2022-04-18T17:45:18-06:00"'; -const booleanQuery = 'CustomBoolField=true'; +const workflowIdQuery = '`WorkflowId`="Hello world"'; +const workflowTypeQuery = '`WorkflowType`="World"'; +const workflowQuery1 = '`WorkflowId`="Hello world" AND `WorkflowType`="World"'; +const startTimeQuery = '`StartTime` > "2022-04-18T17:45:18-06:00"'; +const closeTimeQuery = '`CloseTime` > "2022-04-18T17:45:18-06:00"'; +const booleanQuery = '`CustomBoolField`=true'; const betweenTimeQuery = - 'StartTime BETWEEN "2023-07-28T00:00:00-00:00" AND "2023-07-28T06:00:00-00:00"'; + '`StartTime` BETWEEN "2023-07-28T00:00:00-00:00" AND "2023-07-28T06:00:00-00:00"'; const workflowQuery2 = - 'WorkflowType="World" AND StartTime > "2022-04-18T17:45:18-06:00"'; + '`WorkflowType`="World" AND `StartTime` > "2022-04-18T17:45:18-06:00"'; const workflowQuery3 = - 'WorkflowType="World" AND StartTime > "2022-04-18T17:45:18-06:00" AND ExecutionStatus="Canceled"'; + '`WorkflowType`="World" AND `StartTime` > "2022-04-18T17:45:18-06:00" AND `ExecutionStatus`="Canceled"'; const workflowQuery4 = - '(ExecutionStatus="Canceled" OR ExecutionStatus="Failed" OR ExecutionStatus="Completed") AND WorkflowType="World" AND StartTime > "2022-04-18T17:45:18-06:00"'; + '(`ExecutionStatus`="Canceled" OR `ExecutionStatus`="Failed" OR `ExecutionStatus`="Completed") AND WorkflowType="World" AND StartTime > "2022-04-18T17:45:18-06:00"'; const customAttributesWithSpacesQuery = '`Custom Bool Field`=true AND `Custom Keyword Field`="Hello world"'; const workflowQueryWithSpaces = - 'WorkflowId="One and Two" AND `Custom Keyword Field`="Hello = world"'; -const prefixQuery = 'WorkflowType STARTS_WITH "hello"'; + '`WorkflowId`="One and Two" AND `Custom Keyword Field`="Hello = world"'; +const prefixQuery = '`WorkflowType` STARTS_WITH "hello"'; const attributes = { CloseTime: 'Datetime', diff --git a/src/lib/utilities/query/tokenize.test.ts b/src/lib/utilities/query/tokenize.test.ts index 4f4176dbc..b453ab4a9 100644 --- a/src/lib/utilities/query/tokenize.test.ts +++ b/src/lib/utilities/query/tokenize.test.ts @@ -2,15 +2,15 @@ import { describe, expect, it } from 'vitest'; import { tokenize } from './tokenize'; -const executionStatusQuery = 'ExecutionStatus="Completed"'; -const startTimeQuery = 'StartTime > "2022-04-18T17:45:18-06:00"'; -const workflowQuery = 'WorkflowId="Hello" and WorkflowType="World"'; +const executionStatusQuery = '`ExecutionStatus`="Completed"'; +const startTimeQuery = '`StartTime` > "2022-04-18T17:45:18-06:00"'; +const workflowQuery = '`WorkflowId`="Hello" and `WorkflowType`="World"'; const customAttributesWithSpacesQuery = - '(ExecutionStatus="Running" OR ExecutionStatus="TimedOut") AND `Custom Key Word`="Hello there" AND WorkflowId="some workflow" AND `Custom Boolean`=true'; + '(`ExecutionStatus`="Running" OR `ExecutionStatus`="TimedOut") AND `Custom Key Word`="Hello there" AND `WorkflowId`="some workflow" AND `Custom Boolean`=true'; const combinedQuery = - 'WorkflowId="Hello" and WorkflowType="World" and StartTime BETWEEN "2022-04-18T18:09:49-06:00" AND "2022-04-20T18:09:49-06:00"'; + '`WorkflowId`="Hello" and `WorkflowType`="World" and `StartTime` BETWEEN "2022-04-18T18:09:49-06:00" AND "2022-04-20T18:09:49-06:00"'; const valuesWithSpacesQuery = - '`Custom Key Word`="Hello there world" AND WorkflowId="one and two = three" OR WorkflowType="example=\'one\'"'; + '`Custom Key Word`="Hello there world" AND `WorkflowId`="one and two = three" OR `WorkflowType`="example=\'one\'"'; describe('tokenize', () => { it('should eliminate spaces', () => { diff --git a/src/lib/utilities/query/tokenize.ts b/src/lib/utilities/query/tokenize.ts index 3e80ea25c..c9683e616 100644 --- a/src/lib/utilities/query/tokenize.ts +++ b/src/lib/utilities/query/tokenize.ts @@ -41,7 +41,9 @@ export const tokenize = (string: string): Tokens => { if (isBacktick(character)) { const isPotentialStartofAttribute = cursor === 0 || - (isSpace(string[cursor - 1]) && isOperator(tokens[tokens.length - 1])); + (isSpace(string[cursor - 1]) && + isOperator(tokens[tokens.length - 1])) || + isParenthesis(string[cursor - 1]); const hasClosingBacktick = string.slice(cursor + 1).includes(character); if (isPotentialStartofAttribute && hasClosingBacktick) {