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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user