Refactor views to support dynamic updates.

This commit is contained in:
Dermot Duffy
2024-07-26 19:15:38 -07:00
parent 33dee47205
commit d5c4e56c45
80 changed files with 3714 additions and 4021 deletions
@@ -19,10 +19,12 @@ describe('should handle camera_select action', () => {
await action.execute(api);
expect(api.getViewManager().setViewByParameters).toBeCalledWith(
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledWith(
expect.objectContaining({
viewName: 'live',
cameraID: 'camera',
params: {
view: 'live',
camera: 'camera',
},
failSafe: true,
}),
);
@@ -49,10 +51,12 @@ describe('should handle camera_select action', () => {
await action.execute(api);
expect(api.getViewManager().setViewByParameters).toBeCalledWith(
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledWith(
expect.objectContaining({
viewName: 'timeline',
cameraID: 'camera',
params: {
view: 'timeline',
camera: 'camera',
},
failSafe: true,
}),
);
@@ -86,10 +90,12 @@ describe('should handle camera_select action', () => {
await action.execute(api);
expect(api.getViewManager().setViewByParameters).toBeCalledWith(
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledWith(
expect.objectContaining({
viewName: 'clips',
cameraID: 'camera',
params: {
view: 'clips',
camera: 'camera',
},
failSafe: true,
}),
);
@@ -114,10 +120,12 @@ describe('should handle camera_select action', () => {
await action.execute(api);
expect(api.getViewManager().setViewByParameters).toBeCalledWith(
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledWith(
expect.objectContaining({
viewName: 'live',
cameraID: 'camera',
params: {
view: 'live',
camera: 'camera',
},
failSafe: true,
}),
);
@@ -141,7 +149,7 @@ describe('should handle camera_select action', () => {
await action.execute(api);
expect(api.getViewManager().setViewByParameters).not.toBeCalled();
expect(api.getViewManager().setViewByParametersWithNewQuery).not.toBeCalled();
});
it('without a current view', async () => {
@@ -158,6 +166,6 @@ describe('should handle camera_select action', () => {
await action.execute(api);
expect(api.getViewManager().setViewByParameters).not.toBeCalled();
expect(api.getViewManager().setViewByParametersWithNewQuery).not.toBeCalled();
});
});
@@ -15,5 +15,9 @@ it('should handle default action', async () => {
await action.execute(api);
expect(api.getViewManager().setViewWithNewDisplayMode).toBeCalledWith('grid');
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledWith({
params: {
displayMode: 'grid',
},
});
});
@@ -1,6 +1,7 @@
import { expect, it } from 'vitest';
import { SubstreamOffAction } from '../../../../src/card-controller/actions/actions/substream-off';
import { createCardAPI } from '../../../test-utils';
import { SubstreamOffViewModifier } from '../../../../src/card-controller/view/modifiers/substream-off';
it('should handle live_substream_off action', async () => {
const api = createCardAPI();
@@ -14,5 +15,7 @@ it('should handle live_substream_off action', async () => {
await action.execute(api);
expect(api.getViewManager().setViewWithoutSubstream).toBeCalled();
expect(api.getViewManager().setViewByParameters).toBeCalledWith({
modifiers: [expect.any(SubstreamOffViewModifier)],
});
});
@@ -1,6 +1,7 @@
import { expect, it } from 'vitest';
import { SubstreamOnAction } from '../../../../src/card-controller/actions/actions/substream-on';
import { createCardAPI } from '../../../test-utils';
import { SubstreamOnViewModifier } from '../../../../src/card-controller/view/modifiers/substream-on';
it('should handle live_substream_on action', async () => {
const api = createCardAPI();
@@ -14,5 +15,7 @@ it('should handle live_substream_on action', async () => {
await action.execute(api);
expect(api.getViewManager().setViewWithSubstream).toBeCalledWith();
expect(api.getViewManager().setViewByParameters).toBeCalledWith({
modifiers: [expect.any(SubstreamOnViewModifier)],
});
});
@@ -1,6 +1,7 @@
import { expect, it } from 'vitest';
import { SubstreamSelectAction } from '../../../../src/card-controller/actions/actions/substream-select';
import { createCardAPI } from '../../../test-utils';
import { SubstreamSelectViewModifier } from '../../../../src/card-controller/view/modifiers/substream-select';
it('should handle live_substream_select action', async () => {
const api = createCardAPI();
@@ -15,5 +16,9 @@ it('should handle live_substream_select action', async () => {
await action.execute(api);
expect(api.getViewManager().setViewWithSubstream).toBeCalledWith('substream');
expect(api.getViewManager().setViewByParameters).toBeCalledWith(
expect.objectContaining({
modifiers: expect.arrayContaining([expect.any(SubstreamSelectViewModifier)]),
}),
);
});
@@ -27,9 +27,11 @@ describe('should handle view action', () => {
await action.execute(api);
expect(api.getViewManager().setViewByParameters).toBeCalledWith(
expect(api.getViewManager().setViewByParametersWithNewQuery).toBeCalledWith(
expect.objectContaining({
viewName: viewName,
params: {
view: viewName,
},
}),
);
});