Always render a view even if default is unsupported.
This commit is contained in:
@@ -143,13 +143,18 @@ describe('FrigateCamera', () => {
|
||||
|
||||
it('basic non-birdseye', async () => {
|
||||
const camera = new FrigateCamera(
|
||||
createCameraConfig(),
|
||||
createCameraConfig({
|
||||
frigate: {
|
||||
camera_name: 'front_door',
|
||||
},
|
||||
}),
|
||||
mock<CameraManagerEngine>(),
|
||||
);
|
||||
|
||||
await camera.initialize(createHASS(), mock<EntityRegistryManager>());
|
||||
|
||||
expect(camera.getCapabilities()).toEqual(nonBirdseyeBaseCapabilities);
|
||||
expect(vi.mocked(getPTZInfo)).toBeCalled();
|
||||
});
|
||||
|
||||
it('basic birdseye', async () => {
|
||||
@@ -173,6 +178,7 @@ describe('FrigateCamera', () => {
|
||||
supportsRecordings: false,
|
||||
supportsTimeline: false,
|
||||
});
|
||||
expect(vi.mocked(getPTZInfo)).not.toBeCalled();
|
||||
});
|
||||
|
||||
describe('with ptz', () => {
|
||||
|
||||
@@ -61,6 +61,17 @@ describe('CameraManagerStore', async () => {
|
||||
expect(store.getVisibleCameraCount()).toBe(1);
|
||||
});
|
||||
|
||||
describe('getDefaultCameraID', () => {
|
||||
it('with camera', async () => {
|
||||
const store = setupStore();
|
||||
expect(store.getDefaultCameraID()).toBe('camera-visible');
|
||||
});
|
||||
it('without camera', async () => {
|
||||
const store = new CameraManagerStore();
|
||||
expect(store.getDefaultCameraID()).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCamera', async () => {
|
||||
it('present', async () => {
|
||||
const store = setupStore();
|
||||
|
||||
@@ -324,6 +324,57 @@ describe('ViewManager.setViewByParameters', () => {
|
||||
expect(manager.getView()).toBeNull();
|
||||
});
|
||||
|
||||
describe('should handle unsupported view', () => {
|
||||
it('without failsafe', () => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager());
|
||||
vi.mocked(api.getCameraManager().getStore).mockReturnValue(
|
||||
createStore([
|
||||
{
|
||||
cameraID: 'camera.kitchen',
|
||||
},
|
||||
]),
|
||||
);
|
||||
vi.mocked(api.getConfigManager().getConfig).mockReturnValue(createConfig());
|
||||
vi.mocked(api.getCameraManager().getCameraCapabilities).mockReturnValue(createCameraCapabilities({
|
||||
supportsSnapshots: false,
|
||||
}));
|
||||
|
||||
const manager = new ViewManager(api);
|
||||
manager.setViewByParameters({
|
||||
viewName: 'snapshots',
|
||||
});
|
||||
|
||||
expect(manager.hasView()).toBeFalsy();
|
||||
expect(manager.getView()).toBeNull();
|
||||
});
|
||||
|
||||
it('with failsafe', () => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager());
|
||||
vi.mocked(api.getCameraManager().getStore).mockReturnValue(
|
||||
createStore([
|
||||
{
|
||||
cameraID: 'camera.kitchen',
|
||||
},
|
||||
]),
|
||||
);
|
||||
vi.mocked(api.getConfigManager().getConfig).mockReturnValue(createConfig());
|
||||
vi.mocked(api.getCameraManager().getCameraCapabilities).mockReturnValue(createCameraCapabilities({
|
||||
supportsSnapshots: false,
|
||||
}));
|
||||
|
||||
const manager = new ViewManager(api);
|
||||
manager.setViewByParameters({
|
||||
viewName: 'snapshots',
|
||||
failSafe: true,
|
||||
});
|
||||
|
||||
expect(manager.hasView()).toBeTruthy();
|
||||
expect(manager.getView()?.view).toBe('live');
|
||||
});
|
||||
});
|
||||
|
||||
describe('should set view by parameters and respect display mode in config for view', () => {
|
||||
it.each([
|
||||
['media' as const],
|
||||
|
||||
Reference in New Issue
Block a user