From 95ed659dd616e34b5cd970dcbc353efc58fed694 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 7 Nov 2026 18:00:16 -0500 Subject: [PATCH 1/4] Apply suggested fix to web/tests/recordingsAPI.spec.js from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- web/tests/recordingsAPI.spec.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/web/tests/recordingsAPI.spec.js b/web/tests/recordingsAPI.spec.js index 8e954157c..d62c2f2dd 100644 --- a/web/tests/recordingsAPI.spec.js +++ b/web/tests/recordingsAPI.spec.js @@ -180,22 +180,14 @@ describe('recordingsAPI', () => { const recording = { id: 89, stream: 'backyard', - start_time: 'invalid-start-timestamp', - end_time: 'invalid-end-timestamp' + start_time: 'not-a-timestamp', + end_time: '2026-02-18T05:30:00Z' }; - const parseSpy = jest - .spyOn(recordingsAPI, 'parseRecordingTimestamp') - .mockImplementation(() => { - throw new Error('parse error'); - }); - const result = await recordingsAPI.getRecordingDetections(recording); expect(result).toEqual([]); expect(enhancedFetch).not.toHaveBeenCalled(); - - parseSpy.mockRestore(); }); test('getRecordingDetections returns empty array when enhancedFetch rejects', async () => { From e05b7a7bff4a9f7ed6e41fde04e5e7e6ee976279 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 7 Nov 2026 18:00:17 -0500 Subject: [PATCH 2/4] Apply suggested fix to web/tests/recordingsAPI.spec.js from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- web/tests/recordingsAPI.spec.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/web/tests/recordingsAPI.spec.js b/web/tests/recordingsAPI.spec.js index d62c2f2dd..668fcf5b2 100644 --- a/web/tests/recordingsAPI.spec.js +++ b/web/tests/recordingsAPI.spec.js @@ -110,7 +110,7 @@ describe('recordingsAPI', () => { ).resolves.toBe(false); }); - test('checkRecordingHasDetections returns false when timestamp parsing fails', async () => { + test('checkRecordingHasDetections returns false when timestamps are invalid', async () => { const recording = { id: 44, stream: 'front-yard', @@ -118,15 +118,7 @@ describe('recordingsAPI', () => { end_time: 'invalid-timestamp' }; - const parseSpy = jest - .spyOn(recordingsAPI, 'parseRecordingTimestamp') - .mockImplementation(() => { - throw new Error('parse error'); - }); - await expect(recordingsAPI.checkRecordingHasDetections(recording)).resolves.toBe(false); - - parseSpy.mockRestore(); }); test('checkRecordingHasDetections returns false when enhancedFetch throws an error', async () => { From 9c22be4d0bed760dd143de9adc35d2ec3ba657f0 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sun, 8 Nov 2026 06:36:12 -0500 Subject: [PATCH 3/4] Assert invalid timestamps skip the detection request Co-Authored-By: Claude Opus 5.5 --- web/tests/recordingsAPI.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/tests/recordingsAPI.spec.js b/web/tests/recordingsAPI.spec.js index 668fcf5b2..46578c563 100644 --- a/web/tests/recordingsAPI.spec.js +++ b/web/tests/recordingsAPI.spec.js @@ -119,6 +119,7 @@ describe('recordingsAPI', () => { }; await expect(recordingsAPI.checkRecordingHasDetections(recording)).resolves.toBe(false); + expect(enhancedFetch).not.toHaveBeenCalled(); }); test('checkRecordingHasDetections returns false when enhancedFetch throws an error', async () => { From 1276e224e369f99bb027c2c27fd43de6f577d92c Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sun, 8 Nov 2026 06:44:35 -0500 Subject: [PATCH 4/4] Cover each invalid detection timestamp independently --- web/tests/recordingsAPI.spec.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/web/tests/recordingsAPI.spec.js b/web/tests/recordingsAPI.spec.js index 46578c563..1eb57ebe1 100644 --- a/web/tests/recordingsAPI.spec.js +++ b/web/tests/recordingsAPI.spec.js @@ -110,16 +110,22 @@ describe('recordingsAPI', () => { ).resolves.toBe(false); }); - test('checkRecordingHasDetections returns false when timestamps are invalid', async () => { + test.each([ + ['start', 'invalid-timestamp', '2026-02-18T05:01:00Z'], + ['end', '2026-02-18T05:00:00Z', 'invalid-timestamp'], + ['both', 'invalid-timestamp', 'invalid-timestamp'] + ])('checkRecordingHasDetections returns false without requesting detections when %s timestamps are invalid', async (_invalid, start_time, end_time) => { const recording = { id: 44, stream: 'front-yard', - start_time: 'invalid-timestamp', - end_time: 'invalid-timestamp' + start_time, + end_time }; + const errorLog = jest.spyOn(console, 'error').mockImplementation(() => {}); await expect(recordingsAPI.checkRecordingHasDetections(recording)).resolves.toBe(false); expect(enhancedFetch).not.toHaveBeenCalled(); + expect(errorLog).toHaveBeenCalledWith('Failed to parse recording timestamps'); }); test('checkRecordingHasDetections returns false when enhancedFetch throws an error', async () => { @@ -169,18 +175,24 @@ describe('recordingsAPI', () => { expect(enhancedFetch).not.toHaveBeenCalled(); }); - test('getRecordingDetections returns empty array when timestamp parsing fails', async () => { + test.each([ + ['start', 'invalid-timestamp', '2026-02-18T05:01:00Z'], + ['end', '2026-02-18T05:00:00Z', 'invalid-timestamp'], + ['both', 'invalid-timestamp', 'invalid-timestamp'] + ])('getRecordingDetections returns empty array without requesting detections when %s timestamps are invalid', async (_invalid, start_time, end_time) => { const recording = { id: 89, stream: 'backyard', - start_time: 'not-a-timestamp', - end_time: '2026-02-18T05:30:00Z' + start_time, + end_time }; + const errorLog = jest.spyOn(console, 'error').mockImplementation(() => {}); const result = await recordingsAPI.getRecordingDetections(recording); expect(result).toEqual([]); expect(enhancedFetch).not.toHaveBeenCalled(); + expect(errorLog).toHaveBeenCalledWith('Failed to parse recording timestamps'); }); test('getRecordingDetections returns empty array when enhancedFetch rejects', async () => {