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.
This commit is contained in:
bymyself
2026-05-03 01:05:01 -07:00
parent 822dc6d633
commit 8e74c8f218

View File

@@ -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
)