Skip to content

Commit

Permalink
Fix ExecutionStatus filters not showing up on page refresh (#2184)
Browse files Browse the repository at this point in the history
* Account for parenthesis as potential start of attribute

* Update queries in tests to have backticks
  • Loading branch information
laurakwhit authored Jul 3, 2024
1 parent 7f69132 commit 07d03a5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
28 changes: 14 additions & 14 deletions src/lib/utilities/query/to-list-workflow-filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 6 additions & 6 deletions src/lib/utilities/query/tokenize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/utilities/query/tokenize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 07d03a5

Please sign in to comment.