@@ -19,6 +19,7 @@ import * as temporalnexus from '@temporalio/nexus';
1919import * as workflow from '@temporalio/workflow' ;
2020import { CancelledFailure , TerminatedFailure , ApplicationFailure , NexusOperationFailure } from '@temporalio/common' ;
2121import { helpers , makeTestFunction } from './helpers-integration' ;
22+ import { waitUntil } from './helpers' ;
2223
2324const test = makeTestFunction ( {
2425 workflowsPath : __filename ,
@@ -227,7 +228,7 @@ test('terminate operation', async (t) => {
227228 } ) ;
228229} ) ;
229230
230- test ( 'list operations' , async ( t ) => {
231+ test ( 'count and list operations' , async ( t ) => {
231232 const { createWorker, registerNexusEndpoint } = helpers ( t ) ;
232233 const { endpointName } = await registerNexusEndpoint ( ) ;
233234 const { handler } = makeTestHandler ( ) ;
@@ -245,6 +246,13 @@ test('list operations', async (t) => {
245246 } ) ;
246247 opIds . add ( id ) ;
247248 }
249+
250+ // Visibility has update delay, repeating query until the activity count is as expected
251+ await waitUntil ( async ( ) => {
252+ const result = await client . nexus . count ( `Endpoint="${ endpointName } "` ) ;
253+ return result . count == 3 ;
254+ } , 10000 ) ;
255+
248256 const seen = new Set < string > ( ) ;
249257 for await ( const op of client . nexus . list ( { query : `Endpoint="${ endpointName } "` } ) ) {
250258 seen . add ( op . operationId ) ;
@@ -256,24 +264,6 @@ test('list operations', async (t) => {
256264 } ) ;
257265} ) ;
258266
259- test ( 'count operations' , async ( t ) => {
260- const { createWorker, registerNexusEndpoint } = helpers ( t ) ;
261- const { endpointName } = await registerNexusEndpoint ( ) ;
262- const { handler } = makeTestHandler ( ) ;
263- const worker = await createWorker ( { nexusServices : [ handler ] } ) ;
264-
265- await worker . runUntil ( async ( ) => {
266- const { client } = t . context . env ;
267- const svc = client . nexus . createServiceClient ( { endpoint : endpointName , service : testService } ) ;
268- await svc . startOperation ( testService . operations . echo , 'count-test' , {
269- id : 'count-op-' + randomUUID ( ) ,
270- scheduleToCloseTimeout : '10s' ,
271- } ) ;
272- const result = await client . nexus . count ( `Endpoint="${ endpointName } "` ) ;
273- t . true ( result . count >= 1 ) ;
274- } ) ;
275- } ) ;
276-
277267test ( 'get handle by ID' , async ( t ) => {
278268 const { createWorker, registerNexusEndpoint } = helpers ( t ) ;
279269 const { endpointName } = await registerNexusEndpoint ( ) ;
0 commit comments