From 8e74c8f2186b72e20778fcdfd53eed2da3fa47ee Mon Sep 17 00:00:00 2001 From: bymyself Date: Sun, 3 May 2026 01:05:01 -0700 Subject: [PATCH] test: harden reset-arg extraction with explicit call assertion Add expect(reset).toHaveBeenCalled() before reading the mock's first call and use optional chaining on calls[0]?.[0] so a missing call produces a clear assertion error rather than a TypeError on undefined indexing. Addresses CodeRabbit nitpick on PR #11631. --- src/platform/workflow/core/services/workflowService.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform/workflow/core/services/workflowService.test.ts b/src/platform/workflow/core/services/workflowService.test.ts index 7d271f555e..a5c99d0a76 100644 --- a/src/platform/workflow/core/services/workflowService.test.ts +++ b/src/platform/workflow/core/services/workflowService.test.ts @@ -556,8 +556,9 @@ describe('useWorkflowService', () => { expect(workflowStore.openWorkflow).toHaveBeenCalledWith(existingWorkflow) expect(workflowStore.createNewTemporary).not.toHaveBeenCalled() + expect(existingWorkflow.changeTracker.reset).toHaveBeenCalled() const resetArg = vi.mocked(existingWorkflow.changeTracker.reset).mock - .calls[0][0] + .calls[0]?.[0] expect(resetArg?.id).toMatch( /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i )