Draws significant inspiration (and direct styling) from https://github.com/dermotduffy/advanced-camera-card/pull/2447 . Thank you @Maudfer ! BREAKING CHANGE: The microphone condition previously bundled two unrelated signals — whether a two-way-audio session was connected and whether the microphone was muted. Connection state is now its own dedicated call condition, and microphone is reserved purely for mute state. Configs are upgraded automatically (the card rewrites affected conditions under overrides, elements, and automations). If you maintain config by hand, convert as follows: If you only used connected: # Before ```yaml condition: microphone connected: true ``` # After ```yaml condition: call call: true ``` If you used both connected and muted — they must be split into two conditions, since they no longer live together: # Before ```yaml condition: microphone connected: true muted: false ``` # After ```yaml condition: and conditions: - condition: call call: true - condition: microphone muted: false ```
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { SubstreamViewModifier } from '../../../../src/card-controller/view/modifiers/substream';
|
|
import { createView } from '../../../test-utils';
|
|
|
|
describe('SubstreamViewModifier', () => {
|
|
it('should write the override for the selected camera', () => {
|
|
const view = createView({ camera: 'camera' });
|
|
|
|
new SubstreamViewModifier('substream').modify(view);
|
|
|
|
expect(view.context?.live?.overrides?.get('camera')).toBe('substream');
|
|
});
|
|
|
|
it('should clear the selected camera override when no substream is given', () => {
|
|
const view = createView({
|
|
camera: 'camera',
|
|
context: { live: { overrides: new Map([['camera', 'substream']]) } },
|
|
});
|
|
|
|
new SubstreamViewModifier().modify(view);
|
|
|
|
expect(view.context?.live?.overrides?.get('camera')).toBeUndefined();
|
|
});
|
|
|
|
it('should write the override for an explicit camera', () => {
|
|
const view = createView({
|
|
camera: 'camera',
|
|
context: { live: { overrides: new Map([['camera', 'substream']]) } },
|
|
});
|
|
|
|
new SubstreamViewModifier('other-substream', 'other-camera').modify(view);
|
|
|
|
expect(view.context?.live?.overrides?.get('other-camera')).toBe('other-substream');
|
|
expect(view.context?.live?.overrides?.get('camera')).toBe('substream');
|
|
});
|
|
|
|
it('should clear the override for an explicit camera', () => {
|
|
const view = createView({
|
|
camera: 'camera',
|
|
context: { live: { overrides: new Map([['other-camera', 'other-substream']]) } },
|
|
});
|
|
|
|
new SubstreamViewModifier(undefined, 'other-camera').modify(view);
|
|
|
|
expect(view.context?.live?.overrides?.get('other-camera')).toBeUndefined();
|
|
});
|
|
|
|
it('should no-op for a view without a camera', () => {
|
|
const view = createView({ camera: null });
|
|
|
|
new SubstreamViewModifier('substream').modify(view);
|
|
|
|
expect(view.context).toBeNull();
|
|
});
|
|
});
|