mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Catch case where recording is not enabled (#4069)
* Catch case where recording is not enabled * Add test for Record to catch this * Add test for Record to catch this
This commit is contained in:
parent
e718d09c79
commit
a1b21a87a1
@ -54,6 +54,10 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se
|
||||
|
||||
const selectedDayRecordingData = recordingsSummary.find((s) => !date || s.day === date);
|
||||
|
||||
if (!selectedDayRecordingData) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const [year, month, day] = selectedDayRecordingData.day.split('-');
|
||||
return selectedDayRecordingData.hours
|
||||
.map((h) => {
|
||||
|
27
web/src/routes/__tests__/Recording.test.jsx
Normal file
27
web/src/routes/__tests__/Recording.test.jsx
Normal file
@ -0,0 +1,27 @@
|
||||
import { h } from 'preact';
|
||||
import * as CameraImage from '../../components/CameraImage';
|
||||
import * as Mqtt from '../../api/mqtt';
|
||||
import Cameras from '../Cameras';
|
||||
import { render, screen, waitForElementToBeRemoved } from 'testing-library';
|
||||
|
||||
describe('Recording Route', () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(CameraImage, 'default').mockImplementation(() => <div data-testid="camera-image" />);
|
||||
jest.spyOn(Mqtt, 'useMqtt').mockImplementation(() => ({ value: { payload: 'OFF' }, send: jest.fn() }));
|
||||
});
|
||||
|
||||
test('shows an ActivityIndicator if not yet loaded', async () => {
|
||||
render(<Cameras />);
|
||||
expect(screen.queryByLabelText('Loading…')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
|
||||
test('shows no recordings warning', async () => {
|
||||
render(<Cameras />);
|
||||
|
||||
await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading…'));
|
||||
|
||||
expect(screen.queryAllByText('No Recordings Found')).toHaveLength(0);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user