Skip to content

Commit dbe4e09

Browse files
Eibon7claude
andcommitted
fix(tests): Add defensive check for insert.mock.calls - Issue #618
- Added defensive check before accessing .insert.mock.calls[0] at line 555 - Fixed 1 'Cannot read properties of undefined (reading '0')' error - Pattern: Validate array has elements before index access File modified: - tests/unit/routes/roast-validation-issue364.test.js (1 defensive check added) Session #10: 1 'Cannot read [0]' error eliminated 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent dee50dc commit dbe4e09

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tests/unit/routes/roast-validation-issue364.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ describe('POST /api/roast/:id/validate - SPEC 8 Issue #364', () => {
550550
.post('/api/roast/test-roast-id/validate')
551551
.send({ text: 'Private user content', platform: 'twitter' });
552552

553+
// Issue #618 - Add defensive check for mock.calls array
554+
expect(supabaseServiceClient.insert.mock.calls.length).toBeGreaterThan(0);
553555
const insertCall = supabaseServiceClient.insert.mock.calls[0][0];
554556
expect(JSON.stringify(insertCall)).not.toContain('Private user content');
555557
expect(insertCall.metadata.textLength).toBe(20); // Only length, not content

0 commit comments

Comments
 (0)