Add support for pre-defined zoom/pan settings.

This commit is contained in:
Dermot Duffy
2024-04-27 14:55:38 -07:00
parent 246dd7ff54
commit 7917e5c537
59 changed files with 1981 additions and 638 deletions
+58 -2
View File
@@ -196,7 +196,6 @@ describe('ActionsManager.handleInteraction', () => {
manager.handleInteractionEvent(
new CustomEvent<Interaction>('event', {
// Malformed interaction type.
detail: { action: 'double_finger_snap' } as unknown as Interaction,
}),
@@ -800,11 +799,68 @@ describe('ActionsManager.executeAction', () => {
})!,
);
expect(api.getViewManager().setViewWithNewContext).toBeCalledWith(
expect(api.getViewManager().setViewWithMergedContext).toBeCalledWith(
expect.objectContaining({ live: { ptzVisible: true } }),
);
});
describe('should handle change_zoom action', () => {
it('default', async () => {
const api = createCardAPI();
const manager = new ActionsManager(api);
await manager.executeFrigateAction(
createAction({
frigate_card_action: 'change_zoom',
target_id: 'camera.office',
})!,
);
expect(api.getViewManager().setViewWithMergedContext).toBeCalledWith(
expect.objectContaining({
zoom: {
'camera.office': {
zoom: {},
},
},
}),
);
});
it('non-default', async () => {
const api = createCardAPI();
const manager = new ActionsManager(api);
await manager.executeFrigateAction(
createAction({
frigate_card_action: 'change_zoom',
target_id: 'camera.office',
zoom: 2,
pan: {
x: 3,
y: 4,
},
})!,
);
expect(api.getViewManager().setViewWithMergedContext).toBeCalledWith(
expect.objectContaining({
zoom: {
'camera.office': {
zoom: {
zoom: 2,
pan: {
x: 3,
y: 4,
},
},
},
},
}),
);
});
});
it('should handle unknown action', async () => {
const manager = new ActionsManager(createCardAPI());