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:
@@ -6,17 +6,24 @@ import {
|
||||
FrigateRecordingViewMedia,
|
||||
} from '../../../src/camera-manager/frigate/media';
|
||||
import { FrigateEvent, eventSchema } from '../../../src/camera-manager/frigate/types.js';
|
||||
import { StateWatcher } from '../../../src/card-controller/hass/state-watcher';
|
||||
import { PTZAction } from '../../../src/config/ptz';
|
||||
import {
|
||||
AdvancedCameraCardView,
|
||||
CameraConfig,
|
||||
FrigateCardView,
|
||||
RawFrigateCardConfig,
|
||||
RawAdvancedCameraCardConfig,
|
||||
} from '../../../src/config/types';
|
||||
import {
|
||||
EntityRegistryManager,
|
||||
createEntityRegistryCache,
|
||||
} from '../../../src/utils/ha/registry/entity';
|
||||
import { ViewMedia } from '../../../src/view/media';
|
||||
import { TestViewMedia, createCameraConfig, createHASS } from '../../test-utils';
|
||||
|
||||
const createEngine = (): FrigateCameraManagerEngine => {
|
||||
return new FrigateCameraManagerEngine(
|
||||
new EntityRegistryManager(createEntityRegistryCache()),
|
||||
new StateWatcher(),
|
||||
new RecordingSegmentsCache(),
|
||||
new RequestCache(),
|
||||
);
|
||||
@@ -75,7 +82,9 @@ const createSnapshotMedia = (): FrigateEventViewMedia => {
|
||||
);
|
||||
};
|
||||
|
||||
const createFrigateCameraConfig = (config?: RawFrigateCardConfig): CameraConfig => {
|
||||
const createFrigateCameraConfig = (
|
||||
config?: RawAdvancedCameraCardConfig,
|
||||
): CameraConfig => {
|
||||
return createCameraConfig({
|
||||
frigate: {
|
||||
camera_name: 'camera-1',
|
||||
@@ -345,7 +354,7 @@ describe('getCameraEndpoints', () => {
|
||||
['clips' as const],
|
||||
['snapshot' as const],
|
||||
['snapshots' as const],
|
||||
])('%s', (viewName: FrigateCardView) => {
|
||||
])('%s', (viewName: AdvancedCameraCardView) => {
|
||||
const endpoints = createEngine().getCameraEndpoints(
|
||||
createCameraConfig({
|
||||
frigate: {
|
||||
@@ -369,7 +378,7 @@ describe('getCameraEndpoints', () => {
|
||||
|
||||
it.each([['recording' as const], ['recordings' as const]])(
|
||||
'%s',
|
||||
(viewName: FrigateCardView) => {
|
||||
(viewName: AdvancedCameraCardView) => {
|
||||
const endpoints = createEngine().getCameraEndpoints(
|
||||
createCameraConfig({
|
||||
frigate: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mock } from 'vitest-mock-extended';
|
||||
import { GenericCameraManagerEngine } from '../../../src/camera-manager/generic/engine-generic';
|
||||
import { Engine, QueryResultsType, QueryType } from '../../../src/camera-manager/types';
|
||||
import { StateWatcherSubscriptionInterface } from '../../../src/card-controller/hass/state-watcher';
|
||||
import { CameraConfig, RawFrigateCardConfig } from '../../../src/config/types';
|
||||
import { CameraConfig, RawAdvancedCameraCardConfig } from '../../../src/config/types';
|
||||
import {
|
||||
TestViewMedia,
|
||||
createCameraConfig,
|
||||
@@ -16,7 +16,9 @@ const createEngine = (): GenericCameraManagerEngine => {
|
||||
return new GenericCameraManagerEngine(mock<StateWatcherSubscriptionInterface>());
|
||||
};
|
||||
|
||||
const createGenericCameraConfig = (config?: RawFrigateCardConfig): CameraConfig => {
|
||||
const createGenericCameraConfig = (
|
||||
config?: RawAdvancedCameraCardConfig,
|
||||
): CameraConfig => {
|
||||
return createCameraConfig(config);
|
||||
};
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ describe('CameraManager', async () => {
|
||||
expect(await manager.initializeCamerasFromConfig()).toBeFalsy();
|
||||
expect(api.getMessageManager().setErrorIfHigherPriority).toBeCalledWith(
|
||||
new Error(
|
||||
'Duplicate Frigate camera id for the following camera, ' +
|
||||
'Duplicate camera id for the following camera, ' +
|
||||
"use the 'id' parameter to uniquely identify cameras",
|
||||
),
|
||||
'Camera initialization failed',
|
||||
@@ -997,7 +997,9 @@ describe('CameraManager', async () => {
|
||||
|
||||
const result: CameraManagerCameraMetadata = {
|
||||
title: 'My Camera',
|
||||
icon: 'mdi:camera',
|
||||
icon: {
|
||||
icon: 'mdi:camera',
|
||||
},
|
||||
};
|
||||
vi.mocked(engine.getCameraMetadata).mockReturnValue(result);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
Interaction,
|
||||
InteractionName,
|
||||
} from '../../../src/card-controller/actions/actions-manager';
|
||||
import { FrigateCardView } from '../../../src/config/types';
|
||||
import { AdvancedCameraCardView } from '../../../src/config/types';
|
||||
import { createLogAction } from '../../../src/utils/action';
|
||||
import {
|
||||
createAction,
|
||||
@@ -114,7 +114,7 @@ describe('ActionsManager', () => {
|
||||
},
|
||||
],
|
||||
['timeline' as const, {}],
|
||||
])('%s', (viewName: FrigateCardView, result: Record<string, unknown>) => {
|
||||
])('%s', (viewName: AdvancedCameraCardView, result: Record<string, unknown>) => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getViewManager().getView).mockReturnValue(
|
||||
createView({ view: viewName }),
|
||||
@@ -231,7 +231,7 @@ describe('ActionsManager', () => {
|
||||
|
||||
const consoleSpy = vi.spyOn(global.console, 'info').mockReturnValue(undefined);
|
||||
await manager.handleActionExecutionRequestEvent(
|
||||
new CustomEvent('frigate-card:action:execution-request', {
|
||||
new CustomEvent('advanced-camera-card:action:execution-request', {
|
||||
detail: { action: createLogAction('Hello, world!') },
|
||||
}),
|
||||
);
|
||||
@@ -266,7 +266,7 @@ describe('ActionsManager', () => {
|
||||
const promise = manager.executeActions([
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
createAction({
|
||||
frigate_card_action: 'sleep',
|
||||
advanced_camera_card_action: 'sleep',
|
||||
duration: {
|
||||
m: 1,
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('should handle camera_select action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera',
|
||||
},
|
||||
);
|
||||
@@ -44,7 +44,7 @@ describe('should handle camera_select action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera',
|
||||
},
|
||||
);
|
||||
@@ -83,7 +83,7 @@ describe('should handle camera_select action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera',
|
||||
},
|
||||
);
|
||||
@@ -113,7 +113,7 @@ describe('should handle camera_select action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
triggered: true,
|
||||
},
|
||||
);
|
||||
@@ -143,7 +143,7 @@ describe('should handle camera_select action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -159,7 +159,7 @@ describe('should handle camera_select action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle camera_ui action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_ui',
|
||||
advanced_camera_card_action: 'camera_ui',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle default action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'default',
|
||||
advanced_camera_card_action: 'default',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle default action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'display_mode_select',
|
||||
advanced_camera_card_action: 'display_mode_select',
|
||||
display_mode: 'grid',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle download action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'download',
|
||||
advanced_camera_card_action: 'download',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle expand action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'expand',
|
||||
advanced_camera_card_action: 'expand',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle fullscreen action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'fullscreen',
|
||||
advanced_camera_card_action: 'fullscreen',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ it('should handle log action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'log',
|
||||
advanced_camera_card_action: 'log',
|
||||
message: 'Hello, world!',
|
||||
level: 'warn',
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('should handle media_player action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'media_player',
|
||||
advanced_camera_card_action: 'media_player',
|
||||
media_player_action: 'stop',
|
||||
media_player: 'this_is_a_media_player',
|
||||
},
|
||||
@@ -38,7 +38,7 @@ describe('should handle media_player action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'media_player',
|
||||
advanced_camera_card_action: 'media_player',
|
||||
media_player_action: 'play',
|
||||
media_player: 'this_is_a_media_player',
|
||||
},
|
||||
@@ -65,7 +65,7 @@ describe('should handle media_player action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'media_player',
|
||||
advanced_camera_card_action: 'media_player',
|
||||
media_player_action: 'play',
|
||||
media_player: 'this_is_a_media_player',
|
||||
},
|
||||
@@ -91,7 +91,7 @@ describe('should handle media_player action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'media_player',
|
||||
advanced_camera_card_action: 'media_player',
|
||||
media_player_action: 'play',
|
||||
media_player: 'this_is_a_media_player',
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle menu toggle action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'menu_toggle',
|
||||
advanced_camera_card_action: 'menu_toggle',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle microphone_connect action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_connect',
|
||||
advanced_camera_card_action: 'microphone_connect',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle microphone_disconnect action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_disconnect',
|
||||
advanced_camera_card_action: 'microphone_disconnect',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle microphone_mute action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_mute',
|
||||
advanced_camera_card_action: 'microphone_mute',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle microphone_unmute action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_unmute',
|
||||
advanced_camera_card_action: 'microphone_unmute',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { MuteAction } from '../../../../src/card-controller/actions/actions/mute';
|
||||
import { FrigateCardMediaPlayer } from '../../../../src/types';
|
||||
import { AdvancedCameraCardMediaPlayer } from '../../../../src/types';
|
||||
import { createCardAPI, createMediaLoadedInfo } from '../../../test-utils';
|
||||
|
||||
it('should handle mute action', async () => {
|
||||
const api = createCardAPI();
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
||||
createMediaLoadedInfo({
|
||||
player: player,
|
||||
@@ -16,7 +16,7 @@ it('should handle mute action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'mute',
|
||||
advanced_camera_card_action: 'mute',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { PauseAction } from '../../../../src/card-controller/actions/actions/pause';
|
||||
import { FrigateCardMediaPlayer } from '../../../../src/types';
|
||||
import { AdvancedCameraCardMediaPlayer } from '../../../../src/types';
|
||||
import { createCardAPI, createMediaLoadedInfo } from '../../../test-utils';
|
||||
|
||||
it('should handle pause action', async () => {
|
||||
const api = createCardAPI();
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
||||
createMediaLoadedInfo({
|
||||
player: player,
|
||||
@@ -16,7 +16,7 @@ it('should handle pause action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'pause',
|
||||
advanced_camera_card_action: 'pause',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { PlayAction } from '../../../../src/card-controller/actions/actions/play';
|
||||
import { FrigateCardMediaPlayer } from '../../../../src/types';
|
||||
import { AdvancedCameraCardMediaPlayer } from '../../../../src/types';
|
||||
import { createCardAPI, createMediaLoadedInfo } from '../../../test-utils';
|
||||
|
||||
it('should handle play action', async () => {
|
||||
const api = createCardAPI();
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
||||
createMediaLoadedInfo({
|
||||
player: player,
|
||||
@@ -16,7 +16,7 @@ it('should handle play action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'play',
|
||||
advanced_camera_card_action: 'play',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle ptz_controls action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_controls',
|
||||
advanced_camera_card_action: 'ptz_controls',
|
||||
enabled: true,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('should handle ptz digital action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
absolute: {
|
||||
zoom: 2,
|
||||
pan: {
|
||||
@@ -70,7 +70,7 @@ describe('should handle ptz digital action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -93,7 +93,7 @@ describe('should handle ptz digital action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
ptz_action: 'left',
|
||||
},
|
||||
);
|
||||
@@ -117,7 +117,7 @@ describe('should handle ptz digital action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
ptz_action: 'left',
|
||||
},
|
||||
);
|
||||
@@ -330,7 +330,7 @@ describe('should handle ptz digital action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
ptz_action: ptzAction,
|
||||
},
|
||||
);
|
||||
@@ -370,7 +370,7 @@ describe('should handle ptz digital action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
ptz_action: 'right',
|
||||
ptz_phase: 'start',
|
||||
},
|
||||
@@ -442,7 +442,7 @@ describe('should handle ptz digital action', () => {
|
||||
|
||||
const startAction = new PTZDigitalAction(context, {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
ptz_action: 'right',
|
||||
ptz_phase: 'start',
|
||||
});
|
||||
@@ -466,7 +466,7 @@ describe('should handle ptz digital action', () => {
|
||||
|
||||
const stopAction = new PTZDigitalAction(context, {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_digital',
|
||||
advanced_camera_card_action: 'ptz_digital',
|
||||
ptz_phase: 'stop',
|
||||
});
|
||||
await stopAction.execute(api);
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('should handle ptz multi action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: 'left',
|
||||
...(targetID && { target_id: targetID }),
|
||||
},
|
||||
@@ -69,7 +69,7 @@ describe('should handle ptz multi action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: 'right',
|
||||
...(targetID && { target_id: targetID }),
|
||||
},
|
||||
@@ -108,7 +108,7 @@ describe('should handle ptz multi action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: 'right',
|
||||
},
|
||||
);
|
||||
@@ -137,7 +137,7 @@ describe('should handle ptz multi action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: 'right',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
camera: 'camera.office',
|
||||
},
|
||||
@@ -65,7 +65,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
},
|
||||
);
|
||||
@@ -112,7 +112,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
},
|
||||
);
|
||||
@@ -140,7 +140,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
},
|
||||
);
|
||||
@@ -159,7 +159,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
},
|
||||
);
|
||||
@@ -187,7 +187,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -225,7 +225,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -256,7 +256,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'preset',
|
||||
ptz_preset: 'window',
|
||||
},
|
||||
@@ -295,7 +295,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
ptz_phase: 'start',
|
||||
},
|
||||
@@ -343,7 +343,7 @@ describe('should handle ptz action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
},
|
||||
);
|
||||
@@ -388,7 +388,7 @@ describe('should handle ptz action', () => {
|
||||
const context = {};
|
||||
const action = new PTZAction(context, {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
});
|
||||
|
||||
@@ -432,7 +432,7 @@ describe('should handle ptz action', () => {
|
||||
const context = {};
|
||||
const startAction = new PTZAction(context, {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
ptz_phase: 'start',
|
||||
});
|
||||
@@ -455,7 +455,7 @@ describe('should handle ptz action', () => {
|
||||
|
||||
const stopAction = new PTZAction(context, {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
ptz_phase: 'stop',
|
||||
});
|
||||
@@ -486,7 +486,7 @@ describe('should handle ptz action', () => {
|
||||
const context = {};
|
||||
const action = new PTZAction(context, {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz',
|
||||
advanced_camera_card_action: 'ptz',
|
||||
ptz_action: 'left',
|
||||
ptz_phase: 'start',
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ it('should handle screenshot action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'screenshot',
|
||||
advanced_camera_card_action: 'screenshot',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ it('should handle sleep action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'sleep',
|
||||
advanced_camera_card_action: 'sleep',
|
||||
duration: {
|
||||
s: 5,
|
||||
ms: 200,
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('should handle status bar action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'status_bar',
|
||||
advanced_camera_card_action: 'status_bar',
|
||||
status_bar_action: 'reset',
|
||||
},
|
||||
);
|
||||
@@ -22,7 +22,7 @@ describe('should handle status bar action', () => {
|
||||
it('add', async () => {
|
||||
const api = createCardAPI();
|
||||
const item = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item',
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('should handle status bar action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'status_bar',
|
||||
advanced_camera_card_action: 'status_bar',
|
||||
status_bar_action: 'add',
|
||||
items: [item],
|
||||
},
|
||||
@@ -44,7 +44,7 @@ describe('should handle status bar action', () => {
|
||||
it('remove', async () => {
|
||||
const api = createCardAPI();
|
||||
const item = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item',
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('should handle status bar action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'status_bar',
|
||||
advanced_camera_card_action: 'status_bar',
|
||||
status_bar_action: 'remove',
|
||||
items: [item],
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ it('should handle live_substream_off action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_off',
|
||||
advanced_camera_card_action: 'live_substream_off',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ it('should handle live_substream_on action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_on',
|
||||
advanced_camera_card_action: 'live_substream_on',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ it('should handle live_substream_select action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_select',
|
||||
advanced_camera_card_action: 'live_substream_select',
|
||||
camera: 'substream',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { UnmuteAction } from '../../../../src/card-controller/actions/actions/unmute';
|
||||
import { FrigateCardMediaPlayer } from '../../../../src/types';
|
||||
import { AdvancedCameraCardMediaPlayer } from '../../../../src/types';
|
||||
import { createCardAPI, createMediaLoadedInfo } from '../../../test-utils';
|
||||
|
||||
it('should handle unmute action', async () => {
|
||||
const api = createCardAPI();
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
||||
createMediaLoadedInfo({
|
||||
player: player,
|
||||
@@ -16,7 +16,7 @@ it('should handle unmute action', async () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'unmute',
|
||||
advanced_camera_card_action: 'unmute',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('should handle view action', () => {
|
||||
{},
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: viewName,
|
||||
advanced_camera_card_action: viewName,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import { SubstreamSelectAction } from '../../../src/card-controller/actions/acti
|
||||
import { UnmuteAction } from '../../../src/card-controller/actions/actions/unmute';
|
||||
import { ViewAction } from '../../../src/card-controller/actions/actions/view';
|
||||
import { ActionFactory } from '../../../src/card-controller/actions/factory';
|
||||
import { FrigateCardCustomAction } from '../../../src/config/types';
|
||||
import { AdvancedCameraCardCustomAction } from '../../../src/config/types';
|
||||
|
||||
// @vitest-environment jsdom
|
||||
describe('ActionFactory', () => {
|
||||
@@ -39,7 +39,11 @@ describe('ActionFactory', () => {
|
||||
expect(
|
||||
factory.createAction(
|
||||
{},
|
||||
{ action: 'fire-dom-event', frigate_card_action: 'clip', card_id: 'card_id' },
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'clip',
|
||||
card_id: 'card_id',
|
||||
},
|
||||
{
|
||||
cardID: 'different_card_id',
|
||||
},
|
||||
@@ -48,7 +52,7 @@ describe('ActionFactory', () => {
|
||||
});
|
||||
|
||||
describe('generic', () => {
|
||||
it('non frigate card action', () => {
|
||||
it('non advanced camera card action', () => {
|
||||
const factory = new ActionFactory();
|
||||
expect(factory.createAction({}, { action: 'fire-dom-event' })).toBeInstanceOf(
|
||||
GenericAction,
|
||||
@@ -65,81 +69,105 @@ describe('ActionFactory', () => {
|
||||
|
||||
describe('actions', () => {
|
||||
it.each([
|
||||
[{ frigate_card_action: 'camera_select' as const }, CameraSelectAction],
|
||||
[{ frigate_card_action: 'camera_ui' as const }, CameraUIAction],
|
||||
[{ frigate_card_action: 'clip' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'clips' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'default' as const }, DefaultAction],
|
||||
[{ frigate_card_action: 'diagnostics' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'camera_select' as const }, CameraSelectAction],
|
||||
[{ advanced_camera_card_action: 'camera_ui' as const }, CameraUIAction],
|
||||
[{ advanced_camera_card_action: 'clip' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'clips' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'default' as const }, DefaultAction],
|
||||
[{ advanced_camera_card_action: 'diagnostics' as const }, ViewAction],
|
||||
[
|
||||
{
|
||||
frigate_card_action: 'display_mode_select' as const,
|
||||
advanced_camera_card_action: 'display_mode_select' as const,
|
||||
display_mode: 'single' as const,
|
||||
},
|
||||
DisplayModeSelectAction,
|
||||
],
|
||||
[{ frigate_card_action: 'download' as const }, DownloadAction],
|
||||
[{ frigate_card_action: 'expand' as const }, ExpandAction],
|
||||
[{ frigate_card_action: 'fullscreen' as const }, FullscreenAction],
|
||||
[{ frigate_card_action: 'image' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'live_substream_off' as const }, SubstreamOffAction],
|
||||
[{ frigate_card_action: 'live_substream_on' as const }, SubstreamOnAction],
|
||||
[{ advanced_camera_card_action: 'download' as const }, DownloadAction],
|
||||
[{ advanced_camera_card_action: 'expand' as const }, ExpandAction],
|
||||
[{ advanced_camera_card_action: 'fullscreen' as const }, FullscreenAction],
|
||||
[{ advanced_camera_card_action: 'image' as const }, ViewAction],
|
||||
[
|
||||
{ advanced_camera_card_action: 'live_substream_off' as const },
|
||||
SubstreamOffAction,
|
||||
],
|
||||
[{ advanced_camera_card_action: 'live_substream_on' as const }, SubstreamOnAction],
|
||||
[
|
||||
{
|
||||
frigate_card_action: 'live_substream_select' as const,
|
||||
advanced_camera_card_action: 'live_substream_select' as const,
|
||||
camera: 'camera.office',
|
||||
},
|
||||
SubstreamSelectAction,
|
||||
],
|
||||
[{ frigate_card_action: 'live' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'live' as const }, ViewAction],
|
||||
[
|
||||
{ frigate_card_action: 'log' as const, message: 'Hello, world!' as const },
|
||||
{
|
||||
advanced_camera_card_action: 'log' as const,
|
||||
message: 'Hello, world!' as const,
|
||||
},
|
||||
LogAction,
|
||||
],
|
||||
[
|
||||
{
|
||||
frigate_card_action: 'media_player' as const,
|
||||
advanced_camera_card_action: 'media_player' as const,
|
||||
media_player: 'media_player.foo' as const,
|
||||
media_player_action: 'play' as const,
|
||||
},
|
||||
MediaPlayerAction,
|
||||
],
|
||||
[{ frigate_card_action: 'menu_toggle' as const }, MenuToggleAction],
|
||||
[{ frigate_card_action: 'microphone_connect' as const }, MicrophoneConnectAction],
|
||||
[{ advanced_camera_card_action: 'menu_toggle' as const }, MenuToggleAction],
|
||||
[
|
||||
{ frigate_card_action: 'microphone_disconnect' as const },
|
||||
{ advanced_camera_card_action: 'microphone_connect' as const },
|
||||
MicrophoneConnectAction,
|
||||
],
|
||||
[
|
||||
{ advanced_camera_card_action: 'microphone_disconnect' as const },
|
||||
MicrophoneDisconnectAction,
|
||||
],
|
||||
[{ frigate_card_action: 'microphone_mute' as const }, MicrophoneMuteAction],
|
||||
[{ frigate_card_action: 'microphone_unmute' as const }, MicrophoneUnmuteAction],
|
||||
[{ frigate_card_action: 'mute' as const }, MuteAction],
|
||||
[{ frigate_card_action: 'pause' as const }, PauseAction],
|
||||
[{ frigate_card_action: 'play' as const }, PlayAction],
|
||||
[{ frigate_card_action: 'ptz_digital' as const }, PTZDigitalAction],
|
||||
[
|
||||
{ frigate_card_action: 'ptz_multi' as const, ptz_action: 'right' as const },
|
||||
{ advanced_camera_card_action: 'microphone_mute' as const },
|
||||
MicrophoneMuteAction,
|
||||
],
|
||||
[
|
||||
{ advanced_camera_card_action: 'microphone_unmute' as const },
|
||||
MicrophoneUnmuteAction,
|
||||
],
|
||||
[{ advanced_camera_card_action: 'mute' as const }, MuteAction],
|
||||
[{ advanced_camera_card_action: 'pause' as const }, PauseAction],
|
||||
[{ advanced_camera_card_action: 'play' as const }, PlayAction],
|
||||
[{ advanced_camera_card_action: 'ptz_digital' as const }, PTZDigitalAction],
|
||||
[
|
||||
{
|
||||
advanced_camera_card_action: 'ptz_multi' as const,
|
||||
ptz_action: 'right' as const,
|
||||
},
|
||||
PTZMultiAction,
|
||||
],
|
||||
[{ frigate_card_action: 'ptz' as const, ptz_action: 'right' as const }, PTZAction],
|
||||
[{ frigate_card_action: 'recording' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'recordings' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'screenshot' as const }, ScreenshotAction],
|
||||
[
|
||||
{ frigate_card_action: 'ptz_controls' as const, enabled: true },
|
||||
{ advanced_camera_card_action: 'ptz' as const, ptz_action: 'right' as const },
|
||||
PTZAction,
|
||||
],
|
||||
[{ advanced_camera_card_action: 'recording' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'recordings' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'screenshot' as const }, ScreenshotAction],
|
||||
[
|
||||
{ advanced_camera_card_action: 'ptz_controls' as const, enabled: true },
|
||||
PTZControlsAction,
|
||||
],
|
||||
[{ frigate_card_action: 'sleep' as const }, SleepAction],
|
||||
[{ frigate_card_action: 'snapshot' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'snapshots' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'timeline' as const }, ViewAction],
|
||||
[{ frigate_card_action: 'unmute' as const }, UnmuteAction],
|
||||
[{ advanced_camera_card_action: 'sleep' as const }, SleepAction],
|
||||
[{ advanced_camera_card_action: 'snapshot' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'snapshots' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'timeline' as const }, ViewAction],
|
||||
[{ advanced_camera_card_action: 'unmute' as const }, UnmuteAction],
|
||||
[
|
||||
{ frigate_card_action: 'status_bar' as const, status_bar_action: 'reset' },
|
||||
{
|
||||
advanced_camera_card_action: 'status_bar' as const,
|
||||
status_bar_action: 'reset',
|
||||
},
|
||||
StatusBarAction,
|
||||
],
|
||||
])(
|
||||
'frigate_card_action: $frigate_card_action',
|
||||
(action: Partial<FrigateCardCustomAction>, classObject: object) => {
|
||||
'advanced_camera_card_action: $advanced_camera_card_action',
|
||||
(action: Partial<AdvancedCameraCardCustomAction>, classObject: object) => {
|
||||
const factory = new ActionFactory();
|
||||
expect(
|
||||
factory.createAction({}, { action: 'fire-dom-event', ...action }),
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('AutomationsManager', () => {
|
||||
const actions = [
|
||||
{
|
||||
action: 'fire-dom-event' as const,
|
||||
frigate_card_action: 'clips',
|
||||
advanced_camera_card_action: 'clips',
|
||||
},
|
||||
];
|
||||
const conditions = [{ condition: 'fullscreen' as const, fullscreen: true }];
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
getOverriddenConfig,
|
||||
} from '../../src/card-controller/conditions-manager';
|
||||
import { MicrophoneState } from '../../src/card-controller/types';
|
||||
import { FrigateCardCondition } from '../../src/config/types';
|
||||
import { AdvancedCameraCardCondition } from '../../src/config/types';
|
||||
import {
|
||||
createCardAPI,
|
||||
createCondition,
|
||||
@@ -26,7 +26,7 @@ describe('ConditionEvaluateRequestEvent', () => {
|
||||
composed: true,
|
||||
});
|
||||
|
||||
expect(event.type).toBe('frigate-card:conditions:evaluate');
|
||||
expect(event.type).toBe('advanced-camera-card:conditions:evaluate');
|
||||
expect(event.conditions).toBe(conditions);
|
||||
expect(event.bubbles).toBeTruthy();
|
||||
expect(event.composed).toBeTruthy();
|
||||
@@ -45,7 +45,7 @@ describe('evaluateConditionViaEvent', () => {
|
||||
expect(ev.conditions).toBe(conditions);
|
||||
ev.evaluation = true;
|
||||
});
|
||||
element.addEventListener('frigate-card:conditions:evaluate', handler);
|
||||
element.addEventListener('advanced-camera-card:conditions:evaluate', handler);
|
||||
|
||||
expect(evaluateConditionViaEvent(element, conditions)).toBeTruthy();
|
||||
expect(handler).toBeCalled();
|
||||
@@ -57,7 +57,7 @@ describe('evaluateConditionViaEvent', () => {
|
||||
expect(ev.conditions).toBe(conditions);
|
||||
ev.evaluation = false;
|
||||
});
|
||||
element.addEventListener('frigate-card:conditions:evaluate', handler);
|
||||
element.addEventListener('advanced-camera-card:conditions:evaluate', handler);
|
||||
|
||||
expect(evaluateConditionViaEvent(element, conditions)).toBeFalsy();
|
||||
expect(handler).toBeCalled();
|
||||
@@ -66,7 +66,7 @@ describe('evaluateConditionViaEvent', () => {
|
||||
const element = document.createElement('div');
|
||||
const conditions = [createCondition({ condition: 'fullscreen', fullscreen: true })];
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:conditions:evaluate', handler);
|
||||
element.addEventListener('advanced-camera-card:conditions:evaluate', handler);
|
||||
|
||||
expect(evaluateConditionViaEvent(element, conditions)).toBeFalsy();
|
||||
expect(handler).toBeCalled();
|
||||
@@ -464,7 +464,7 @@ describe('ConditionsManager', () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
const createSuitableConfig = (conditions: FrigateCardCondition[]) => {
|
||||
const createSuitableConfig = (conditions: AdvancedCameraCardCondition[]) => {
|
||||
return createConfig({
|
||||
overrides: [
|
||||
{
|
||||
@@ -790,11 +790,11 @@ describe('ConditionsManager', () => {
|
||||
|
||||
describe('with screen condition', () => {
|
||||
const mediaQueryConfig = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{}],
|
||||
elements: [
|
||||
{
|
||||
type: 'custom:frigate-card-conditional',
|
||||
type: 'custom:advanced-camera-card-conditional',
|
||||
conditions: [
|
||||
{
|
||||
condition: 'fullscreen' as const,
|
||||
@@ -805,7 +805,7 @@ describe('ConditionsManager', () => {
|
||||
{
|
||||
type: 'custom:nested-unknown-object',
|
||||
unknown_key: {
|
||||
type: 'custom:frigate-card-conditional',
|
||||
type: 'custom:advanced-camera-card-conditional',
|
||||
conditions: [
|
||||
{
|
||||
condition: 'screen' as const,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ZodError } from 'zod';
|
||||
import { getOverriddenConfig } from '../../../src/card-controller/conditions-manager';
|
||||
import { ConfigManager } from '../../../src/card-controller/config/config-manager';
|
||||
import { InitializationAspect } from '../../../src/card-controller/initialization-manager';
|
||||
import { frigateCardConfigSchema } from '../../../src/config/types';
|
||||
import { advancedCameraCardConfigSchema } from '../../../src/config/types';
|
||||
import { createCardAPI, createConfig, flushPromises } from '../../test-utils';
|
||||
|
||||
vi.mock('../../../src/card-controller/conditions-manager.js');
|
||||
@@ -20,7 +20,7 @@ describe('ConfigManager', () => {
|
||||
});
|
||||
|
||||
it('invalid configuration', () => {
|
||||
const spy = vi.spyOn(frigateCardConfigSchema, 'safeParse').mockReturnValue({
|
||||
const spy = vi.spyOn(advancedCameraCardConfigSchema, 'safeParse').mockReturnValue({
|
||||
success: false,
|
||||
error: new ZodError([]),
|
||||
});
|
||||
@@ -44,18 +44,14 @@ describe('ConfigManager', () => {
|
||||
const manager = new ConfigManager(createCardAPI());
|
||||
expect(() =>
|
||||
manager.setConfig({
|
||||
cameras: [
|
||||
{
|
||||
frigate: {
|
||||
label: 'foo',
|
||||
},
|
||||
},
|
||||
],
|
||||
// This key needs to be upgradeable in `management.ts` .
|
||||
type: 'custom:frigate-card',
|
||||
cameras: 'WILL_NOT_PARSE',
|
||||
}),
|
||||
).toThrowError(
|
||||
'An automated card configuration upgrade is ' +
|
||||
'available, please visit the visual card editor. ' +
|
||||
'Invalid configuration: [\n "type"\n]',
|
||||
'Invalid configuration: [\n "cameras"\n]',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -72,7 +68,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
};
|
||||
|
||||
@@ -105,7 +101,7 @@ describe('ConfigManager', () => {
|
||||
it('should apply profiles', () => {
|
||||
const manager = new ConfigManager(createCardAPI());
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
profiles: ['low-performance'],
|
||||
};
|
||||
@@ -120,7 +116,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
};
|
||||
|
||||
@@ -137,7 +133,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
debug: {
|
||||
logging: true,
|
||||
@@ -183,7 +179,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
};
|
||||
vi.mocked(getOverriddenConfig).mockReturnValue(config);
|
||||
@@ -201,14 +197,14 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config_1 = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
};
|
||||
manager.setConfig(config_1);
|
||||
vi.mocked(api.getStyleManager().updateFromConfig).mockClear();
|
||||
|
||||
const config_2 = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.kitchen' }],
|
||||
};
|
||||
vi.mocked(getOverriddenConfig).mockReturnValue(config_2);
|
||||
@@ -223,7 +219,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
manager.setConfig({
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
});
|
||||
|
||||
@@ -242,7 +238,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config_1 = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
};
|
||||
vi.mocked(getOverriddenConfig).mockReturnValue(createConfig(config_1));
|
||||
@@ -253,7 +249,7 @@ describe('ConfigManager', () => {
|
||||
);
|
||||
|
||||
const config_2 = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.kitchen' }],
|
||||
};
|
||||
vi.mocked(getOverriddenConfig).mockReturnValue(createConfig(config_2));
|
||||
@@ -268,7 +264,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config_1 = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
};
|
||||
vi.mocked(getOverriddenConfig).mockReturnValue(createConfig(config_1));
|
||||
@@ -296,7 +292,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config_1 = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
live: {
|
||||
microphone: {
|
||||
@@ -332,7 +328,7 @@ describe('ConfigManager', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
const config = {
|
||||
type: 'custom:frigate-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
};
|
||||
vi.mocked(getOverriddenConfig).mockReturnValue(createConfig(config));
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('setAutomationsFromConfig', () => {
|
||||
actions: [
|
||||
{
|
||||
action: 'fire-dom-event' as const,
|
||||
frigate_card_action: 'clips',
|
||||
advanced_camera_card_action: 'clips',
|
||||
},
|
||||
],
|
||||
conditions: [{ condition: 'fullscreen' as const, fullscreen: true }],
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('setKeyboardShortcutsFromConfig', () => {
|
||||
actions: [
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: ptzAction,
|
||||
ptz_phase: 'start',
|
||||
},
|
||||
@@ -89,7 +89,7 @@ describe('setKeyboardShortcutsFromConfig', () => {
|
||||
actions: [
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: ptzAction,
|
||||
ptz_phase: 'stop',
|
||||
},
|
||||
@@ -119,7 +119,7 @@ describe('setKeyboardShortcutsFromConfig', () => {
|
||||
actions: [
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
},
|
||||
],
|
||||
conditions: [
|
||||
|
||||
@@ -27,7 +27,7 @@ import { StatusBarItemManager } from '../../src/card-controller/status-bar-item-
|
||||
import { StyleManager } from '../../src/card-controller/style-manager';
|
||||
import { TriggersManager } from '../../src/card-controller/triggers-manager';
|
||||
import { ViewManager } from '../../src/card-controller/view/view-manager';
|
||||
import { FrigateCardEditor } from '../../src/editor';
|
||||
import { AdvancedCameraCardEditor } from '../../src/editor';
|
||||
import { DeviceRegistryManager } from '../../src/utils/ha/registry/device';
|
||||
import { EntityRegistryManager } from '../../src/utils/ha/registry/entity';
|
||||
import { ResolvedMediaCache } from '../../src/utils/ha/resolved-media';
|
||||
@@ -142,7 +142,9 @@ describe('CardController', () => {
|
||||
});
|
||||
|
||||
it('getConfigElement', async () => {
|
||||
expect((await CardController.getConfigElement()) instanceof FrigateCardEditor);
|
||||
expect(
|
||||
(await CardController.getConfigElement()) instanceof AdvancedCameraCardEditor,
|
||||
);
|
||||
});
|
||||
|
||||
it('getConfigManager', () => {
|
||||
|
||||
@@ -189,7 +189,7 @@ describe('DefaultManager', () => {
|
||||
actions: [
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'default',
|
||||
advanced_camera_card_action: 'default',
|
||||
},
|
||||
],
|
||||
conditions: [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { FrigateCardMediaPlayer } from '../../src/types';
|
||||
import { DownloadManager } from '../../src/card-controller/download-manager';
|
||||
import { AdvancedCameraCardMediaPlayer } from '../../src/types';
|
||||
import { downloadMedia, downloadURL } from '../../src/utils/download.js';
|
||||
import {
|
||||
createCardAPI,
|
||||
@@ -62,7 +62,7 @@ describe('DownloadManager.downloadScreenshot', () => {
|
||||
|
||||
it('with url', async () => {
|
||||
const api = createCardAPI();
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player.getScreenshotURL.mockResolvedValue('http://screenshot');
|
||||
|
||||
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
||||
@@ -78,7 +78,7 @@ describe('DownloadManager.downloadScreenshot', () => {
|
||||
|
||||
it('without url', async () => {
|
||||
const api = createCardAPI();
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player.getScreenshotURL.mockResolvedValue(null);
|
||||
|
||||
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
||||
|
||||
@@ -2,7 +2,10 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { CardController } from '../../../../src/card-controller/controller';
|
||||
import { WebkitFullScreenProvider } from '../../../../src/card-controller/fullscreen/webkit';
|
||||
import { FrigateCardMediaPlayer, WebkitHTMLVideoElement } from '../../../../src/types';
|
||||
import {
|
||||
AdvancedCameraCardMediaPlayer,
|
||||
WebkitHTMLVideoElement,
|
||||
} from '../../../../src/types';
|
||||
import { createCardAPI, createMediaLoadedInfo } from '../../../test-utils';
|
||||
|
||||
const createWebkitVideoElement = (): HTMLVideoElement &
|
||||
@@ -11,7 +14,7 @@ const createWebkitVideoElement = (): HTMLVideoElement &
|
||||
};
|
||||
|
||||
const setElement = (api: CardController, element: HTMLElement): void => {
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player.getFullscreenElement.mockReturnValue(element);
|
||||
|
||||
vi.mocked(api.getMediaLoadedInfoManager().get).mockReturnValue(
|
||||
@@ -158,7 +161,7 @@ describe('WebkitFullScreenProvider', () => {
|
||||
).mock.calls[0][0];
|
||||
|
||||
const element_1 = createWebkitVideoElement();
|
||||
const player_1 = mock<FrigateCardMediaPlayer>();
|
||||
const player_1 = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player_1.getFullscreenElement.mockReturnValue(element_1);
|
||||
const mediaLoadedInfo_1 = createMediaLoadedInfo({ player: player_1 });
|
||||
|
||||
@@ -169,7 +172,7 @@ describe('WebkitFullScreenProvider', () => {
|
||||
expect(handler).toBeCalledTimes(1);
|
||||
|
||||
const element_2 = createWebkitVideoElement();
|
||||
const player_2 = mock<FrigateCardMediaPlayer>();
|
||||
const player_2 = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player_2.getFullscreenElement.mockReturnValue(element_2);
|
||||
const mediaLoadedInfo_2 = createMediaLoadedInfo({ player: player_2 });
|
||||
|
||||
@@ -219,7 +222,7 @@ describe('WebkitFullScreenProvider', () => {
|
||||
|
||||
setElement(api, element);
|
||||
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player.getFullscreenElement.mockReturnValue(element);
|
||||
const mediaLoadedInfo = createMediaLoadedInfo({ player });
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterAll, describe, expect, it, vi } from 'vitest';
|
||||
import { FrigateCardError, Message } from '../../src/types';
|
||||
import { MessageManager } from '../../src/card-controller/message-manager';
|
||||
import { AdvancedCameraCardError, Message } from '../../src/types';
|
||||
import { createCardAPI } from '../test-utils';
|
||||
|
||||
const createMessage = (options?: Partial<Message>): Message => {
|
||||
@@ -111,7 +111,7 @@ describe('MessageManager', () => {
|
||||
expect(manager.getMessage()).toBe(connectionMessage);
|
||||
});
|
||||
|
||||
it('should set FrigateCardError object', () => {
|
||||
it('should set AdvancedCameraCardError object', () => {
|
||||
const consoleSpy = vi.spyOn(global.console, 'warn').mockReturnValue(undefined);
|
||||
|
||||
const api = createCardAPI();
|
||||
@@ -119,11 +119,11 @@ describe('MessageManager', () => {
|
||||
const context = { foo: 'bar' };
|
||||
|
||||
manager.setErrorIfHigherPriority(
|
||||
new FrigateCardError('frigate card message', context),
|
||||
new AdvancedCameraCardError('advanced camera card message', context),
|
||||
);
|
||||
expect(manager.hasMessage()).toBeTruthy();
|
||||
expect(manager.getMessage()).toEqual({
|
||||
message: 'frigate card message',
|
||||
message: 'advanced camera card message',
|
||||
type: 'error',
|
||||
context: context,
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('QueryStringManager', () => {
|
||||
['snapshots' as const],
|
||||
['timeline' as const],
|
||||
])('%s', async (viewName: string) => {
|
||||
setQueryString(`?frigate-card-action.id.${viewName}=`);
|
||||
setQueryString(`?advanced-camera-card-action.id.${viewName}=`);
|
||||
const api = createCardAPI();
|
||||
|
||||
// View actions do not need the card to have been updated.
|
||||
@@ -68,7 +68,7 @@ describe('QueryStringManager', () => {
|
||||
['expand' as const],
|
||||
['menu_toggle' as const],
|
||||
])('%s', async (action: string) => {
|
||||
setQueryString(`?frigate-card-action.id.${action}=`);
|
||||
setQueryString(`?advanced-camera-card-action.id.${action}=`);
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
const manager = new QueryStringManager(api);
|
||||
@@ -80,14 +80,14 @@ describe('QueryStringManager', () => {
|
||||
{
|
||||
action: 'fire-dom-event',
|
||||
card_id: 'id',
|
||||
frigate_card_action: action,
|
||||
advanced_camera_card_action: action,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should execute view default action', async () => {
|
||||
setQueryString('?frigate-card-action.id.default=');
|
||||
setQueryString('?advanced-camera-card-action.id.default=');
|
||||
const api = createCardAPI();
|
||||
// View actions do not need the card to have been updated.
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(false);
|
||||
@@ -104,7 +104,7 @@ describe('QueryStringManager', () => {
|
||||
});
|
||||
|
||||
it('should execute camera_select action', async () => {
|
||||
setQueryString('?frigate-card-action.id.camera_select=camera.office');
|
||||
setQueryString('?advanced-camera-card-action.id.camera_select=camera.office');
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
const manager = new QueryStringManager(api);
|
||||
@@ -123,7 +123,9 @@ describe('QueryStringManager', () => {
|
||||
});
|
||||
|
||||
it('should execute live_substream_select action', async () => {
|
||||
setQueryString('?frigate-card-action.id.live_substream_select=camera.office_hd');
|
||||
setQueryString(
|
||||
'?advanced-camera-card-action.id.live_substream_select=camera.office_hd',
|
||||
);
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
const manager = new QueryStringManager(api);
|
||||
@@ -145,7 +147,7 @@ describe('QueryStringManager', () => {
|
||||
it.each([['camera_select' as const], ['live_substream_select' as const]])(
|
||||
'%s',
|
||||
async (action: string) => {
|
||||
setQueryString(`?frigate-card-action.id.${action}=`);
|
||||
setQueryString(`?advanced-camera-card-action.id.${action}=`);
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
const manager = new QueryStringManager(api);
|
||||
@@ -163,7 +165,7 @@ describe('QueryStringManager', () => {
|
||||
it('should handle unknown action', async () => {
|
||||
const consoleSpy = vi.spyOn(global.console, 'warn').mockReturnValue(undefined);
|
||||
|
||||
setQueryString('?frigate-card-action.id.not_an_action=value');
|
||||
setQueryString('?advanced-camera-card-action.id.not_an_action=value');
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
const manager = new QueryStringManager(api);
|
||||
@@ -190,7 +192,7 @@ describe('QueryStringManager', () => {
|
||||
['snapshots' as const],
|
||||
['timeline' as const],
|
||||
])('%s', async (viewName: string) => {
|
||||
setQueryString(`?frigate-card-action.id.${viewName}=`);
|
||||
setQueryString(`?advanced-camera-card-action.id.${viewName}=`);
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
const manager = new QueryStringManager(api);
|
||||
@@ -210,10 +212,10 @@ describe('QueryStringManager', () => {
|
||||
describe('should handle conflicting but valid actions', () => {
|
||||
it('view and default with camera and substream specified', async () => {
|
||||
setQueryString(
|
||||
'?frigate-card-action.id.clips=' +
|
||||
'&frigate-card-action.id.live_substream_select=camera.kitchen_hd' +
|
||||
'&frigate-card-action.id.default=' +
|
||||
'&frigate-card-action.id.camera_select=camera.kitchen',
|
||||
'?advanced-camera-card-action.id.clips=' +
|
||||
'&advanced-camera-card-action.id.live_substream_select=camera.kitchen_hd' +
|
||||
'&advanced-camera-card-action.id.default=' +
|
||||
'&advanced-camera-card-action.id.camera_select=camera.kitchen',
|
||||
);
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
@@ -232,8 +234,8 @@ describe('QueryStringManager', () => {
|
||||
|
||||
it('multiple cameras specified', async () => {
|
||||
setQueryString(
|
||||
'?frigate-card-action.id.camera_select=camera.kitchen' +
|
||||
'&frigate-card-action.id.camera_select=camera.office',
|
||||
'?advanced-camera-card-action.id.camera_select=camera.kitchen' +
|
||||
'&advanced-camera-card-action.id.camera_select=camera.office',
|
||||
);
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
@@ -250,7 +252,9 @@ describe('QueryStringManager', () => {
|
||||
});
|
||||
|
||||
it('should only execute when needed', async () => {
|
||||
setQueryString('?frigate-card-action.id.live_substream_select=camera.office_hd');
|
||||
setQueryString(
|
||||
'?advanced-camera-card-action.id.live_substream_select=camera.office_hd',
|
||||
);
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(true);
|
||||
const manager = new QueryStringManager(api);
|
||||
@@ -271,4 +275,23 @@ describe('QueryStringManager', () => {
|
||||
expect(manager.hasViewRelatedActionsToRun()).toBeFalsy();
|
||||
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should execute actions with old frigate-card-action key', async () => {
|
||||
setQueryString(`?frigate-card-action.id.clips=`);
|
||||
const api = createCardAPI();
|
||||
|
||||
// View actions do not need the card to have been updated.
|
||||
vi.mocked(api.getCardElementManager().hasUpdated).mockReturnValue(false);
|
||||
const manager = new QueryStringManager(api);
|
||||
|
||||
expect(manager.hasViewRelatedActionsToRun()).toBeTruthy();
|
||||
await manager.executeIfNecessary();
|
||||
expect(manager.hasViewRelatedActionsToRun()).toBeFalsy();
|
||||
|
||||
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledWith({
|
||||
params: {
|
||||
view: 'clips',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
|
||||
describe('StatusBarItemManager', () => {
|
||||
const testItem: StatusBarString = {
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: 'test',
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ describe('StatusBarItemManager', () => {
|
||||
view: createView({ view: 'live', camera: 'camera-1' }),
|
||||
}),
|
||||
).toContainEqual({
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: 'Camera Title',
|
||||
expand: true,
|
||||
sufficient: true,
|
||||
@@ -108,7 +108,7 @@ describe('StatusBarItemManager', () => {
|
||||
view: view,
|
||||
}),
|
||||
).toContainEqual({
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: 'Media Title',
|
||||
expand: true,
|
||||
sufficient: true,
|
||||
@@ -180,7 +180,7 @@ describe('StatusBarItemManager', () => {
|
||||
mediaLoadedInfo: { width, height },
|
||||
}),
|
||||
).toContainEqual({
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: expectedName,
|
||||
});
|
||||
},
|
||||
@@ -196,7 +196,7 @@ describe('StatusBarItemManager', () => {
|
||||
mediaLoadedInfo: { width: 640, height: 480, technology: ['webrtc'] },
|
||||
}),
|
||||
).toContainEqual({
|
||||
type: 'custom:frigate-card-status-bar-icon' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-icon' as const,
|
||||
icon: 'mdi:webrtc',
|
||||
});
|
||||
});
|
||||
@@ -209,7 +209,7 @@ describe('StatusBarItemManager', () => {
|
||||
mediaLoadedInfo: { width: 640, height: 480, technology: ['hls'] },
|
||||
}),
|
||||
).toContainEqual({
|
||||
type: 'custom:frigate-card-status-bar-string' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-string' as const,
|
||||
string: 'HLS',
|
||||
});
|
||||
});
|
||||
@@ -237,7 +237,7 @@ describe('StatusBarItemManager', () => {
|
||||
view: createView({ view: 'live', camera: 'camera-1' }),
|
||||
}),
|
||||
).toContainEqual({
|
||||
type: 'custom:frigate-card-status-bar-icon' as const,
|
||||
type: 'custom:advanced-camera-card-status-bar-icon' as const,
|
||||
icon: 'ENGINE_ICON',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { StyleManager } from '../../src/card-controller/style-manager';
|
||||
import { FrigateCardView, ThemeName } from '../../src/config/types';
|
||||
import { AdvancedCameraCardView, ThemeName } from '../../src/config/types';
|
||||
import { createCardAPI, createConfig, createView } from '../test-utils';
|
||||
|
||||
// @vitest-environment jsdom
|
||||
@@ -57,15 +57,15 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.setExpandedMode();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-aspect-ratio')).toBe(
|
||||
'unset',
|
||||
);
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-width')).toBe(
|
||||
'var(--frigate-card-expand-max-width)',
|
||||
);
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-height')).toBe(
|
||||
'var(--frigate-card-expand-max-height)',
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-aspect-ratio'),
|
||||
).toBe('unset');
|
||||
expect(element.style.getPropertyValue('--advanced-camera-card-expand-width')).toBe(
|
||||
'var(--advanced-camera-card-expand-max-width)',
|
||||
);
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-height'),
|
||||
).toBe('var(--advanced-camera-card-expand-max-height)');
|
||||
});
|
||||
|
||||
it('with view but without media', () => {
|
||||
@@ -79,13 +79,15 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.setExpandedMode();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-aspect-ratio')).toBe(
|
||||
'unset',
|
||||
);
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-width')).toBe('none');
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-height')).toBe(
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-aspect-ratio'),
|
||||
).toBe('unset');
|
||||
expect(element.style.getPropertyValue('--advanced-camera-card-expand-width')).toBe(
|
||||
'none',
|
||||
);
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-height'),
|
||||
).toBe('none');
|
||||
});
|
||||
|
||||
it('with view and media', () => {
|
||||
@@ -102,13 +104,15 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.setExpandedMode();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-aspect-ratio')).toBe(
|
||||
'800 / 600',
|
||||
);
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-width')).toBe('none');
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-height')).toBe(
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-aspect-ratio'),
|
||||
).toBe('800 / 600');
|
||||
expect(element.style.getPropertyValue('--advanced-camera-card-expand-width')).toBe(
|
||||
'none',
|
||||
);
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-height'),
|
||||
).toBe('none');
|
||||
});
|
||||
|
||||
it('with view and grid display mode', () => {
|
||||
@@ -125,15 +129,15 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.setExpandedMode();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-aspect-ratio')).toBe(
|
||||
'800 / 600',
|
||||
);
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-width')).toBe(
|
||||
'var(--frigate-card-expand-max-width)',
|
||||
);
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-height')).toBe(
|
||||
'var(--frigate-card-expand-max-height)',
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-aspect-ratio'),
|
||||
).toBe('800 / 600');
|
||||
expect(element.style.getPropertyValue('--advanced-camera-card-expand-width')).toBe(
|
||||
'var(--advanced-camera-card-expand-max-width)',
|
||||
);
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-height'),
|
||||
).toBe('var(--advanced-camera-card-expand-max-height)');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -146,8 +150,12 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.updateFromConfig();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-max-height')).toBeFalsy();
|
||||
expect(element.style.getPropertyValue('--frigate-card-expand-height')).toBeFalsy();
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-max-height'),
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-expand-height'),
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
it('with a config', () => {
|
||||
@@ -165,7 +173,9 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.updateFromConfig();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-height')).toBe('800px');
|
||||
expect(element.style.getPropertyValue('--advanced-camera-card-height')).toBe(
|
||||
'800px',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -180,10 +190,10 @@ describe('StyleManager', () => {
|
||||
manager.updateFromConfig();
|
||||
|
||||
expect(
|
||||
element.style.getPropertyValue('--frigate-card-css-box-shadow'),
|
||||
element.style.getPropertyValue('--advanced-camera-card-css-box-shadow'),
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
element.style.getPropertyValue('--frigate-card-css-border-radius'),
|
||||
element.style.getPropertyValue('--advanced-camera-card-css-border-radius'),
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -205,11 +215,11 @@ describe('StyleManager', () => {
|
||||
|
||||
manager.updateFromConfig();
|
||||
|
||||
expect(element.style.getPropertyValue('--frigate-card-css-box-shadow')).toEqual(
|
||||
'none',
|
||||
);
|
||||
expect(
|
||||
element.style.getPropertyValue('--frigate-card-css-border-radius'),
|
||||
element.style.getPropertyValue('--advanced-camera-card-css-box-shadow'),
|
||||
).toEqual('none');
|
||||
expect(
|
||||
element.style.getPropertyValue('--advanced-camera-card-css-border-radius'),
|
||||
).toBeFalsy();
|
||||
});
|
||||
});
|
||||
@@ -277,7 +287,7 @@ describe('StyleManager', () => {
|
||||
['recording' as const],
|
||||
['snapshot' as const],
|
||||
['timeline' as const],
|
||||
])('%s', (viewName: FrigateCardView) => {
|
||||
])('%s', (viewName: AdvancedCameraCardView) => {
|
||||
const api = createCardAPI();
|
||||
const view = createView({ view: viewName });
|
||||
vi.mocked(api.getViewManager().getView).mockReturnValue(view);
|
||||
@@ -297,7 +307,7 @@ describe('StyleManager', () => {
|
||||
describe('should be enforced when dynamic in certain views', () => {
|
||||
it.each([['clips' as const], ['recordings' as const], ['snapshots' as const]])(
|
||||
'%s',
|
||||
(viewName: FrigateCardView) => {
|
||||
(viewName: AdvancedCameraCardView) => {
|
||||
const api = createCardAPI();
|
||||
const view = createView({ view: viewName });
|
||||
vi.mocked(api.getViewManager().getView).mockReturnValue(view);
|
||||
@@ -318,7 +328,7 @@ describe('StyleManager', () => {
|
||||
describe('should use media dimensions in dynamic', () => {
|
||||
it.each([['clips' as const], ['recordings' as const], ['snapshots' as const]])(
|
||||
'%s',
|
||||
(viewName: FrigateCardView) => {
|
||||
(viewName: AdvancedCameraCardView) => {
|
||||
const api = createCardAPI();
|
||||
const view = createView({ view: viewName });
|
||||
vi.mocked(api.getViewManager().getView).mockReturnValue(view);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { CardController } from '../../src/card-controller/controller';
|
||||
import { TriggersManager } from '../../src/card-controller/triggers-manager';
|
||||
import {
|
||||
FrigateCardView,
|
||||
AdvancedCameraCardView,
|
||||
TriggersOptions,
|
||||
triggersSchema,
|
||||
} from '../../src/config/types';
|
||||
@@ -36,7 +36,7 @@ const baseTriggersConfig: TriggersOptions = {
|
||||
// function reduces it.
|
||||
const createTriggerAPI = (options?: {
|
||||
config?: Partial<TriggersOptions>;
|
||||
default?: FrigateCardView;
|
||||
default?: AdvancedCameraCardView;
|
||||
interaction?: boolean;
|
||||
}): CardController => {
|
||||
const api = createCardAPI();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { ViewFactory } from '../../../src/card-controller/view/factory';
|
||||
import { ViewModifier } from '../../../src/card-controller/view/types';
|
||||
import { FrigateCardView, ViewDisplayMode } from '../../../src/config/types';
|
||||
import { AdvancedCameraCardView, ViewDisplayMode } from '../../../src/config/types';
|
||||
import { View } from '../../../src/view/view';
|
||||
import {
|
||||
createCameraManager,
|
||||
@@ -374,7 +374,7 @@ describe('getViewByParameters', () => {
|
||||
['recording' as const],
|
||||
['snapshot' as const],
|
||||
['live' as const],
|
||||
])('%s', (viewName: FrigateCardView) => {
|
||||
])('%s', (viewName: AdvancedCameraCardView) => {
|
||||
const api = createPopulatedAPI({
|
||||
media_viewer: {
|
||||
display: displayConfig,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { CardController } from '../../../../src/card-controller/controller';
|
||||
import { SubstreamOnViewModifier } from '../../../../src/card-controller/view/modifiers/substream-on';
|
||||
import { RawFrigateCardConfig } from '../../../../src/config/types';
|
||||
import { RawAdvancedCameraCardConfig } from '../../../../src/config/types';
|
||||
import {
|
||||
getStreamCameraID,
|
||||
hasSubstream,
|
||||
@@ -17,7 +17,9 @@ import {
|
||||
createView,
|
||||
} from '../../../test-utils';
|
||||
|
||||
const createAPIWithSubstreams = (config?: RawFrigateCardConfig): CardController => {
|
||||
const createAPIWithSubstreams = (
|
||||
config?: RawAdvancedCameraCardConfig,
|
||||
): CardController => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager());
|
||||
vi.mocked(api.getCameraManager().getStore).mockReturnValue(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { vi } from 'vitest';
|
||||
import { CardController } from '../../../src/card-controller/controller';
|
||||
import { RawFrigateCardConfig } from '../../../src/config/types';
|
||||
import { RawAdvancedCameraCardConfig } from '../../../src/config/types';
|
||||
import {
|
||||
createCameraManager,
|
||||
createCapabilities,
|
||||
@@ -9,7 +9,9 @@ import {
|
||||
createStore,
|
||||
} from '../../test-utils';
|
||||
|
||||
export const createPopulatedAPI = (config?: RawFrigateCardConfig): CardController => {
|
||||
export const createPopulatedAPI = (
|
||||
config?: RawAdvancedCameraCardConfig,
|
||||
): CardController => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager());
|
||||
vi.mocked(api.getCameraManager().getStore).mockReturnValue(
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import { ViewContext } from 'view';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { QueryType } from '../../../src/camera-manager/types';
|
||||
import { ViewFactory } from '../../../src/card-controller/view/factory';
|
||||
import { SetQueryViewModifier } from '../../../src/card-controller/view/modifiers/set-query';
|
||||
import {
|
||||
QueryExecutorOptions,
|
||||
ViewModifier,
|
||||
} from '../../../src/card-controller/view/types';
|
||||
import { ViewManager } from '../../../src/card-controller/view/view-manager';
|
||||
import { FrigateCardView } from '../../../src/config/types';
|
||||
import { ViewQueryExecutor } from '../../../src/card-controller/view/view-query-executor';
|
||||
import { AdvancedCameraCardView } from '../../../src/config/types';
|
||||
import { ViewMedia } from '../../../src/view/media';
|
||||
import { EventMediaQueries } from '../../../src/view/media-queries';
|
||||
import { MediaQueriesResults } from '../../../src/view/media-queries-results';
|
||||
import { View } from '../../../src/view/view';
|
||||
import {
|
||||
createCameraManager,
|
||||
createCapabilities,
|
||||
@@ -13,15 +22,6 @@ import {
|
||||
createStore,
|
||||
createView,
|
||||
} from '../../test-utils';
|
||||
import { ViewQueryExecutor } from '../../../src/card-controller/view/view-query-executor';
|
||||
import { EventMediaQueries } from '../../../src/view/media-queries';
|
||||
import { QueryType } from '../../../src/camera-manager/types';
|
||||
import { SetQueryViewModifier } from '../../../src/card-controller/view/modifiers/set-query';
|
||||
import { View } from '../../../src/view/view';
|
||||
import {
|
||||
QueryExecutorOptions,
|
||||
ViewModifier,
|
||||
} from '../../../src/card-controller/view/types';
|
||||
|
||||
describe('should act correctly when view is set', () => {
|
||||
it('basic view', () => {
|
||||
@@ -279,7 +279,7 @@ describe('isViewSupportedByCamera', () => {
|
||||
['recordings' as const, false],
|
||||
['timeline' as const, false],
|
||||
['media' as const, false],
|
||||
])('%s', (viewName: FrigateCardView, expected: boolean) => {
|
||||
])('%s', (viewName: AdvancedCameraCardView, expected: boolean) => {
|
||||
const api = createCardAPI();
|
||||
vi.mocked(api.getCameraManager).mockReturnValue(createCameraManager());
|
||||
vi.mocked(api.getCameraManager().getStore).mockReturnValue(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mock } from 'vitest-mock-extended';
|
||||
import { applyViewModifiers } from '../../../src/card-controller/view/modifiers';
|
||||
import { QueryExecutor } from '../../../src/card-controller/view/query-executor';
|
||||
import { ViewQueryExecutor } from '../../../src/card-controller/view/view-query-executor';
|
||||
import { FrigateCardView } from '../../../src/config/types';
|
||||
import { AdvancedCameraCardView } from '../../../src/config/types';
|
||||
import {
|
||||
EventMediaQueries,
|
||||
RecordingMediaQueries,
|
||||
@@ -271,7 +271,10 @@ describe('ViewQueryExecutor', () => {
|
||||
['snapshots' as const, 'snapshots' as const],
|
||||
])(
|
||||
'%s',
|
||||
async (viewName: FrigateCardView, eventsMediaType: 'clips' | 'snapshots') => {
|
||||
async (
|
||||
viewName: AdvancedCameraCardView,
|
||||
eventsMediaType: 'clips' | 'snapshots',
|
||||
) => {
|
||||
const executor = mock<QueryExecutor>();
|
||||
const query = new EventMediaQueries();
|
||||
const queryResults = new MediaQueriesResults();
|
||||
@@ -310,7 +313,7 @@ describe('ViewQueryExecutor', () => {
|
||||
describe('with a recordings-based view', () => {
|
||||
it.each([['recording' as const], ['recordings' as const]])(
|
||||
'%s',
|
||||
async (viewName: FrigateCardView) => {
|
||||
async (viewName: AdvancedCameraCardView) => {
|
||||
const executor = mock<QueryExecutor>();
|
||||
const query = new RecordingMediaQueries();
|
||||
const queryResults = new MediaQueriesResults();
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('LiveController', () => {
|
||||
const host = createLitElement();
|
||||
const parent = createParent({ children: [host] });
|
||||
const eventListener = vi.fn();
|
||||
parent.addEventListener('frigate-card:media:loaded', eventListener);
|
||||
parent.addEventListener('advanced-camera-card:media:loaded', eventListener);
|
||||
|
||||
const controller = new LiveController(host);
|
||||
expect(host.addController).toBeCalled();
|
||||
@@ -70,7 +70,7 @@ describe('LiveController', () => {
|
||||
const host = createLitElement();
|
||||
const parent = createParent({ children: [host] });
|
||||
const eventListener = vi.fn();
|
||||
parent.addEventListener('frigate-card:media:loaded', eventListener);
|
||||
parent.addEventListener('advanced-camera-card:media:loaded', eventListener);
|
||||
|
||||
const controller = new LiveController(host);
|
||||
const mediaLoadedInfo = createMediaLoadedInfo();
|
||||
|
||||
@@ -5,7 +5,7 @@ import { dispatchLiveErrorEvent } from '../../../../src/components-lib/live/util
|
||||
it('should dispatch live error event', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:live:error', handler);
|
||||
element.addEventListener('advanced-camera-card:live:error', handler);
|
||||
|
||||
dispatchLiveErrorEvent(element);
|
||||
expect(handler).toBeCalled();
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
MediaActionsController,
|
||||
MediaActionsControllerOptions,
|
||||
} from '../../src/components-lib/media-actions-controller';
|
||||
import { FrigateCardMediaPlayer } from '../../src/types';
|
||||
import { AdvancedCameraCardMediaPlayer } from '../../src/types';
|
||||
import {
|
||||
IntersectionObserverMock,
|
||||
MutationObserverMock,
|
||||
@@ -18,11 +18,11 @@ import { callVisibilityHandler, createTestSlideNodes } from '../utils/embla/test
|
||||
const getPlayer = (
|
||||
element: HTMLElement,
|
||||
selector: string,
|
||||
): (HTMLElement & FrigateCardMediaPlayer) | null => {
|
||||
): (HTMLElement & AdvancedCameraCardMediaPlayer) | null => {
|
||||
return element.querySelector(selector);
|
||||
};
|
||||
|
||||
const createPlayer = (): HTMLElement & FrigateCardMediaPlayer => {
|
||||
const createPlayer = (): HTMLElement & AdvancedCameraCardMediaPlayer => {
|
||||
const player = document.createElement('video');
|
||||
|
||||
player['play'] = vi.fn();
|
||||
@@ -35,7 +35,7 @@ const createPlayer = (): HTMLElement & FrigateCardMediaPlayer => {
|
||||
player['setControls'] = vi.fn();
|
||||
player['isPaused'] = vi.fn();
|
||||
|
||||
return player as unknown as HTMLElement & FrigateCardMediaPlayer;
|
||||
return player as unknown as HTMLElement & AdvancedCameraCardMediaPlayer;
|
||||
};
|
||||
|
||||
const createPlayerSlideNodes = (n = 10): HTMLElement[] => {
|
||||
@@ -231,7 +231,7 @@ describe('MediaActionsController', () => {
|
||||
controller.unsetTarget();
|
||||
|
||||
getPlayer(children[0], 'video')?.dispatchEvent(
|
||||
new Event('frigate-card:media:loaded'),
|
||||
new Event('advanced-camera-card:media:loaded'),
|
||||
);
|
||||
await flushPromises();
|
||||
|
||||
@@ -255,7 +255,7 @@ describe('MediaActionsController', () => {
|
||||
expect(getPlayer(children[0], 'video')?.play).toBeCalledTimes(1);
|
||||
|
||||
getPlayer(children[0], 'video')?.dispatchEvent(
|
||||
new Event('frigate-card:media:loaded'),
|
||||
new Event('advanced-camera-card:media:loaded'),
|
||||
);
|
||||
|
||||
await flushPromises();
|
||||
@@ -277,7 +277,7 @@ describe('MediaActionsController', () => {
|
||||
expect(getPlayer(children[0], 'video')?.unmute).toBeCalledTimes(1);
|
||||
|
||||
getPlayer(children[0], 'video')?.dispatchEvent(
|
||||
new Event('frigate-card:media:loaded'),
|
||||
new Event('advanced-camera-card:media:loaded'),
|
||||
);
|
||||
|
||||
await flushPromises();
|
||||
@@ -299,7 +299,7 @@ describe('MediaActionsController', () => {
|
||||
await controller.setTarget(0, true);
|
||||
|
||||
getPlayer(children[9], 'video')?.dispatchEvent(
|
||||
new Event('frigate-card:media:loaded'),
|
||||
new Event('advanced-camera-card:media:loaded'),
|
||||
);
|
||||
|
||||
await flushPromises();
|
||||
@@ -325,7 +325,7 @@ describe('MediaActionsController', () => {
|
||||
expect(getPlayer(children[0], 'video')?.unmute).toBeCalledTimes(1);
|
||||
|
||||
getPlayer(children[0], 'video')?.dispatchEvent(
|
||||
new Event('frigate-card:media:loaded'),
|
||||
new Event('advanced-camera-card:media:loaded'),
|
||||
);
|
||||
|
||||
await flushPromises();
|
||||
|
||||
@@ -174,7 +174,7 @@ describe('MediaGridController', () => {
|
||||
const controller = createController(slot);
|
||||
|
||||
const mediaLoadedInfoHandler = vi.fn();
|
||||
host.addEventListener('frigate-card:media:loaded', mediaLoadedInfoHandler);
|
||||
host.addEventListener('advanced-camera-card:media:loaded', mediaLoadedInfoHandler);
|
||||
dispatchExistingMediaLoadedInfoAsEvent(children[0], mediaLoadedInfo);
|
||||
|
||||
controller.selectCell('0');
|
||||
@@ -194,7 +194,7 @@ describe('MediaGridController', () => {
|
||||
controller.selectCell('0');
|
||||
|
||||
const mediaLoadedInfoHandler = vi.fn();
|
||||
host.addEventListener('frigate-card:media:loaded', mediaLoadedInfoHandler);
|
||||
host.addEventListener('advanced-camera-card:media:loaded', mediaLoadedInfoHandler);
|
||||
dispatchExistingMediaLoadedInfoAsEvent(children[0], mediaLoadedInfo);
|
||||
|
||||
expect(mediaLoadedInfoHandler).toBeCalledWith(
|
||||
@@ -213,7 +213,7 @@ describe('MediaGridController', () => {
|
||||
controller.selectCell('1');
|
||||
|
||||
const mediaLoadedInfoHandler = vi.fn();
|
||||
host.addEventListener('frigate-card:media:loaded', mediaLoadedInfoHandler);
|
||||
host.addEventListener('advanced-camera-card:media:loaded', mediaLoadedInfoHandler);
|
||||
dispatchExistingMediaLoadedInfoAsEvent(children[0], mediaLoadedInfo);
|
||||
|
||||
// Another element is selected, so the event should not have propagated.
|
||||
@@ -228,8 +228,11 @@ describe('MediaGridController', () => {
|
||||
|
||||
const unselectedHandler = vi.fn();
|
||||
const unloadMediaHandler = vi.fn();
|
||||
host.addEventListener('frigate-card:media-grid:unselected', unselectedHandler);
|
||||
host.addEventListener('frigate-card:media:unloaded', unloadMediaHandler);
|
||||
host.addEventListener(
|
||||
'advanced-camera-card:media-grid:unselected',
|
||||
unselectedHandler,
|
||||
);
|
||||
host.addEventListener('advanced-camera-card:media:unloaded', unloadMediaHandler);
|
||||
|
||||
controller.selectCell('0');
|
||||
expect(controller.getSelected()).toBe('0');
|
||||
@@ -401,9 +404,9 @@ describe('MediaGridController', () => {
|
||||
columnWidth: 245,
|
||||
}),
|
||||
);
|
||||
expect(parent.style.getPropertyValue('--frigate-card-grid-column-size')).toBe(
|
||||
'245px',
|
||||
);
|
||||
expect(
|
||||
parent.style.getPropertyValue('--advanced-camera-card-grid-column-size'),
|
||||
).toBe('245px');
|
||||
});
|
||||
|
||||
it('should respect exact columns', () => {
|
||||
@@ -420,9 +423,9 @@ describe('MediaGridController', () => {
|
||||
columnWidth: 1499,
|
||||
}),
|
||||
);
|
||||
expect(parent.style.getPropertyValue('--frigate-card-grid-column-size')).toBe(
|
||||
'1499px',
|
||||
);
|
||||
expect(
|
||||
parent.style.getPropertyValue('--advanced-camera-card-grid-column-size'),
|
||||
).toBe('1499px');
|
||||
});
|
||||
|
||||
it('should respect selected width factor', () => {
|
||||
@@ -430,13 +433,13 @@ describe('MediaGridController', () => {
|
||||
const controller = createController(parent);
|
||||
controller.setDisplayConfig({ mode: 'grid', grid_selected_width_factor: 3 });
|
||||
expect(
|
||||
parent.style.getPropertyValue('--frigate-card-grid-selected-width-factor'),
|
||||
parent.style.getPropertyValue('--advanced-camera-card-grid-selected-width-factor'),
|
||||
).toBe('3');
|
||||
|
||||
// Setting the same config again should do nothing.
|
||||
controller.setDisplayConfig({ mode: 'grid', grid_selected_width_factor: 3 });
|
||||
expect(
|
||||
parent.style.getPropertyValue('--frigate-card-grid-selected-width-factor'),
|
||||
parent.style.getPropertyValue('--advanced-camera-card-grid-selected-width-factor'),
|
||||
).toBe('3');
|
||||
});
|
||||
|
||||
@@ -490,9 +493,9 @@ describe('MediaGridController', () => {
|
||||
columnWidth: 245,
|
||||
}),
|
||||
);
|
||||
expect(parent.style.getPropertyValue('--frigate-card-grid-column-size')).toBe(
|
||||
'245px',
|
||||
);
|
||||
expect(
|
||||
parent.style.getPropertyValue('--advanced-camera-card-grid-column-size'),
|
||||
).toBe('245px');
|
||||
|
||||
// Clear mock state.
|
||||
vi.mocked(Masonry).mockClear();
|
||||
@@ -509,9 +512,9 @@ describe('MediaGridController', () => {
|
||||
columnWidth: 599,
|
||||
}),
|
||||
);
|
||||
expect(parent.style.getPropertyValue('--frigate-card-grid-column-size')).toBe(
|
||||
'599px',
|
||||
);
|
||||
expect(
|
||||
parent.style.getPropertyValue('--advanced-camera-card-grid-column-size'),
|
||||
).toBe('599px');
|
||||
expect(masonry.layout).toBeCalled();
|
||||
|
||||
// Clear mock state.
|
||||
|
||||
@@ -14,12 +14,12 @@ import {
|
||||
MenuButtonControllerOptions,
|
||||
} from '../../src/components-lib/menu-button-controller';
|
||||
import {
|
||||
FrigateCardConfig,
|
||||
FrigateCardView,
|
||||
AdvancedCameraCardConfig,
|
||||
AdvancedCameraCardView,
|
||||
MenuItem,
|
||||
ViewDisplayMode,
|
||||
} from '../../src/config/types';
|
||||
import { FrigateCardMediaPlayer } from '../../src/types';
|
||||
import { AdvancedCameraCardMediaPlayer } from '../../src/types';
|
||||
import { createGeneralAction } from '../../src/utils/action';
|
||||
import { ViewMedia } from '../../src/view/media';
|
||||
import { MediaQueriesResults } from '../../src/view/media-queries-results';
|
||||
@@ -45,7 +45,7 @@ const calculateButtons = (
|
||||
controller: MenuButtonController,
|
||||
options?: MenuButtonControllerOptions & {
|
||||
hass?: HomeAssistant;
|
||||
config?: FrigateCardConfig;
|
||||
config?: AdvancedCameraCardConfig;
|
||||
cameraManager?: CameraManager;
|
||||
view?: View | null;
|
||||
viewManager?: ViewManager;
|
||||
@@ -72,7 +72,7 @@ const calculateButtons = (
|
||||
describe('MenuButtonController', () => {
|
||||
let controller: MenuButtonController;
|
||||
const dynamicButton: MenuItem = {
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:alpha-a-circle',
|
||||
title: 'Dynamic button',
|
||||
};
|
||||
@@ -82,17 +82,17 @@ describe('MenuButtonController', () => {
|
||||
controller = new MenuButtonController();
|
||||
});
|
||||
|
||||
describe('should have default menu button', () => {
|
||||
describe('should have iris menu button', () => {
|
||||
it('with hidden menu style', () => {
|
||||
const buttons = calculateButtons(controller);
|
||||
|
||||
expect(buttons).toContainEqual({
|
||||
icon: 'frigate',
|
||||
icon: 'iris',
|
||||
enabled: true,
|
||||
permanent: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
title: 'Frigate menu / Default view',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Iris / Default View / Unhide menu',
|
||||
tap_action: createGeneralAction('menu_toggle'),
|
||||
hold_action: createGeneralAction('diagnostics'),
|
||||
});
|
||||
@@ -104,12 +104,12 @@ describe('MenuButtonController', () => {
|
||||
});
|
||||
|
||||
expect(buttons).toContainEqual({
|
||||
icon: 'frigate',
|
||||
icon: 'iris',
|
||||
enabled: true,
|
||||
permanent: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
title: 'Frigate menu / Default view',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Iris / Default View / Unhide menu',
|
||||
tap_action: createGeneralAction('default'),
|
||||
hold_action: createGeneralAction('diagnostics'),
|
||||
});
|
||||
@@ -138,7 +138,7 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:video-switch',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-submenu',
|
||||
type: 'custom:advanced-camera-card-menu-submenu',
|
||||
title: 'Cameras',
|
||||
items: [
|
||||
{
|
||||
@@ -150,7 +150,7 @@ describe('MenuButtonController', () => {
|
||||
selected: true,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera-1',
|
||||
},
|
||||
},
|
||||
@@ -163,7 +163,7 @@ describe('MenuButtonController', () => {
|
||||
selected: false,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'camera-2',
|
||||
},
|
||||
},
|
||||
@@ -252,10 +252,10 @@ describe('MenuButtonController', () => {
|
||||
title: 'Substream(s)',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_on',
|
||||
advanced_camera_card_action: 'live_substream_on',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -289,14 +289,14 @@ describe('MenuButtonController', () => {
|
||||
|
||||
expect(buttons).toContainEqual({
|
||||
icon: 'mdi:video-input-component',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
title: 'Substream(s)',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_off',
|
||||
advanced_camera_card_action: 'live_substream_off',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -354,7 +354,7 @@ describe('MenuButtonController', () => {
|
||||
style: {},
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-submenu',
|
||||
type: 'custom:advanced-camera-card-menu-submenu',
|
||||
items: [
|
||||
{
|
||||
enabled: true,
|
||||
@@ -365,7 +365,7 @@ describe('MenuButtonController', () => {
|
||||
selected: true,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_select',
|
||||
advanced_camera_card_action: 'live_substream_select',
|
||||
camera: 'camera-1',
|
||||
},
|
||||
},
|
||||
@@ -378,7 +378,7 @@ describe('MenuButtonController', () => {
|
||||
selected: false,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_select',
|
||||
advanced_camera_card_action: 'live_substream_select',
|
||||
camera: 'camera-2',
|
||||
},
|
||||
},
|
||||
@@ -391,7 +391,7 @@ describe('MenuButtonController', () => {
|
||||
selected: false,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_select',
|
||||
advanced_camera_card_action: 'live_substream_select',
|
||||
camera: 'camera-3',
|
||||
},
|
||||
},
|
||||
@@ -443,10 +443,10 @@ describe('MenuButtonController', () => {
|
||||
expect(buttons).toContainEqual({
|
||||
icon: 'mdi:video-input-component',
|
||||
title: 'Substream(s)',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-submenu',
|
||||
type: 'custom:advanced-camera-card-menu-submenu',
|
||||
items: [
|
||||
{
|
||||
enabled: true,
|
||||
@@ -457,7 +457,7 @@ describe('MenuButtonController', () => {
|
||||
selected: false,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_select',
|
||||
advanced_camera_card_action: 'live_substream_select',
|
||||
camera: 'camera-1',
|
||||
},
|
||||
},
|
||||
@@ -472,7 +472,7 @@ describe('MenuButtonController', () => {
|
||||
selected: true,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_select',
|
||||
advanced_camera_card_action: 'live_substream_select',
|
||||
camera: 'camera-2',
|
||||
},
|
||||
},
|
||||
@@ -485,7 +485,7 @@ describe('MenuButtonController', () => {
|
||||
selected: false,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'live_substream_select',
|
||||
advanced_camera_card_action: 'live_substream_select',
|
||||
camera: 'camera-3',
|
||||
},
|
||||
},
|
||||
@@ -507,10 +507,10 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:cctv',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Live view',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'live' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'live' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -526,10 +526,10 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:cctv',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Live view',
|
||||
style: {},
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'live' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'live' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -561,11 +561,11 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:filmstrip',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Clips gallery',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'clips' },
|
||||
hold_action: { action: 'fire-dom-event', frigate_card_action: 'clip' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'clips' },
|
||||
hold_action: { action: 'fire-dom-event', advanced_camera_card_action: 'clip' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -580,11 +580,11 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:filmstrip',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Clips gallery',
|
||||
style: {},
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'clips' },
|
||||
hold_action: { action: 'fire-dom-event', frigate_card_action: 'clip' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'clips' },
|
||||
hold_action: { action: 'fire-dom-event', advanced_camera_card_action: 'clip' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -614,11 +614,17 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:camera',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Snapshots gallery',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'snapshots' },
|
||||
hold_action: { action: 'fire-dom-event', frigate_card_action: 'snapshot' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'snapshots',
|
||||
},
|
||||
hold_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'snapshot',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -633,11 +639,17 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:camera',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Snapshots gallery',
|
||||
style: {},
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'snapshots' },
|
||||
hold_action: { action: 'fire-dom-event', frigate_card_action: 'snapshot' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'snapshots',
|
||||
},
|
||||
hold_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'snapshot',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -669,11 +681,17 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:album',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Recordings gallery',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'recordings' },
|
||||
hold_action: { action: 'fire-dom-event', frigate_card_action: 'recording' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'recordings',
|
||||
},
|
||||
hold_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'recording',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -688,11 +706,17 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:album',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Recordings gallery',
|
||||
style: {},
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'recordings' },
|
||||
hold_action: { action: 'fire-dom-event', frigate_card_action: 'recording' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'recordings',
|
||||
},
|
||||
hold_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'recording',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -725,10 +749,10 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:image',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Static image',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'image' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'image' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -745,10 +769,10 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:image',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Static image',
|
||||
style: {},
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'image' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'image' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -780,10 +804,13 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:chart-gantt',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Timeline view',
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'timeline' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'timeline',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -799,10 +826,13 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:chart-gantt',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Timeline view',
|
||||
style: {},
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'timeline' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'timeline',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -844,9 +874,12 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:download',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Download',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'download' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'download',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -909,9 +942,9 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:web',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Camera user interface',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'camera_ui' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'camera_ui' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -935,19 +968,19 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:microphone',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Microphone',
|
||||
style: {
|
||||
animation: 'pulse 3s infinite',
|
||||
color: 'var(--frigate-card-menu-button-critical-color)',
|
||||
color: 'var(--advanced-camera-card-menu-button-critical-color)',
|
||||
},
|
||||
start_tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_unmute',
|
||||
advanced_camera_card_action: 'microphone_unmute',
|
||||
},
|
||||
end_tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_mute',
|
||||
advanced_camera_card_action: 'microphone_mute',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -989,7 +1022,7 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:microphone-message-off',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Microphone',
|
||||
style: {},
|
||||
});
|
||||
@@ -1014,16 +1047,16 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:microphone-off',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Microphone',
|
||||
style: {},
|
||||
start_tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_unmute',
|
||||
advanced_camera_card_action: 'microphone_unmute',
|
||||
},
|
||||
end_tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_mute',
|
||||
advanced_camera_card_action: 'microphone_mute',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1047,7 +1080,7 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:microphone-message-off',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Microphone',
|
||||
style: {},
|
||||
});
|
||||
@@ -1075,12 +1108,12 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:microphone-off',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Microphone',
|
||||
style: {},
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_unmute',
|
||||
advanced_camera_card_action: 'microphone_unmute',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1107,15 +1140,15 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:microphone',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Microphone',
|
||||
style: {
|
||||
animation: 'pulse 3s infinite',
|
||||
color: 'var(--frigate-card-menu-button-critical-color)',
|
||||
color: 'var(--advanced-camera-card-menu-button-critical-color)',
|
||||
},
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'microphone_mute',
|
||||
advanced_camera_card_action: 'microphone_mute',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1140,9 +1173,12 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:fullscreen',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Fullscreen',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'fullscreen' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'fullscreen',
|
||||
},
|
||||
style: {},
|
||||
});
|
||||
});
|
||||
@@ -1159,10 +1195,13 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:fullscreen-exit',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Fullscreen',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'fullscreen' },
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'fullscreen',
|
||||
},
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1188,9 +1227,9 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:arrow-expand-all',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Expand',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'expand' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'expand' },
|
||||
style: {},
|
||||
});
|
||||
});
|
||||
@@ -1202,10 +1241,10 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:arrow-collapse-all',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Expand',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'expand' },
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'expand' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1240,7 +1279,7 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:cast',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-submenu',
|
||||
type: 'custom:advanced-camera-card-menu-submenu',
|
||||
title: 'Send to media player',
|
||||
items: [
|
||||
{
|
||||
@@ -1252,13 +1291,13 @@ describe('MenuButtonController', () => {
|
||||
disabled: false,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'media_player',
|
||||
advanced_camera_card_action: 'media_player',
|
||||
media_player: 'media_player.tv',
|
||||
media_player_action: 'play',
|
||||
},
|
||||
hold_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'media_player',
|
||||
advanced_camera_card_action: 'media_player',
|
||||
media_player: 'media_player.tv',
|
||||
media_player_action: 'stop',
|
||||
},
|
||||
@@ -1293,7 +1332,7 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:cast',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-submenu',
|
||||
type: 'custom:advanced-camera-card-menu-submenu',
|
||||
title: 'Send to media player',
|
||||
items: [
|
||||
{
|
||||
@@ -1310,7 +1349,7 @@ describe('MenuButtonController', () => {
|
||||
});
|
||||
|
||||
it('should have pause button', () => {
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
const buttons = calculateButtons(controller, {
|
||||
currentMediaLoadedInfo: createMediaLoadedInfo({
|
||||
capabilities: {
|
||||
@@ -1324,14 +1363,14 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:pause',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Play / Pause',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'pause' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'pause' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should have play button', () => {
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player.isPaused.mockReturnValue(true);
|
||||
const buttons = calculateButtons(controller, {
|
||||
currentMediaLoadedInfo: createMediaLoadedInfo({
|
||||
@@ -1346,14 +1385,14 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:play',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Play / Pause',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'play' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'play' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should have mute button', () => {
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
const buttons = calculateButtons(controller, {
|
||||
currentMediaLoadedInfo: createMediaLoadedInfo({
|
||||
capabilities: {
|
||||
@@ -1367,14 +1406,14 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:volume-high',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Mute / Unmute',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'mute' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'mute' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should have unmute button', () => {
|
||||
const player = mock<FrigateCardMediaPlayer>();
|
||||
const player = mock<AdvancedCameraCardMediaPlayer>();
|
||||
player.isMuted.mockReturnValue(true);
|
||||
const buttons = calculateButtons(controller, {
|
||||
currentMediaLoadedInfo: createMediaLoadedInfo({
|
||||
@@ -1389,16 +1428,16 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:volume-off',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Mute / Unmute',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'unmute' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'unmute' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should have screenshot button', () => {
|
||||
const buttons = calculateButtons(controller, {
|
||||
currentMediaLoadedInfo: createMediaLoadedInfo({
|
||||
player: mock<FrigateCardMediaPlayer>(),
|
||||
player: mock<AdvancedCameraCardMediaPlayer>(),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -1406,9 +1445,12 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:monitor-screenshot',
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title: 'Screenshot',
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'screenshot' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'screenshot',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1435,18 +1477,18 @@ describe('MenuButtonController', () => {
|
||||
icon: displayMode === 'single' ? 'mdi:grid' : 'mdi:grid-off',
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
title:
|
||||
displayMode === 'grid'
|
||||
? 'Show single media viewer'
|
||||
: 'Show media viewer for each camera in a grid',
|
||||
style:
|
||||
displayMode === 'grid'
|
||||
? { color: 'var(--frigate-card-menu-button-active-color)' }
|
||||
? { color: 'var(--advanced-camera-card-menu-button-active-color)' }
|
||||
: {},
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'display_mode_select',
|
||||
advanced_camera_card_action: 'display_mode_select',
|
||||
display_mode: displayMode === 'single' ? 'grid' : 'single',
|
||||
},
|
||||
});
|
||||
@@ -1517,15 +1559,15 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:pan',
|
||||
priority: 50,
|
||||
style: {
|
||||
color: 'var(--frigate-card-menu-button-active-color)',
|
||||
color: 'var(--advanced-camera-card-menu-button-active-color)',
|
||||
},
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_controls',
|
||||
advanced_camera_card_action: 'ptz_controls',
|
||||
enabled: false,
|
||||
},
|
||||
title: 'Show PTZ controls',
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1553,11 +1595,11 @@ describe('MenuButtonController', () => {
|
||||
style: {},
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_controls',
|
||||
advanced_camera_card_action: 'ptz_controls',
|
||||
enabled: true,
|
||||
},
|
||||
title: 'Show PTZ controls',
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1583,15 +1625,15 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:pan',
|
||||
priority: 50,
|
||||
style: {
|
||||
color: 'var(--frigate-card-menu-button-active-color)',
|
||||
color: 'var(--advanced-camera-card-menu-button-active-color)',
|
||||
},
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_controls',
|
||||
advanced_camera_card_action: 'ptz_controls',
|
||||
enabled: false,
|
||||
},
|
||||
title: 'Show PTZ controls',
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1624,15 +1666,15 @@ describe('MenuButtonController', () => {
|
||||
icon: 'mdi:pan',
|
||||
priority: 50,
|
||||
style: {
|
||||
color: 'var(--frigate-card-menu-button-active-color)',
|
||||
color: 'var(--advanced-camera-card-menu-button-active-color)',
|
||||
},
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_controls',
|
||||
advanced_camera_card_action: 'ptz_controls',
|
||||
enabled: false,
|
||||
},
|
||||
title: 'Show PTZ controls',
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1648,7 +1690,7 @@ describe('MenuButtonController', () => {
|
||||
])(
|
||||
'%s view with isDefault %s',
|
||||
(
|
||||
viewName: FrigateCardView,
|
||||
viewName: AdvancedCameraCardView,
|
||||
isDefault: boolean | undefined,
|
||||
expectedResult: boolean,
|
||||
) => {
|
||||
@@ -1695,11 +1737,11 @@ describe('MenuButtonController', () => {
|
||||
priority: 50,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
target_id: targetID,
|
||||
},
|
||||
title: 'PTZ Home',
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
});
|
||||
} else {
|
||||
expect(buttons).not.toContainEqual(
|
||||
@@ -1747,7 +1789,7 @@ describe('MenuButtonController', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('with non-Frigate fire-dom-event action', () => {
|
||||
it('with non-advanced-camera-card fire-dom-event action', () => {
|
||||
const button: MenuItem = {
|
||||
...dynamicButton,
|
||||
tap_action: { action: 'fire-dom-event' },
|
||||
@@ -1761,37 +1803,40 @@ describe('MenuButtonController', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('with Frigate view action', () => {
|
||||
it('with advanced camera card view action', () => {
|
||||
const button: MenuItem = {
|
||||
...dynamicButton,
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'clips' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'clips' },
|
||||
};
|
||||
const view = createView({ view: 'clips' });
|
||||
controller.addDynamicMenuButton(button);
|
||||
|
||||
expect(calculateButtons(controller, { view: view })).toContainEqual({
|
||||
...button,
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
});
|
||||
});
|
||||
|
||||
it('with Frigate default action', () => {
|
||||
it('with advanced camera card default action', () => {
|
||||
const button: MenuItem = {
|
||||
...dynamicButton,
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'default' },
|
||||
tap_action: { action: 'fire-dom-event', advanced_camera_card_action: 'default' },
|
||||
};
|
||||
controller.addDynamicMenuButton(button);
|
||||
|
||||
expect(calculateButtons(controller)).toContainEqual({
|
||||
...button,
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
});
|
||||
});
|
||||
|
||||
it('with fullscreen action', () => {
|
||||
const button: MenuItem = {
|
||||
...dynamicButton,
|
||||
tap_action: { action: 'fire-dom-event', frigate_card_action: 'fullscreen' },
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'fullscreen',
|
||||
},
|
||||
};
|
||||
controller.addDynamicMenuButton(button);
|
||||
const fullscreenManager = mock<FullscreenManager>();
|
||||
@@ -1800,7 +1845,7 @@ describe('MenuButtonController', () => {
|
||||
|
||||
expect(calculateButtons(controller, { fullscreenManager })).toContainEqual({
|
||||
...button,
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1809,7 +1854,7 @@ describe('MenuButtonController', () => {
|
||||
...dynamicButton,
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'camera_select',
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: 'foo',
|
||||
},
|
||||
};
|
||||
@@ -1818,7 +1863,7 @@ describe('MenuButtonController', () => {
|
||||
|
||||
expect(calculateButtons(controller, { view: view })).toContainEqual({
|
||||
...button,
|
||||
style: { color: 'var(--frigate-card-menu-button-active-color)' },
|
||||
style: { color: 'var(--advanced-camera-card-menu-button-active-color)' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1827,7 +1872,7 @@ describe('MenuButtonController', () => {
|
||||
...dynamicButton,
|
||||
tap_action: [
|
||||
{ action: 'fire-dom-event' },
|
||||
{ action: 'fire-dom-event', frigate_card_action: 'clips' },
|
||||
{ action: 'fire-dom-event', advanced_camera_card_action: 'clips' },
|
||||
],
|
||||
};
|
||||
const view = createView({ camera: 'clips' });
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('MenuController', () => {
|
||||
};
|
||||
const menuToggleAction = {
|
||||
action: 'fire-dom-event' as const,
|
||||
frigate_card_action: 'menu_toggle' as const,
|
||||
advanced_camera_card_action: 'menu_toggle' as const,
|
||||
};
|
||||
const tapActionConfig = {
|
||||
camera_entity: 'foo',
|
||||
@@ -46,7 +46,9 @@ describe('MenuController', () => {
|
||||
controller.setMenuConfig(config);
|
||||
expect(controller.getMenuConfig()).toBe(config);
|
||||
|
||||
expect(host.style.getPropertyValue('--frigate-card-menu-button-size')).toBe('21px');
|
||||
expect(host.style.getPropertyValue('--advanced-camera-card-menu-button-size')).toBe(
|
||||
'21px',
|
||||
);
|
||||
expect(host.getAttribute('data-style')).toBe('hover');
|
||||
expect(host.getAttribute('data-position')).toBe('left');
|
||||
expect(host.getAttribute('data-alignment')).toBe('top');
|
||||
@@ -79,24 +81,24 @@ describe('MenuController', () => {
|
||||
|
||||
controller.setButtons([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
priority: 20,
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:goat',
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:chicken',
|
||||
priority: 40,
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:horse',
|
||||
priority: 40,
|
||||
alignment: 'matching',
|
||||
@@ -105,7 +107,7 @@ describe('MenuController', () => {
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
priority: 30,
|
||||
alignment: 'matching',
|
||||
@@ -114,13 +116,13 @@ describe('MenuController', () => {
|
||||
|
||||
expect(controller.getButtons('matching')).toEqual([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:chicken',
|
||||
priority: 40,
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:horse',
|
||||
priority: 40,
|
||||
alignment: 'matching',
|
||||
@@ -130,16 +132,16 @@ describe('MenuController', () => {
|
||||
alignment: 'matching',
|
||||
icon: 'mdi:sheep',
|
||||
priority: 30,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
},
|
||||
{
|
||||
alignment: 'matching',
|
||||
icon: 'mdi:cow',
|
||||
priority: 20,
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:goat',
|
||||
alignment: 'matching',
|
||||
},
|
||||
@@ -156,19 +158,19 @@ describe('MenuController', () => {
|
||||
controller.setExpanded(true);
|
||||
controller.setButtons([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
priority: 99,
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
icon: 'frigate',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'iris',
|
||||
alignment: 'matching',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
priority: 100,
|
||||
alignment: 'matching',
|
||||
@@ -177,19 +179,19 @@ describe('MenuController', () => {
|
||||
|
||||
expect(controller.getButtons('matching')).toEqual([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
icon: 'frigate',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'iris',
|
||||
alignment: 'matching',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
priority: 100,
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
priority: 99,
|
||||
alignment: 'matching',
|
||||
@@ -207,25 +209,25 @@ describe('MenuController', () => {
|
||||
controller.setExpanded(false);
|
||||
controller.setButtons([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
priority: 100,
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
icon: 'frigate',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'iris',
|
||||
alignment: 'matching',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
priority: 100,
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
alignment: 'matching',
|
||||
priority: 100,
|
||||
@@ -235,15 +237,15 @@ describe('MenuController', () => {
|
||||
|
||||
expect(controller.getButtons('matching')).toEqual([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
alignment: 'matching',
|
||||
priority: 100,
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
icon: 'frigate',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'iris',
|
||||
alignment: 'matching',
|
||||
permanent: true,
|
||||
},
|
||||
@@ -256,29 +258,29 @@ describe('MenuController', () => {
|
||||
const controller = new MenuController(createLitElement());
|
||||
controller.setButtons([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
alignment: 'opposing',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
},
|
||||
]);
|
||||
|
||||
expect(controller.getButtons('matching')).toEqual([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
alignment: 'matching',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
},
|
||||
]);
|
||||
@@ -288,16 +290,16 @@ describe('MenuController', () => {
|
||||
const controller = new MenuController(createLitElement());
|
||||
controller.setButtons([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:goat',
|
||||
enabled: true,
|
||||
},
|
||||
@@ -305,11 +307,11 @@ describe('MenuController', () => {
|
||||
|
||||
expect(controller.getButtons('matching')).toEqual([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:cow',
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:goat',
|
||||
enabled: true,
|
||||
},
|
||||
@@ -326,20 +328,20 @@ describe('MenuController', () => {
|
||||
|
||||
controller.setButtons([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
icon: 'frigate',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'iris',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
},
|
||||
]);
|
||||
|
||||
expect(controller.getButtons('matching')).toEqual([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
icon: 'frigate',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'iris',
|
||||
permanent: true,
|
||||
},
|
||||
]);
|
||||
@@ -348,12 +350,12 @@ describe('MenuController', () => {
|
||||
|
||||
expect(controller.getButtons('matching')).toEqual([
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
icon: 'frigate',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'iris',
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
type: 'custom:frigate-card-menu-icon',
|
||||
type: 'custom:advanced-camera-card-menu-icon',
|
||||
icon: 'mdi:sheep',
|
||||
},
|
||||
]);
|
||||
@@ -370,7 +372,7 @@ describe('MenuController', () => {
|
||||
it('should execute simple action in non-hidden menu', () => {
|
||||
const host = createLitElement();
|
||||
const handler = vi.fn();
|
||||
host.addEventListener('frigate-card:action:execution-request', handler);
|
||||
host.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new MenuController(host);
|
||||
|
||||
@@ -386,7 +388,7 @@ describe('MenuController', () => {
|
||||
it('should execute simple action in with config in event', () => {
|
||||
const host = createLitElement();
|
||||
const handler = vi.fn();
|
||||
host.addEventListener('frigate-card:action:execution-request', handler);
|
||||
host.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new MenuController(host);
|
||||
|
||||
@@ -401,7 +403,7 @@ describe('MenuController', () => {
|
||||
it('should execute simple array of actions in non-hidden menu', () => {
|
||||
const host = createLitElement();
|
||||
const handler = vi.fn();
|
||||
host.addEventListener('frigate-card:action:execution-request', handler);
|
||||
host.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new MenuController(host);
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { expect, it, vi } from 'vitest';
|
||||
import { dispatchFrigateCardErrorEvent } from '../../../src/components-lib/message/dispatch';
|
||||
import { FrigateCardError } from '../../../src/types';
|
||||
import { dispatchAdvancedCameraCardErrorEvent } from '../../../src/components-lib/message/dispatch';
|
||||
import { AdvancedCameraCardError } from '../../../src/types';
|
||||
|
||||
// @vitest-environment jsdom
|
||||
it('should ignore non-error', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:message', handler);
|
||||
element.addEventListener('advanced-camera-card:message', handler);
|
||||
|
||||
dispatchFrigateCardErrorEvent(element, 'NOT_FRIGATE_EVENT');
|
||||
dispatchAdvancedCameraCardErrorEvent(element, 'NOT_ADVANCED_CAMERA_CARD_EVENT');
|
||||
|
||||
expect(handler).not.toBeCalled();
|
||||
});
|
||||
@@ -16,9 +16,9 @@ it('should ignore non-error', () => {
|
||||
it('should dispatch error', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:message', handler);
|
||||
element.addEventListener('advanced-camera-card:message', handler);
|
||||
|
||||
dispatchFrigateCardErrorEvent(element, new Error('ERROR'));
|
||||
dispatchAdvancedCameraCardErrorEvent(element, new Error('ERROR'));
|
||||
|
||||
expect(handler).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -32,9 +32,12 @@ it('should dispatch error', () => {
|
||||
it('should dispatch error with context', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:message', handler);
|
||||
element.addEventListener('advanced-camera-card:message', handler);
|
||||
|
||||
dispatchFrigateCardErrorEvent(element, new FrigateCardError('ERROR', 'CONTEXT'));
|
||||
dispatchAdvancedCameraCardErrorEvent(
|
||||
element,
|
||||
new AdvancedCameraCardError('ERROR', 'CONTEXT'),
|
||||
);
|
||||
|
||||
expect(handler).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -172,13 +172,13 @@ describe('PTZController', () => {
|
||||
expect(controller.getPTZActions()?.[actionName]).toEqual({
|
||||
start_tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: actionName,
|
||||
ptz_phase: 'start',
|
||||
},
|
||||
end_tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
ptz_action: actionName,
|
||||
ptz_phase: 'stop',
|
||||
},
|
||||
@@ -211,7 +211,7 @@ describe('PTZController', () => {
|
||||
expect(controller.getPTZActions()['home']).toEqual({
|
||||
tap_action: {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'ptz_multi',
|
||||
advanced_camera_card_action: 'ptz_multi',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -229,7 +229,7 @@ describe('PTZController', () => {
|
||||
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:action:execution-request', handler);
|
||||
element.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new PTZController(element);
|
||||
controller.setCamera();
|
||||
@@ -251,7 +251,7 @@ describe('PTZController', () => {
|
||||
it('should not call action without actions config', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:action:execution-request', handler);
|
||||
element.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new PTZController(element);
|
||||
controller.setCamera();
|
||||
@@ -265,7 +265,7 @@ describe('PTZController', () => {
|
||||
it('should not call action without hass', () => {
|
||||
const element = document.createElement('div');
|
||||
const handler = vi.fn();
|
||||
element.addEventListener('frigate-card:action:execution-request', handler);
|
||||
element.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new PTZController(element);
|
||||
controller.setCamera();
|
||||
|
||||
@@ -22,9 +22,9 @@ describe('StatusBarController', () => {
|
||||
controller.setConfig(config);
|
||||
|
||||
expect(controller.getConfig()).toEqual(config);
|
||||
expect(host.style.getPropertyValue('--frigate-card-status-bar-height')).toBe(
|
||||
'50px',
|
||||
);
|
||||
expect(
|
||||
host.style.getPropertyValue('--advanced-camera-card-status-bar-height'),
|
||||
).toBe('50px');
|
||||
expect(host.getAttribute('data-style')).toBe('hover');
|
||||
expect(host.getAttribute('data-position')).toBe('top');
|
||||
expect(host.requestUpdate).toHaveBeenCalled();
|
||||
@@ -79,7 +79,7 @@ describe('StatusBarController', () => {
|
||||
const controller = new StatusBarController(host);
|
||||
const items = [
|
||||
{
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Test',
|
||||
},
|
||||
];
|
||||
@@ -92,22 +92,22 @@ describe('StatusBarController', () => {
|
||||
const host = createLitElement();
|
||||
const controller = new StatusBarController(host);
|
||||
const item1 = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 1',
|
||||
priority: 40,
|
||||
};
|
||||
const item2 = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 2',
|
||||
priority: 10,
|
||||
};
|
||||
const item3 = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 3',
|
||||
priority: 60,
|
||||
};
|
||||
const item4 = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 4',
|
||||
priority: undefined,
|
||||
};
|
||||
@@ -120,12 +120,12 @@ describe('StatusBarController', () => {
|
||||
const host = createLitElement();
|
||||
const controller = new StatusBarController(host);
|
||||
const item1 = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 1',
|
||||
priority: 100,
|
||||
};
|
||||
const exclusiveItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 2',
|
||||
priority: 1,
|
||||
exclusive: true,
|
||||
@@ -140,12 +140,12 @@ describe('StatusBarController', () => {
|
||||
const host = createLitElement();
|
||||
const controller = new StatusBarController(host);
|
||||
const insufficientItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 1',
|
||||
sufficient: false,
|
||||
};
|
||||
const sufficientItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 2',
|
||||
sufficient: true,
|
||||
};
|
||||
@@ -159,12 +159,12 @@ describe('StatusBarController', () => {
|
||||
const host = createLitElement();
|
||||
const controller = new StatusBarController(host);
|
||||
const insufficientItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 1',
|
||||
sufficient: false,
|
||||
};
|
||||
const sufficientItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 2',
|
||||
sufficient: false,
|
||||
};
|
||||
@@ -188,7 +188,7 @@ describe('StatusBarController', () => {
|
||||
);
|
||||
|
||||
const sufficientItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 1',
|
||||
priority: 100,
|
||||
sufficient: true,
|
||||
@@ -210,7 +210,7 @@ describe('StatusBarController', () => {
|
||||
);
|
||||
|
||||
const insufficientItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 1',
|
||||
priority: 100,
|
||||
sufficient: false,
|
||||
@@ -231,19 +231,19 @@ describe('StatusBarController', () => {
|
||||
);
|
||||
|
||||
const sufficientString = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'String',
|
||||
priority: 100,
|
||||
sufficient: true,
|
||||
};
|
||||
const sufficientIcon = {
|
||||
type: 'custom:frigate-card-status-bar-icon',
|
||||
type: 'custom:advanced-camera-card-status-bar-icon',
|
||||
icon: 'Icon',
|
||||
priority: 100,
|
||||
sufficient: true,
|
||||
};
|
||||
const sufficientImage = {
|
||||
type: 'custom:frigate-card-status-bar-image',
|
||||
type: 'custom:advanced-camera-card-status-bar-image',
|
||||
image: 'Image',
|
||||
priority: 100,
|
||||
sufficient: true,
|
||||
@@ -275,7 +275,7 @@ describe('StatusBarController', () => {
|
||||
);
|
||||
|
||||
const sufficientItem = {
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item 1',
|
||||
priority: 100,
|
||||
sufficient: true,
|
||||
@@ -297,7 +297,7 @@ describe('StatusBarController', () => {
|
||||
it('should bail without action', () => {
|
||||
const host = createLitElement();
|
||||
const handler = vi.fn();
|
||||
host.addEventListener('frigate-card:action:execution-request', handler);
|
||||
host.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new StatusBarController(host);
|
||||
controller.actionHandler(createInteractionEvent('tap'));
|
||||
@@ -307,7 +307,7 @@ describe('StatusBarController', () => {
|
||||
it('should request action execution', () => {
|
||||
const host = createLitElement();
|
||||
const handler = vi.fn();
|
||||
host.addEventListener('frigate-card:action:execution-request', handler);
|
||||
host.addEventListener('advanced-camera-card:action:execution-request', handler);
|
||||
|
||||
const controller = new StatusBarController(host);
|
||||
|
||||
|
||||
@@ -231,8 +231,8 @@ describe('ZoomController', () => {
|
||||
const element = document.createElement('div');
|
||||
const zoomedFunc = vi.fn();
|
||||
const unzoomedFunc = vi.fn();
|
||||
element.addEventListener('frigate-card:zoom:zoomed', zoomedFunc);
|
||||
element.addEventListener('frigate-card:zoom:unzoomed', unzoomedFunc);
|
||||
element.addEventListener('advanced-camera-card:zoom:zoomed', zoomedFunc);
|
||||
element.addEventListener('advanced-camera-card:zoom:unzoomed', unzoomedFunc);
|
||||
|
||||
vi.mocked(Panzoom).mockReturnValueOnce(createMockPanZoom());
|
||||
createAndRegisterZoom(element);
|
||||
@@ -267,8 +267,8 @@ describe('ZoomController', () => {
|
||||
const element = document.createElement('div');
|
||||
const zoomedFunc = vi.fn();
|
||||
const unzoomedFunc = vi.fn();
|
||||
element.addEventListener('frigate-card:zoom:zoomed', zoomedFunc);
|
||||
element.addEventListener('frigate-card:zoom:unzoomed', unzoomedFunc);
|
||||
element.addEventListener('advanced-camera-card:zoom:zoomed', zoomedFunc);
|
||||
element.addEventListener('advanced-camera-card:zoom:unzoomed', unzoomedFunc);
|
||||
|
||||
vi.mocked(Panzoom).mockReturnValueOnce(createMockPanZoom());
|
||||
createAndRegisterZoom(element);
|
||||
@@ -312,7 +312,7 @@ describe('ZoomController', () => {
|
||||
setElementToDefaultCardSize(element);
|
||||
|
||||
const changeFunc = vi.fn();
|
||||
element.addEventListener('frigate-card:zoom:change', changeFunc);
|
||||
element.addEventListener('advanced-camera-card:zoom:change', changeFunc);
|
||||
|
||||
vi.mocked(Panzoom).mockReturnValueOnce(createMockPanZoom());
|
||||
createAndRegisterZoom(element);
|
||||
@@ -357,7 +357,7 @@ describe('ZoomController', () => {
|
||||
setElementToDefaultCardSize(element);
|
||||
|
||||
const changeFunc = vi.fn();
|
||||
element.addEventListener('frigate-card:zoom:change', changeFunc);
|
||||
element.addEventListener('advanced-camera-card:zoom:change', changeFunc);
|
||||
|
||||
vi.mocked(Panzoom).mockReturnValueOnce(createMockPanZoom());
|
||||
const controller = createAndRegisterZoom(element);
|
||||
@@ -403,7 +403,7 @@ describe('ZoomController', () => {
|
||||
setElementToDefaultCardSize(element);
|
||||
|
||||
const changeFunc = vi.fn();
|
||||
element.addEventListener('frigate-card:zoom:change', changeFunc);
|
||||
element.addEventListener('advanced-camera-card:zoom:change', changeFunc);
|
||||
|
||||
vi.mocked(Panzoom).mockReturnValueOnce(createMockPanZoom());
|
||||
const controller = createAndRegisterZoom(element);
|
||||
|
||||
@@ -61,7 +61,7 @@ it('handleZoomSettingsObservedEvent', () => {
|
||||
const viewManager = mock<ViewManager>();
|
||||
|
||||
handleZoomSettingsObservedEvent(
|
||||
new CustomEvent('frigate-card:zoom:change', {
|
||||
new CustomEvent('advanced-camera-card:zoom:change', {
|
||||
detail: {
|
||||
pan: { x: 1, y: 2 },
|
||||
zoom: 3,
|
||||
|
||||
+656
-498
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import { setProfiles } from '../../../src/config/profiles';
|
||||
import { frigateCardConfigSchema } from '../../../src/config/types';
|
||||
import { createRawConfig } from '../../test-utils';
|
||||
import { CASTING_PROFILE } from '../../../src/config/profiles/casting';
|
||||
import { advancedCameraCardConfigSchema } from '../../../src/config/types';
|
||||
import { createRawConfig } from '../../test-utils';
|
||||
|
||||
it('should contain expected defaults', () => {
|
||||
expect(CASTING_PROFILE).toEqual({
|
||||
@@ -23,11 +23,11 @@ it('should contain expected defaults', () => {
|
||||
|
||||
it('should be parseable after application', () => {
|
||||
const rawInputConfig = createRawConfig();
|
||||
const parsedConfig = frigateCardConfigSchema.parse(rawInputConfig);
|
||||
const parsedConfig = advancedCameraCardConfigSchema.parse(rawInputConfig);
|
||||
|
||||
setProfiles(rawInputConfig, parsedConfig, ['casting']);
|
||||
|
||||
// Reparse the config to ensure the profile did not introduce errors.
|
||||
const parseResult = frigateCardConfigSchema.safeParse(parsedConfig);
|
||||
const parseResult = advancedCameraCardConfigSchema.safeParse(parsedConfig);
|
||||
expect(parseResult.success, parseResult.error?.toString()).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('setProfiles', () => {
|
||||
|
||||
it('should handle profiles', () => {
|
||||
const input = {
|
||||
type: 'frigate-hass-card',
|
||||
type: 'custom:advanced-camera-card',
|
||||
cameras: [{}],
|
||||
live: {
|
||||
controls: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import { setProfiles } from '../../../src/config/profiles';
|
||||
import { LOW_PERFORMANCE_PROFILE } from '../../../src/config/profiles/low-performance';
|
||||
import { frigateCardConfigSchema } from '../../../src/config/types';
|
||||
import { advancedCameraCardConfigSchema } from '../../../src/config/types';
|
||||
import { createRawConfig } from '../../test-utils';
|
||||
|
||||
it('should contain expected defaults', () => {
|
||||
@@ -37,7 +37,7 @@ it('should contain expected defaults', () => {
|
||||
'media_viewer.draggable': false,
|
||||
'media_viewer.snapshot_click_plays_clip': false,
|
||||
'media_viewer.transition_effect': 'none',
|
||||
'menu.buttons.frigate.enabled': false,
|
||||
'menu.buttons.iris.enabled': false,
|
||||
'menu.buttons.media_player.enabled': false,
|
||||
'menu.buttons.timeline.enabled': false,
|
||||
'menu.style': 'outside',
|
||||
@@ -60,11 +60,11 @@ it('should contain expected defaults', () => {
|
||||
|
||||
it('should be parseable after application', () => {
|
||||
const rawInputConfig = createRawConfig();
|
||||
const parsedConfig = frigateCardConfigSchema.parse(rawInputConfig);
|
||||
const parsedConfig = advancedCameraCardConfigSchema.parse(rawInputConfig);
|
||||
|
||||
setProfiles(rawInputConfig, parsedConfig, ['low-performance']);
|
||||
|
||||
// Reparse the config to ensure the profile did not introduce errors.
|
||||
const parseResult = frigateCardConfigSchema.safeParse(parsedConfig);
|
||||
const parseResult = advancedCameraCardConfigSchema.safeParse(parsedConfig);
|
||||
expect(parseResult.success, parseResult.error?.toString()).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import { SCRUBBING_PROFILE } from '../../../src/config/profiles/scrubbing';
|
||||
import { setProfiles } from '../../../src/config/profiles';
|
||||
import { frigateCardConfigSchema } from '../../../src/config/types';
|
||||
import { SCRUBBING_PROFILE } from '../../../src/config/profiles/scrubbing';
|
||||
import { advancedCameraCardConfigSchema } from '../../../src/config/types';
|
||||
import { createRawConfig } from '../../test-utils';
|
||||
|
||||
it('should contain expected defaults', () => {
|
||||
@@ -17,11 +17,11 @@ it('should contain expected defaults', () => {
|
||||
|
||||
it('should be parseable after application', () => {
|
||||
const rawInputConfig = createRawConfig();
|
||||
const parsedConfig = frigateCardConfigSchema.parse(rawInputConfig);
|
||||
const parsedConfig = advancedCameraCardConfigSchema.parse(rawInputConfig);
|
||||
|
||||
setProfiles(rawInputConfig, parsedConfig, ['low-performance']);
|
||||
|
||||
// Reparse the config to ensure the profile did not introduce errors.
|
||||
const parseResult = frigateCardConfigSchema.safeParse(parsedConfig);
|
||||
const parseResult = advancedCameraCardConfigSchema.safeParse(parsedConfig);
|
||||
expect(parseResult.success, parseResult.error?.toString()).toBeTruthy();
|
||||
});
|
||||
|
||||
+21
-21
@@ -4,9 +4,9 @@ import {
|
||||
conditionalSchema,
|
||||
customSchema,
|
||||
dimensionsConfigSchema,
|
||||
frigateCardConditionSchema,
|
||||
frigateCardCustomActionsBaseSchema,
|
||||
frigateCardCustomActionSchema,
|
||||
advancedCameraCardConditionSchema,
|
||||
advancedCameraCardCustomActionsBaseSchema,
|
||||
advancedCameraCardCustomActionSchema,
|
||||
} from '../../src/config/types';
|
||||
import { createConfig } from '../test-utils';
|
||||
|
||||
@@ -217,10 +217,6 @@ describe('config defaults', () => {
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
},
|
||||
frigate: {
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
},
|
||||
fullscreen: {
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
@@ -229,6 +225,10 @@ describe('config defaults', () => {
|
||||
enabled: false,
|
||||
priority: 50,
|
||||
},
|
||||
iris: {
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
},
|
||||
live: {
|
||||
enabled: true,
|
||||
priority: 50,
|
||||
@@ -338,7 +338,7 @@ describe('config defaults', () => {
|
||||
style: 'stack',
|
||||
window_seconds: 3600,
|
||||
},
|
||||
type: 'frigate-hass-card',
|
||||
type: 'advanced-camera-card',
|
||||
view: {
|
||||
camera_select: 'current',
|
||||
default: 'live',
|
||||
@@ -416,7 +416,7 @@ it('should transform dimensions.aspect_ratio', () => {
|
||||
describe('should refine user_agent_re conditions', () => {
|
||||
it('should successfully parse valid user_agent_re condition', () => {
|
||||
expect(
|
||||
frigateCardConditionSchema.parse({
|
||||
advancedCameraCardConditionSchema.parse({
|
||||
condition: 'user_agent',
|
||||
user_agent_re: 'Chrome/',
|
||||
}),
|
||||
@@ -428,7 +428,7 @@ describe('should refine user_agent_re conditions', () => {
|
||||
|
||||
it('should reject invalid user_agent_re conditions', () => {
|
||||
expect(() =>
|
||||
frigateCardConditionSchema.parse({
|
||||
advancedCameraCardConditionSchema.parse({
|
||||
condition: 'user_agent',
|
||||
user_agent_re: '[',
|
||||
}),
|
||||
@@ -438,15 +438,15 @@ describe('should refine user_agent_re conditions', () => {
|
||||
|
||||
it('should transform action', () => {
|
||||
expect(
|
||||
frigateCardCustomActionsBaseSchema.parse({
|
||||
action: 'custom:frigate-card-action',
|
||||
advancedCameraCardCustomActionsBaseSchema.parse({
|
||||
action: 'custom:advanced-camera-card-action',
|
||||
}),
|
||||
).toEqual({
|
||||
action: 'fire-dom-event',
|
||||
});
|
||||
});
|
||||
|
||||
describe('should convert webrtc card PTZ to Frigate card PTZ', () => {
|
||||
describe('should convert webrtc card PTZ to Advanced Camera Card PTZ', () => {
|
||||
describe('relative actions', () => {
|
||||
it.each([
|
||||
['left' as const],
|
||||
@@ -632,29 +632,29 @@ describe('should lazy evaluate schemas', () => {
|
||||
it('status bar actions', () => {
|
||||
const input = {
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'status_bar',
|
||||
advanced_camera_card_action: 'status_bar',
|
||||
status_bar_action: 'reset',
|
||||
items: [
|
||||
{
|
||||
type: 'custom:frigate-card-status-bar-string',
|
||||
type: 'custom:advanced-camera-card-status-bar-string',
|
||||
string: 'Item',
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(frigateCardCustomActionSchema.parse(input)).toEqual(input);
|
||||
expect(advancedCameraCardCustomActionSchema.parse(input)).toEqual(input);
|
||||
});
|
||||
});
|
||||
|
||||
describe('should handle custom frigate elements', () => {
|
||||
it('should add custom error on frigate entry', () => {
|
||||
describe('should handle custom advanced camera card elements', () => {
|
||||
it('should add custom error on advanced camera card element', () => {
|
||||
const result = customSchema.safeParse({
|
||||
type: 'custom:frigate-card-foo',
|
||||
type: 'custom:advanced-camera-card-foo',
|
||||
});
|
||||
expect(result.success).toBeFalsy();
|
||||
if (!result.success) {
|
||||
expect(result.error.errors[0]).toEqual({
|
||||
code: 'custom',
|
||||
message: 'Frigate-card custom elements must match specific schemas',
|
||||
message: 'advanced-camera-card custom elements must match specific schemas',
|
||||
fatal: true,
|
||||
path: ['type'],
|
||||
});
|
||||
@@ -669,7 +669,7 @@ describe('should handle custom frigate elements', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// https://github.com/dermotduffy/frigate-hass-card/issues/1280
|
||||
// https://github.com/dermotduffy/advanced-camera-card/issues/1280
|
||||
it('should not require title controls to specify all options', () => {
|
||||
expect(
|
||||
createConfig({
|
||||
|
||||
+21
-19
@@ -42,16 +42,16 @@ import { TriggersManager } from '../src/card-controller/triggers-manager';
|
||||
import { ViewManager } from '../src/card-controller/view/view-manager';
|
||||
import {
|
||||
ActionsConfig,
|
||||
AdvancedCameraCardCondition,
|
||||
AdvancedCameraCardConfig,
|
||||
AdvancedCameraCardCustomAction,
|
||||
CameraConfig,
|
||||
FrigateCardCondition,
|
||||
FrigateCardConfig,
|
||||
FrigateCardCustomAction,
|
||||
PerformanceConfig,
|
||||
RawFrigateCardConfig,
|
||||
RawAdvancedCameraCardConfig,
|
||||
advancedCameraCardConditionSchema,
|
||||
advancedCameraCardConfigSchema,
|
||||
advancedCameraCardCustomActionSchema,
|
||||
cameraConfigSchema,
|
||||
frigateCardConditionSchema,
|
||||
frigateCardConfigSchema,
|
||||
frigateCardCustomActionSchema,
|
||||
performanceConfigSchema,
|
||||
} from '../src/config/types';
|
||||
import { CapabilitiesRaw, ExtendedHomeAssistant, MediaLoadedInfo } from '../src/types';
|
||||
@@ -65,9 +65,9 @@ import { View, ViewParameters } from '../src/view/view';
|
||||
|
||||
export const createAction = (
|
||||
action: Record<string, unknown>,
|
||||
): FrigateCardCustomAction | null => {
|
||||
const result = frigateCardCustomActionSchema.safeParse({
|
||||
action: 'custom:frigate-card-action',
|
||||
): AdvancedCameraCardCustomAction | null => {
|
||||
const result = advancedCameraCardCustomActionSchema.safeParse({
|
||||
action: 'custom:advanced-camera-card-action',
|
||||
...action,
|
||||
});
|
||||
return result.success ? result.data : null;
|
||||
@@ -78,23 +78,25 @@ export const createCameraConfig = (config?: unknown): CameraConfig => {
|
||||
};
|
||||
|
||||
export const createCondition = (
|
||||
condition?: Partial<FrigateCardCondition>,
|
||||
): FrigateCardCondition => {
|
||||
return frigateCardConditionSchema.parse(condition ?? {});
|
||||
condition?: Partial<AdvancedCameraCardCondition>,
|
||||
): AdvancedCameraCardCondition => {
|
||||
return advancedCameraCardConditionSchema.parse(condition ?? {});
|
||||
};
|
||||
|
||||
export const createRawConfig = (
|
||||
config?: Partial<RawFrigateCardConfig>,
|
||||
): RawFrigateCardConfig => {
|
||||
config?: Partial<RawAdvancedCameraCardConfig>,
|
||||
): RawAdvancedCameraCardConfig => {
|
||||
return {
|
||||
type: 'frigate-hass-card',
|
||||
type: 'advanced-camera-card',
|
||||
cameras: [{}],
|
||||
...config,
|
||||
};
|
||||
};
|
||||
|
||||
export const createConfig = (config?: RawFrigateCardConfig): FrigateCardConfig => {
|
||||
return frigateCardConfigSchema.parse(createRawConfig(config));
|
||||
export const createConfig = (
|
||||
config?: RawAdvancedCameraCardConfig,
|
||||
): AdvancedCameraCardConfig => {
|
||||
return advancedCameraCardConfigSchema.parse(createRawConfig(config));
|
||||
};
|
||||
|
||||
export const createCamera = (
|
||||
@@ -296,7 +298,7 @@ export const createMediaLoadedInfo = (
|
||||
export const createMediaLoadedInfoEvent = (
|
||||
mediaLoadedInfo?: MediaLoadedInfo,
|
||||
): CustomEvent<MediaLoadedInfo> => {
|
||||
return new CustomEvent('frigate-card:media:loaded', {
|
||||
return new CustomEvent('advanced-camera-card:media:loaded', {
|
||||
detail: mediaLoadedInfo ?? createMediaLoadedInfo(),
|
||||
composed: true,
|
||||
bubbles: true,
|
||||
|
||||
+26
-26
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { FrigateCardView } from '../../src/config/types';
|
||||
import { AdvancedCameraCardView } from '../../src/config/types';
|
||||
import { CapabilityKey } from '../../src/types';
|
||||
import { getCameraIDsForViewName } from '../../src/view/view-to-cameras';
|
||||
import {
|
||||
@@ -13,7 +13,7 @@ describe('getCameraIDsForViewName', () => {
|
||||
describe('views that are always supported', () => {
|
||||
it.each([['image' as const], ['diagnostics' as const]])(
|
||||
'%s',
|
||||
(viewName: FrigateCardView) => {
|
||||
(viewName: AdvancedCameraCardView) => {
|
||||
const cameraManager = createCameraManager();
|
||||
vi.mocked(cameraManager.getStore).mockReturnValue(
|
||||
createStore([
|
||||
@@ -53,7 +53,7 @@ describe('getCameraIDsForViewName', () => {
|
||||
['timeline' as const, 'clips' as const],
|
||||
['timeline' as const, 'snapshots' as const],
|
||||
['timeline' as const, 'recordings' as const],
|
||||
])('%s', (viewName: FrigateCardView, capabilityKey: CapabilityKey) => {
|
||||
])('%s', (viewName: AdvancedCameraCardView, capabilityKey: CapabilityKey) => {
|
||||
const cameraManager = createCameraManager();
|
||||
vi.mocked(cameraManager.getStore).mockReturnValue(
|
||||
createStore([
|
||||
|
||||
Reference in New Issue
Block a user