Skip to content

Commit 3261083

Browse files
committed
test fixes
1 parent af0754e commit 3261083

File tree

4 files changed

+39
-30
lines changed

4 files changed

+39
-30
lines changed

packages/test/src/test-integration-split-one.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,12 @@ test('Workflow can upsert Search Attributes', configMacro, async (t, config) =>
698698
);
699699
});
700700

701-
export async function returnWorkflowInfo(): Promise<WorkflowInfo> {
702-
return workflowInfo();
701+
export async function returnWorkflowInfo(): Promise<WorkflowInfo & { isTypedSearchAttributesInstance: boolean }> {
702+
const info = workflowInfo();
703+
return {
704+
...info,
705+
isTypedSearchAttributesInstance: info.typedSearchAttributes instanceof TypedSearchAttributes,
706+
};
703707
}
704708

705709
test('Workflow can read WorkflowInfo', configMacro, async (t, config) => {
@@ -724,7 +728,10 @@ test('Workflow can read WorkflowInfo', configMacro, async (t, config) => {
724728
runId: handle.firstExecutionRunId,
725729
taskQueue,
726730
searchAttributes: {},
727-
typedSearchAttributes: new TypedSearchAttributes(),
731+
// Ensure serialized data structure is correct
732+
typedSearchAttributes: JSON.parse(JSON.stringify(new TypedSearchAttributes())),
733+
// Ensure typed search attributes in workflow info is an instance of TypedSearchAttributes
734+
isTypedSearchAttributesInstance: true,
728735
workflowType: 'returnWorkflowInfo',
729736
workflowId: handle.workflowId,
730737
historyLength: 3,

packages/test/src/test-schedules.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
SearchAttributes,
1414
} from '@temporalio/client';
1515
import { msToNumber } from '@temporalio/common/lib/time';
16-
import { searchAttributePair, SearchAttributeType } from '@temporalio/common';
16+
import { searchAttributePair, SearchAttributeType, TypedSearchAttributes } from '@temporalio/common';
1717
import { registerDefaultCustomSearchAttributes, RUN_INTEGRATION_TESTS } from './helpers';
1818

1919
export interface Context {
@@ -169,7 +169,7 @@ if (RUN_INTEGRATION_TESTS) {
169169
searchAttributes: {
170170
CustomKeywordField: ['test-value2'],
171171
},
172-
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
172+
typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)],
173173
},
174174
});
175175

@@ -179,15 +179,17 @@ if (RUN_INTEGRATION_TESTS) {
179179
t.is(describedSchedule.action.type, 'startWorkflow');
180180
t.is(describedSchedule.action.workflowType, 'dummyWorkflow');
181181
t.deepEqual(describedSchedule.action.memo, { 'my-memo': 'foo' });
182-
t.deepEqual(describedSchedule.action.searchAttributes, [
183-
['CustomKeywordField', ['test-value2']],
184-
['CustomInt', 42],
185-
]);
186-
t.deepEqual(describedSchedule.action.typedSearchAttributes, [
187-
searchAttributePair('CustomInt', SearchAttributeType.INT, 42),
188-
// Note that the typed search attribute infers type TEXT from the value.
189-
searchAttributePair('CustomKeywordField', SearchAttributeType.TEXT, 'test-value2'),
190-
]);
182+
t.deepEqual(describedSchedule.action.searchAttributes, {
183+
CustomKeywordField: ['test-value2'],
184+
CustomIntField: [42],
185+
});
186+
t.deepEqual(
187+
describedSchedule.action.typedSearchAttributes,
188+
new TypedSearchAttributes([
189+
searchAttributePair('CustomIntField', SearchAttributeType.INT, 42),
190+
searchAttributePair('CustomKeywordField', SearchAttributeType.KEYWORD, 'test-value2'),
191+
])
192+
);
191193
} finally {
192194
await handle.delete();
193195
}
@@ -212,7 +214,7 @@ if (RUN_INTEGRATION_TESTS) {
212214
searchAttributes: {
213215
CustomKeywordField: ['test-value2'],
214216
},
215-
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
217+
typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)],
216218
},
217219
});
218220

@@ -223,15 +225,17 @@ if (RUN_INTEGRATION_TESTS) {
223225
t.is(describedSchedule.action.workflowType, 'dummyWorkflowWith2Args');
224226
t.deepEqual(describedSchedule.action.args, [3, 4]);
225227
t.deepEqual(describedSchedule.action.memo, { 'my-memo': 'foo' });
226-
t.deepEqual(describedSchedule.action.searchAttributes, [
227-
['CustomKeywordField', ['test-value2']],
228-
['CustomInt', 42],
229-
]);
230-
t.deepEqual(describedSchedule.action.typedSearchAttributes, [
231-
searchAttributePair('CustomInt', SearchAttributeType.INT, 42),
232-
// Note that the typed search attribute "guesses" TEXT, inferred from the value.
233-
searchAttributePair('CustomKeywordField', SearchAttributeType.TEXT, 'test-value2'),
234-
]);
228+
t.deepEqual(describedSchedule.action.searchAttributes, {
229+
CustomKeywordField: ['test-value2'],
230+
CustomIntField: [42],
231+
});
232+
t.deepEqual(
233+
describedSchedule.action.typedSearchAttributes,
234+
new TypedSearchAttributes([
235+
searchAttributePair('CustomIntField', SearchAttributeType.INT, 42),
236+
searchAttributePair('CustomKeywordField', SearchAttributeType.KEYWORD, 'test-value2'),
237+
])
238+
);
235239
} finally {
236240
await handle.delete();
237241
}
@@ -342,7 +346,7 @@ if (RUN_INTEGRATION_TESTS) {
342346
searchAttributes: {
343347
CustomKeywordField: ['test-value2'],
344348
},
345-
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
349+
typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)],
346350
},
347351
});
348352

@@ -587,7 +591,7 @@ if (RUN_INTEGRATION_TESTS) {
587591
taskQueue,
588592
},
589593
searchAttributes,
590-
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
594+
typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)],
591595
})
592596
);
593597
}

packages/test/src/test-sinks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ if (RUN_INTEGRATION_TESTS) {
118118
memo: {},
119119
parent: undefined,
120120
searchAttributes: {},
121-
typedSearchAttributes: new TypedSearchAttributes(),
121+
typedSearchAttributes: JSON.parse(JSON.stringify(new TypedSearchAttributes())),
122122
historyLength: 3,
123123
continueAsNewSuggested: false,
124124
// values ignored for the purpose of comparison

packages/workflow/src/workflow.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,7 @@ export function makeContinueAsNewFunc<F extends Workflow>(
937937
memo: options.memo && mapToPayloads(activator.payloadConverter, options.memo),
938938
searchAttributes:
939939
options.searchAttributes || options.typedSearchAttributes
940-
? {
941-
indexedFields: encodeUnifiedSearchAttributes(options.searchAttributes, options.typedSearchAttributes),
942-
}
940+
? encodeUnifiedSearchAttributes(options.searchAttributes, options.typedSearchAttributes)
943941
: undefined,
944942
workflowRunTimeout: msOptionalToTs(options.workflowRunTimeout),
945943
workflowTaskTimeout: msOptionalToTs(options.workflowTaskTimeout),

0 commit comments

Comments
 (0)