fix: Only show PTZ controls for selected camera in grid mode (#1619)

This commit is contained in:
Dermot Duffy
2024-10-05 14:17:34 -07:00
committed by GitHub
parent 632e06b7f9
commit abcba34a3f
3 changed files with 37 additions and 23 deletions
+24 -19
View File
@@ -5,11 +5,11 @@ import {
removeSubstream,
} from '../../src/utils/substream';
import { View } from '../../src/view/view';
import { createView } from '../test-utils';
describe('hasSubstream/getStreamCameraID', () => {
it('should detect substream', () => {
const view = new View({
view: 'live',
const view = createView({
camera: 'camera',
context: {
live: {
@@ -21,16 +21,14 @@ describe('hasSubstream/getStreamCameraID', () => {
expect(getStreamCameraID(view)).toBe('camera2');
});
it('should not detect substream when absent', () => {
const view = new View({
view: 'live',
const view = createView({
camera: 'camera',
});
expect(hasSubstream(view)).toBeFalsy();
expect(getStreamCameraID(view)).toBe('camera');
});
it('should not detect substream when main stream', () => {
const view = new View({
view: 'live',
const view = createView({
camera: 'camera',
context: {
live: {
@@ -41,21 +39,28 @@ describe('hasSubstream/getStreamCameraID', () => {
expect(hasSubstream(view)).toBeFalsy();
expect(getStreamCameraID(view)).toBe('camera');
});
it('should respect cameraID override', () => {
const view = new View({
view: 'live',
camera: 'camera',
context: {
live: {
overrides: new Map([
['camera', 'camera2'],
['camera3', 'camera4'],
]),
describe('should respect cameraID override', () => {
it('should respect cameraID override when present in overrides', () => {
const view = createView({
camera: 'camera',
context: {
live: {
overrides: new Map([
['camera', 'camera2'],
['camera3', 'camera4'],
]),
},
},
},
});
expect(hasSubstream(view)).toBeTruthy();
expect(getStreamCameraID(view, 'camera3')).toBe('camera4');
});
it('should respect cameraID override when not present in overrides', () => {
const view = createView();
expect(hasSubstream(view)).toBeFalsy();
expect(getStreamCameraID(view, 'camera3')).toBe('camera3');
});
expect(hasSubstream(view)).toBeTruthy();
expect(getStreamCameraID(view, 'camera3')).toBe('camera4');
});
});