feat: Add control/output of selected camera via an entity (#1895)
- Closes #1871
This commit is contained in:
@@ -13,7 +13,7 @@ describe('should handle camera_select action', () => {
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -23,13 +23,36 @@ describe('should handle camera_select action', () => {
|
||||
expect.objectContaining({
|
||||
params: {
|
||||
view: 'live',
|
||||
camera: 'camera',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
failSafe: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should ignore requests to change to the current camera', async () => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getViewManager().getView).mockReturnValue(
|
||||
createView({
|
||||
camera: 'camera.office',
|
||||
}),
|
||||
);
|
||||
vi.mocked(api.getViewManager().isViewSupportedByCamera).mockReturnValue(true);
|
||||
|
||||
const action = new CameraSelectAction(
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
);
|
||||
|
||||
await action.execute(api);
|
||||
|
||||
expect(api.getViewManager().setViewByParametersWithNewQuery).not.toBeCalled();
|
||||
});
|
||||
|
||||
it('without config', async () => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getConfigManager().getConfig).mockReturnValue(null);
|
||||
@@ -45,7 +68,7 @@ describe('should handle camera_select action', () => {
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -55,7 +78,7 @@ describe('should handle camera_select action', () => {
|
||||
expect.objectContaining({
|
||||
params: {
|
||||
view: 'timeline',
|
||||
camera: 'camera',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
failSafe: true,
|
||||
}),
|
||||
@@ -84,7 +107,7 @@ describe('should handle camera_select action', () => {
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -94,7 +117,7 @@ describe('should handle camera_select action', () => {
|
||||
expect.objectContaining({
|
||||
params: {
|
||||
view: 'clips',
|
||||
camera: 'camera',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
failSafe: true,
|
||||
}),
|
||||
@@ -106,7 +129,7 @@ describe('should handle camera_select action', () => {
|
||||
vi.mocked(api.getViewManager().getView).mockReturnValue(createView());
|
||||
vi.mocked(api.getViewManager().isViewSupportedByCamera).mockReturnValue(true);
|
||||
vi.mocked(api.getTriggersManager().getMostRecentlyTriggeredCameraID).mockReturnValue(
|
||||
'camera',
|
||||
'camera.office',
|
||||
);
|
||||
|
||||
const action = new CameraSelectAction(
|
||||
@@ -124,7 +147,7 @@ describe('should handle camera_select action', () => {
|
||||
expect.objectContaining({
|
||||
params: {
|
||||
view: 'live',
|
||||
camera: 'camera',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
failSafe: true,
|
||||
}),
|
||||
@@ -136,7 +159,7 @@ describe('should handle camera_select action', () => {
|
||||
vi.mocked(api.getViewManager().getView).mockReturnValue(createView());
|
||||
vi.mocked(api.getViewManager().isViewSupportedByCamera).mockReturnValue(true);
|
||||
vi.mocked(api.getTriggersManager().getMostRecentlyTriggeredCameraID).mockReturnValue(
|
||||
'camera',
|
||||
'camera.office',
|
||||
);
|
||||
|
||||
const action = new CameraSelectAction(
|
||||
|
||||
Reference in New Issue
Block a user