feat: Rename the card to advanced-camera-card (#1873)

Whilst the Frigate support in this card is the best among camera
engines, the name incorrectly suggests that Frigate is a requirement.
Instead, to broaden the appeal, change to more camera agnostic name.
This does not suggest any change in priority, role or support for
Frigate.

This change is likely to be bug prone, due to the size of the rename --
the code contains 1500+ references to "Frigate" most of which make sense
to rename, some which do not, all of which needed human assessment.

- Closes #1298


BREAKING CHANGE: References to `frigate-card` in all kinds of
configuration need to be updated to `advanced-camera-card`. An automated
config upgrade should take care of the majority of usecases (click `Edit
-> Upgrade -> Save`), though may not be perfect.
This commit is contained in:
Dermot Duffy
2025-02-06 19:32:32 -08:00
committed by GitHub
parent 43947b49dc
commit cc376a8be1
305 changed files with 4270 additions and 3686 deletions
+26 -26
View File
@@ -1,4 +1,4 @@
import { hasAction } from '@dermotduffy/custom-card-helpers';
import { hasAction as customCardHasAction } from '@dermotduffy/custom-card-helpers';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { actionSchema } from '../../src/config/types';
@@ -9,18 +9,18 @@ import {
createGeneralAction,
createLogAction,
createMediaPlayerAction,
createPTZAction,
createPTZControlsAction,
createPTZDigitalAction,
createPTZMultiAction,
createPTZControlsAction,
frigateCardHasAction,
getActionConfigGivenAction,
hasAction,
stopEventFromActivatingCardWideActions,
createPTZAction,
} from '../../src/utils/action';
vi.mock('@dermotduffy/custom-card-helpers');
describe('convertActionToFrigateCardCustomAction', () => {
describe('convertActionToAdvancedCameraCardCustomAction', () => {
it('should skip null action', () => {
expect(convertActionToCardCustomAction(null)).toBeFalsy();
});
@@ -28,12 +28,12 @@ describe('convertActionToFrigateCardCustomAction', () => {
it('should parse valid', () => {
expect(
convertActionToCardCustomAction({
action: 'custom:frigate-card-action',
frigate_card_action: 'download',
action: 'custom:advanced-camera-card-action',
advanced_camera_card_action: 'download',
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'download',
advanced_camera_card_action: 'download',
});
});
@@ -50,7 +50,7 @@ describe('createGeneralAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'clips',
advanced_camera_card_action: 'clips',
card_id: 'card_id',
});
});
@@ -62,7 +62,7 @@ describe('createCameraAction', () => {
{
action: 'fire-dom-event',
camera: 'camera',
frigate_card_action: 'camera_select',
advanced_camera_card_action: 'camera_select',
card_id: 'card_id',
},
);
@@ -77,7 +77,7 @@ describe('createMediaPlayerAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'media_player',
advanced_camera_card_action: 'media_player',
media_player: 'device',
media_player_action: 'play',
card_id: 'card_id',
@@ -93,7 +93,7 @@ describe('createDisplayModeAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'display_mode_select',
advanced_camera_card_action: 'display_mode_select',
display_mode: 'grid',
card_id: 'card_id',
});
@@ -108,7 +108,7 @@ describe('createPTZControlsAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'ptz_controls',
advanced_camera_card_action: 'ptz_controls',
enabled: true,
card_id: 'card_id',
});
@@ -123,7 +123,7 @@ describe('createPTZAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'ptz',
advanced_camera_card_action: 'ptz',
card_id: 'card_id',
});
});
@@ -139,7 +139,7 @@ describe('createPTZAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'ptz',
advanced_camera_card_action: 'ptz',
card_id: 'card_id',
camera: 'camera_id',
ptz_action: 'right',
@@ -157,7 +157,7 @@ describe('createPTZDigitalAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'ptz_digital',
advanced_camera_card_action: 'ptz_digital',
card_id: 'card_id',
});
});
@@ -176,7 +176,7 @@ describe('createPTZDigitalAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'ptz_digital',
advanced_camera_card_action: 'ptz_digital',
card_id: 'card_id',
target_id: 'target_id',
absolute: {
@@ -199,7 +199,7 @@ describe('createPTZMultiAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'ptz_multi',
advanced_camera_card_action: 'ptz_multi',
card_id: 'card_id',
ptz_action: 'right',
ptz_preset: 'preset',
@@ -216,7 +216,7 @@ describe('createPTZMultiAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'ptz_multi',
advanced_camera_card_action: 'ptz_multi',
card_id: 'card_id',
ptz_action: 'right',
ptz_phase: 'start',
@@ -233,7 +233,7 @@ describe('createLogAction', () => {
}),
).toEqual({
action: 'fire-dom-event',
frigate_card_action: 'log',
advanced_camera_card_action: 'log',
message: 'Hello, world!',
card_id: 'card_id',
level: 'info',
@@ -244,7 +244,7 @@ describe('createLogAction', () => {
describe('getActionConfigGivenAction', () => {
const action = actionSchema.parse({
action: 'fire-dom-event',
frigate_card_action: 'clips',
advanced_camera_card_action: 'clips',
});
it('should not handle undefined arguments', () => {
@@ -284,7 +284,7 @@ describe('getActionConfigGivenAction', () => {
});
});
describe('frigateCardHasAction', () => {
describe('hasAction', () => {
const action = actionSchema.parse({
action: 'toggle',
});
@@ -294,12 +294,12 @@ describe('frigateCardHasAction', () => {
});
it('should handle non-array case', () => {
expect(frigateCardHasAction(action)).toBeFalsy();
expect(hasAction).toBeCalledTimes(1);
expect(hasAction(action)).toBeFalsy();
expect(customCardHasAction).toBeCalledTimes(1);
});
it('should handle array case', () => {
expect(frigateCardHasAction([action, action, action])).toBeFalsy();
expect(hasAction).toBeCalledTimes(3);
expect(hasAction([action, action, action])).toBeFalsy();
expect(customCardHasAction).toBeCalledTimes(3);
});
});
+9 -9
View File
@@ -1,5 +1,5 @@
import { afterAll, describe, expect, it, vi } from 'vitest';
import { FrigateCardError } from '../../src/types';
import { AdvancedCameraCardError } from '../../src/types';
import {
allPromises,
arefloatsApproximatelyEqual,
@@ -9,7 +9,7 @@ import {
contentsChanged,
dayToDate,
desparsifyArrays,
dispatchFrigateCardEvent,
dispatchAdvancedCameraCardEvent,
errorToConsole,
formatDate,
formatDateAndTime,
@@ -32,13 +32,13 @@ import {
import { createSlot, createSlotHost } from '../test-utils';
// @vitest-environment jsdom
describe('dispatchFrigateCardEvent', () => {
describe('dispatchAdvancedCameraCardEvent', () => {
it('should dispatch event without data', () => {
const element = document.createElement('div');
const handler = vi.fn();
element.addEventListener('frigate-card:foo', handler);
element.addEventListener('advanced-camera-card:foo', handler);
dispatchFrigateCardEvent(element, 'foo');
dispatchAdvancedCameraCardEvent(element, 'foo');
expect(handler).toBeCalled();
});
@@ -49,8 +49,8 @@ describe('dispatchFrigateCardEvent', () => {
expect(ev.detail).toBe(data);
});
element.addEventListener('frigate-card:foo', handler);
dispatchFrigateCardEvent(element, 'foo', data);
element.addEventListener('advanced-camera-card:foo', handler);
dispatchAdvancedCameraCardEvent(element, 'foo', data);
expect(handler).toBeCalled();
});
});
@@ -112,9 +112,9 @@ describe('errorToConsole', () => {
errorToConsole(error);
expect(spy).toHaveBeenCalledWith('ERROR');
});
it('should log with context given frigate card error', () => {
it('should log with context given advanced camera card error', () => {
const data = { foo: 2 };
const error = new FrigateCardError('ERROR', { foo: 2 });
const error = new AdvancedCameraCardError('ERROR', { foo: 2 });
errorToConsole(error);
expect(spy).toHaveBeenCalledWith(error, data);
});
+9 -9
View File
@@ -4,8 +4,8 @@ import { mock } from 'vitest-mock-extended';
import { getLanguage } from '../../src/localize/localize';
import { getDiagnostics, getReleaseVersion } from '../../src/utils/diagnostics.js';
import { DeviceRegistryManager } from '../../src/utils/ha/registry/device';
import { createHASS, createRegistryDevice } from '../test-utils';
import { homeAssistantWSRequest } from '../../src/utils/ha/ws-request';
import { createHASS, createRegistryDevice } from '../test-utils';
vi.mock('../../package.json', () => ({
default: {
@@ -21,7 +21,7 @@ vi.mock('../../src/utils/ha/ws-request.js');
describe('getReleaseVersion', () => {
it('should get release version', () => {
expect(getReleaseVersion()).toBe('__FRIGATE_CARD_RELEASE_VERSION__');
expect(getReleaseVersion()).toBe('__ADVANCED_CAMERA_CARD_RELEASE_VERSION__');
});
});
@@ -38,7 +38,7 @@ describe('getDiagnostics', () => {
vi.setSystemTime(now);
vi.mocked(getLanguage).mockReturnValue('en');
vi.stubGlobal('navigator', { userAgent: 'FrigateCardTest/1.0' });
vi.stubGlobal('navigator', { userAgent: 'AdvancedCameraCardTest/1.0' });
});
afterEach(() => {
@@ -76,8 +76,8 @@ describe('getDiagnostics', () => {
cameras: [{ camera_entity: 'camera.office' }],
}),
).toEqual({
browser: 'FrigateCardTest/1.0',
card_version: '__FRIGATE_CARD_RELEASE_VERSION__',
browser: 'AdvancedCameraCardTest/1.0',
card_version: '__ADVANCED_CAMERA_CARD_RELEASE_VERSION__',
config: {
cameras: [{ camera_entity: 'camera.office' }],
},
@@ -130,8 +130,8 @@ describe('getDiagnostics', () => {
it('should fetch diagnostics without hass or config', async () => {
expect(await getDiagnostics()).toEqual({
browser: 'FrigateCardTest/1.0',
card_version: '__FRIGATE_CARD_RELEASE_VERSION__',
browser: 'AdvancedCameraCardTest/1.0',
card_version: '__ADVANCED_CAMERA_CARD_RELEASE_VERSION__',
git: {
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
@@ -156,8 +156,8 @@ describe('getDiagnostics', () => {
deviceRegistryManager.getMatchingDevices.mockResolvedValue([]);
expect(await getDiagnostics(hass, deviceRegistryManager)).toEqual({
browser: 'FrigateCardTest/1.0',
card_version: '__FRIGATE_CARD_RELEASE_VERSION__',
browser: 'AdvancedCameraCardTest/1.0',
card_version: '__ADVANCED_CAMERA_CARD_RELEASE_VERSION__',
git: {
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
+10 -4
View File
@@ -112,7 +112,10 @@ describe('CarouselController', () => {
const parent = createParent({ children: children });
const forceSelectListener = vi.fn();
parent.addEventListener('frigate-card:carousel:force-select', forceSelectListener);
parent.addEventListener(
'advanced-camera-card:carousel:force-select',
forceSelectListener,
);
const carousel = new CarouselController(createRoot(), parent);
@@ -131,7 +134,10 @@ describe('CarouselController', () => {
const parent = createParent({ children: children });
const forceSelectListener = vi.fn();
parent.addEventListener('frigate-card:carousel:force-select', forceSelectListener);
parent.addEventListener(
'advanced-camera-card:carousel:force-select',
forceSelectListener,
);
const carousel = new CarouselController(createRoot(), parent);
@@ -147,7 +153,7 @@ describe('CarouselController', () => {
new CarouselController(createRoot(), parent);
const selectHandler = vi.fn();
parent.addEventListener('frigate-card:carousel:select', selectHandler);
parent.addEventListener('advanced-camera-card:carousel:select', selectHandler);
getEmblaApi()?.selectedScrollSnap.mockReturnValue(6);
getEmblaApi()?.slideNodes.mockReturnValue(children);
@@ -169,7 +175,7 @@ describe('CarouselController', () => {
new CarouselController(createRoot(), parent);
const selectHandler = vi.fn();
parent.addEventListener('frigate-card:carousel:select', selectHandler);
parent.addEventListener('advanced-camera-card:carousel:select', selectHandler);
getEmblaApi()?.selectedScrollSnap.mockReturnValue(1000);
getEmblaApi()?.slideNodes.mockReturnValue(children);
@@ -50,7 +50,7 @@ describe('AutoMediaLoadedInfo', () => {
plugin.init(emblaApi, createTestEmblaOptionHandler());
const mediaLoadedHandler = vi.fn();
parent.addEventListener('frigate-card:media:' + type, mediaLoadedHandler);
parent.addEventListener('advanced-camera-card:media:' + type, mediaLoadedHandler);
if (type === 'loaded') {
dispatchExistingMediaLoadedInfoAsEvent(children[5], createMediaLoadedInfo());
} else if (type === 'unloaded') {
@@ -76,19 +76,19 @@ describe('AutoMediaLoadedInfo', () => {
plugin.init(emblaApi, createTestEmblaOptionHandler());
const mediaLoadedHandler = vi.fn();
parent.addEventListener('frigate-card:media:loaded', mediaLoadedHandler);
parent.addEventListener('advanced-camera-card:media:loaded', mediaLoadedHandler);
dispatchExistingMediaLoadedInfoAsEvent(children[5], createMediaLoadedInfo());
vi.mocked(emblaApi.selectedScrollSnap).mockReturnValue(4);
emblaApi
.containerNode()
.dispatchEvent(new Event('frigate-card:carousel:force-select'));
.dispatchEvent(new Event('advanced-camera-card:carousel:force-select'));
expect(mediaLoadedHandler).not.toBeCalled();
vi.mocked(emblaApi.selectedScrollSnap).mockReturnValue(5);
emblaApi
.containerNode()
.dispatchEvent(new Event('frigate-card:carousel:force-select'));
.dispatchEvent(new Event('advanced-camera-card:carousel:force-select'));
expect(mediaLoadedHandler).toBeCalled();
});
});
+10 -10
View File
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { FrigateCardMediaPlayer, MediaLoadedCapabilities } from '../../src/types';
import { AdvancedCameraCardMediaPlayer, MediaLoadedCapabilities } from '../../src/types';
import {
createMediaLoadedInfo,
dispatchExistingMediaLoadedInfoAsEvent,
@@ -14,7 +14,7 @@ import {
import { createMediaLoadedInfo as createTestMediaLoadedInfo } from '../test-utils.js';
const options = {
player: mock<FrigateCardMediaPlayer>(),
player: mock<AdvancedCameraCardMediaPlayer>(),
capabilities: mock<MediaLoadedCapabilities>(),
};
@@ -86,14 +86,14 @@ describe('createMediaLoadedInfo', () => {
// @vitest-environment jsdom
describe('dispatchMediaLoadedEvent', () => {
const options = {
player: mock<FrigateCardMediaPlayer>(),
player: mock<AdvancedCameraCardMediaPlayer>(),
capabilities: mock<MediaLoadedCapabilities>(),
};
it('should dispatch', () => {
const handler = vi.fn();
const div = document.createElement('div');
div.addEventListener('frigate-card:media:loaded', handler);
div.addEventListener('advanced-camera-card:media:loaded', handler);
// Need to write readonly properties.
const img = document.createElement('img');
@@ -115,7 +115,7 @@ describe('dispatchMediaLoadedEvent', () => {
it('should not dispatch', () => {
const handler = vi.fn();
const div = document.createElement('div');
div.addEventListener('frigate-card:media:loaded', handler);
div.addEventListener('advanced-camera-card:media:loaded', handler);
dispatchMediaLoadedEvent(div, div, options);
expect(handler).not.toBeCalled();
@@ -127,7 +127,7 @@ describe('dispatchExistingMediaLoadedInfoAsEvent', () => {
it('should dispatch', () => {
const handler = vi.fn();
const div = document.createElement('div');
div.addEventListener('frigate-card:media:loaded', handler);
div.addEventListener('advanced-camera-card:media:loaded', handler);
const info = createTestMediaLoadedInfo();
dispatchExistingMediaLoadedInfoAsEvent(div, info);
@@ -144,7 +144,7 @@ describe('dispatchMediaUnloadedEvent', () => {
it('should dispatch', () => {
const handler = vi.fn();
const div = document.createElement('div');
div.addEventListener('frigate-card:media:unloaded', handler);
div.addEventListener('advanced-camera-card:media:unloaded', handler);
dispatchMediaUnloadedEvent(div);
expect(handler).toBeCalled();
@@ -156,7 +156,7 @@ describe('dispatchMediaVolumeChangeEvent', () => {
it('should dispatch', () => {
const handler = vi.fn();
const div = document.createElement('div');
div.addEventListener('frigate-card:media:volumechange', handler);
div.addEventListener('advanced-camera-card:media:volumechange', handler);
dispatchMediaVolumeChangeEvent(div);
expect(handler).toBeCalled();
@@ -168,7 +168,7 @@ describe('dispatchMediaPlayEvent', () => {
it('should dispatch', () => {
const handler = vi.fn();
const div = document.createElement('div');
div.addEventListener('frigate-card:media:play', handler);
div.addEventListener('advanced-camera-card:media:play', handler);
dispatchMediaPlayEvent(div);
expect(handler).toBeCalled();
@@ -180,7 +180,7 @@ describe('dispatchMediaPauseEvent', () => {
it('should dispatch', () => {
const handler = vi.fn();
const div = document.createElement('div');
div.addEventListener('frigate-card:media:pause', handler);
div.addEventListener('advanced-camera-card:media:pause', handler);
dispatchMediaPauseEvent(div);
expect(handler).toBeCalled();
+41 -23
View File
@@ -11,19 +11,19 @@ describe('updateElementStyleFromMediaLayoutConfig', () => {
fit: 'cover',
});
expect(video.style.getPropertyValue('--frigate-card-media-layout-fit')).toBe(
'cover',
);
expect(
video.style.getPropertyValue('--advanced-camera-card-media-layout-fit'),
).toBe('cover');
});
it('unset', () => {
const video = document.createElement('video');
video.style.setProperty('--frigate-card-media-layout-fit', 'cover');
video.style.setProperty('--advanced-camera-card-media-layout-fit', 'cover');
updateElementStyleFromMediaLayoutConfig(video);
expect(
video.style.getPropertyValue('--frigate-card-media-layout-fit'),
video.style.getPropertyValue('--advanced-camera-card-media-layout-fit'),
).toBeFalsy();
});
});
@@ -40,25 +40,25 @@ describe('updateElementStyleFromMediaLayoutConfig', () => {
});
expect(
video.style.getPropertyValue('--frigate-card-media-layout-position-x'),
video.style.getPropertyValue('--advanced-camera-card-media-layout-position-x'),
).toBe('10%');
expect(
video.style.getPropertyValue('--frigate-card-media-layout-position-y'),
video.style.getPropertyValue('--advanced-camera-card-media-layout-position-y'),
).toBe('20%');
});
it('unset', () => {
const video = document.createElement('video');
video.style.setProperty('--frigate-card-media-layout-position-x', '10%');
video.style.setProperty('--frigate-card-media-layout-position-y', '20%');
video.style.setProperty('--advanced-camera-card-media-layout-position-x', '10%');
video.style.setProperty('--advanced-camera-card-media-layout-position-y', '20%');
updateElementStyleFromMediaLayoutConfig(video);
expect(
video.style.getPropertyValue('--frigate-card-media-layout-position-x'),
video.style.getPropertyValue('--advanced-camera-card-media-layout-position-x'),
).toBeFalsy();
expect(
video.style.getPropertyValue('--frigate-card-media-layout-position-y'),
video.style.getPropertyValue('--advanced-camera-card-media-layout-position-y'),
).toBeFalsy();
});
});
@@ -77,39 +77,57 @@ describe('updateElementStyleFromMediaLayoutConfig', () => {
});
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-top'),
video.style.getPropertyValue('--advanced-camera-card-media-layout-view-box-top'),
).toBe('1%');
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-bottom'),
video.style.getPropertyValue(
'--advanced-camera-card-media-layout-view-box-bottom',
),
).toBe('2%');
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-left'),
video.style.getPropertyValue(
'--advanced-camera-card-media-layout-view-box-left',
),
).toBe('3%');
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-right'),
video.style.getPropertyValue(
'--advanced-camera-card-media-layout-view-box-right',
),
).toBe('4%');
});
it('unset', () => {
const video = document.createElement('video');
video.style.setProperty('--frigate-card-media-layout-view-box-top', '1%');
video.style.setProperty('--frigate-card-media-layout-view-box-bottom', '2%');
video.style.setProperty('--frigate-card-media-layout-view-box-left', '3%');
video.style.setProperty('--frigate-card-media-layout-view-box-right', '4%');
video.style.setProperty('--advanced-camera-card-media-layout-view-box-top', '1%');
video.style.setProperty(
'--advanced-camera-card-media-layout-view-box-bottom',
'2%',
);
video.style.setProperty('--advanced-camera-card-media-layout-view-box-left', '3%');
video.style.setProperty(
'--advanced-camera-card-media-layout-view-box-right',
'4%',
);
updateElementStyleFromMediaLayoutConfig(video);
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-top'),
video.style.getPropertyValue('--advanced-camera-card-media-layout-view-box-top'),
).toBeFalsy();
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-bottom'),
video.style.getPropertyValue(
'--advanced-camera-card-media-layout-view-box-bottom',
),
).toBeFalsy();
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-left'),
video.style.getPropertyValue(
'--advanced-camera-card-media-layout-view-box-left',
),
).toBeFalsy();
expect(
video.style.getPropertyValue('--frigate-card-media-layout-view-box-right'),
video.style.getPropertyValue(
'--advanced-camera-card-media-layout-view-box-right',
),
).toBeFalsy();
});
});
+10 -10
View File
@@ -1,8 +1,8 @@
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { FrigateCardMediaPlayer } from '../../src/types.js';
import { AdvancedCameraCardMediaPlayer } from '../../src/types.js';
import {
FrigateCardHTMLVideoElement,
AdvancedCameraCardHTMLVideoElement,
MEDIA_LOAD_CONTROLS_HIDE_SECONDS,
hideMediaControlsTemporarily,
playMediaMutingIfNecessary,
@@ -19,7 +19,7 @@ describe('setControlsOnVideo', () => {
});
it('should stop timer', () => {
const video: FrigateCardHTMLVideoElement = document.createElement('video');
const video: AdvancedCameraCardHTMLVideoElement = document.createElement('video');
hideMediaControlsTemporarily(video);
expect(video._controlsHideTimer).toBeTruthy();
@@ -41,7 +41,7 @@ describe('hideMediaControlsTemporarily', () => {
});
it('should set controls', () => {
const video: FrigateCardHTMLVideoElement = document.createElement('video');
const video: AdvancedCameraCardHTMLVideoElement = document.createElement('video');
video.controls = true;
hideMediaControlsTemporarily(video);
@@ -53,7 +53,7 @@ describe('hideMediaControlsTemporarily', () => {
});
it('should add event listener that resets controls', () => {
const video: FrigateCardHTMLVideoElement = document.createElement('video');
const video: AdvancedCameraCardHTMLVideoElement = document.createElement('video');
video.controls = true;
hideMediaControlsTemporarily(video);
@@ -77,7 +77,7 @@ class NotAllowedError extends Error {
describe('playMediaMutingIfNecessary', () => {
it('should play', async () => {
const player = mock<FrigateCardMediaPlayer>();
const player = mock<AdvancedCameraCardMediaPlayer>();
const video = mock<HTMLVideoElement>();
video.play.mockResolvedValue();
await playMediaMutingIfNecessary(player, video);
@@ -85,7 +85,7 @@ describe('playMediaMutingIfNecessary', () => {
});
it('should mute if not allowed to play and unmuted', async () => {
const player = mock<FrigateCardMediaPlayer>();
const player = mock<AdvancedCameraCardMediaPlayer>();
player.isMuted.mockReturnValue(false);
player.mute.mockResolvedValue();
@@ -100,7 +100,7 @@ describe('playMediaMutingIfNecessary', () => {
});
it('should not mute if not allowed to play and already unmuted', async () => {
const player = mock<FrigateCardMediaPlayer>();
const player = mock<AdvancedCameraCardMediaPlayer>();
player.isMuted.mockReturnValue(true);
const video = mock<HTMLVideoElement>();
@@ -114,7 +114,7 @@ describe('playMediaMutingIfNecessary', () => {
});
it('should ignore exception if subsequent play call throws', async () => {
const player = mock<FrigateCardMediaPlayer>();
const player = mock<AdvancedCameraCardMediaPlayer>();
player.isMuted.mockReturnValue(false);
const video = mock<HTMLVideoElement>();
@@ -128,7 +128,7 @@ describe('playMediaMutingIfNecessary', () => {
});
it('should ignore calls without a video', async () => {
const player = mock<FrigateCardMediaPlayer>();
const player = mock<AdvancedCameraCardMediaPlayer>();
player.isMuted.mockReturnValue(false);
await playMediaMutingIfNecessary(player);
+2 -2
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { Capabilities } from '../../src/camera-manager/capabilities';
import { FrigateCardView } from '../../src/config/types';
import { AdvancedCameraCardView } from '../../src/config/types';
import { IMAGE_VIEW_ZOOM_TARGET_SENTINEL } from '../../src/const';
import {
getPTZTarget,
@@ -124,7 +124,7 @@ describe('getPTZTarget', () => {
describe('in non-media views', () => {
it.each([['timeline' as const], ['diagnostics' as const]])(
'%s',
(viewName: FrigateCardView) => {
(viewName: AdvancedCameraCardView) => {
const view = createView({
view: viewName,
});