feat: Make cameras optional (#2343)

This commit is contained in:
Dermot Duffy
2026-02-13 20:21:05 -08:00
committed by GitHub
parent 21f9469784
commit 93f1f08e51
61 changed files with 1312 additions and 557 deletions
@@ -1,4 +1,4 @@
import { describe, expect, it, vi } from 'vitest';
import { describe, expect, it } from 'vitest';
import { EffectAction } from '../../../../src/card-controller/actions/actions/effect';
import { createEffectAction } from '../../../../src/utils/action';
import { createCardAPI } from '../../../test-utils';
@@ -11,7 +11,7 @@ describe('EffectAction', () => {
await action.execute(api);
expect(api.getEffectsControllerAPI()?.startEffect).toHaveBeenCalledWith('snow');
expect(api.getEffectsManager().startEffect).toHaveBeenCalledWith('snow');
});
it('should call stopEffect when action is stop', async () => {
@@ -21,7 +21,7 @@ describe('EffectAction', () => {
await action.execute(api);
expect(api.getEffectsControllerAPI()?.stopEffect).toHaveBeenCalledWith('snow');
expect(api.getEffectsManager().stopEffect).toHaveBeenCalledWith('snow');
});
it('should call toggleEffect when action is toggle', async () => {
@@ -31,16 +31,7 @@ describe('EffectAction', () => {
await action.execute(api);
expect(api.getEffectsControllerAPI()?.toggleEffect).toHaveBeenCalledWith('snow');
});
it('should not throw when effectsControllerAPI is null', async () => {
const api = createCardAPI();
vi.mocked(api.getEffectsControllerAPI).mockReturnValue(null);
const actionConfig = createEffectAction('snow', 'start');
const action = new EffectAction({}, actionConfig);
await expect(action.execute(api)).resolves.toBeUndefined();
expect(api.getEffectsManager().toggleEffect).toHaveBeenCalledWith('snow');
});
it('should have a no-op stop method', async () => {
@@ -101,4 +101,28 @@ describe('should handle media_player action', () => {
expect(api.getMediaPlayerManager().playMedia).not.toBeCalled();
});
it('to not play live without camera', async () => {
const api = createCardAPI();
vi.mocked(api.getViewManager().getView).mockReturnValue(
createView({
camera: null,
view: 'live',
}),
);
const action = new MediaPlayerAction(
{},
{
action: 'fire-dom-event',
advanced_camera_card_action: 'media_player',
media_player_action: 'play',
media_player: 'this_is_a_media_player',
},
);
await action.execute(api);
expect(api.getMediaPlayerManager().playLive).not.toBeCalled();
});
});