Compare commits

..
Author SHA1 Message Date
Cédric VerstraetenandClaude Opus 5.5 57055498a2 docs: move recording layout into README-FILE-STRUCTURE.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:46:55 +00:00
13 changed files with 7659 additions and 1067 deletions
+58
View File
@@ -0,0 +1,58 @@
# Recording file structure
This document describes where the Kerberos Agent stores recordings, locally and in
direct S3 uploads, and how the current layout relates to the legacy one.
## Local recording layout
New local recordings are stored under
`data/recordings/yyyy/mm/dd/<timestamp>-<deviceKey>.mp4`, using the recording's UTC
start date and Unix-millisecond timestamp. For example:
`data/recordings/2026/01/02/1767355200123-device-key.mp4`.
The filename no longer embeds the camera name, region, change count, or duration,
and it does not change when the recording is finalized.
Those attributes, together with FPS and encryption status, are captured in the
`.metadata` upload checkpoint and sent as structured HTTP/tus metadata.
Existing flat recordings and dated recordings with older long filenames remain
supported without a migration. Recording lists, day filters, playback, uploaders,
and automatic cleanup handle both filename formats and layouts. Upload queue
checkpoints remain flat in `data/cloud/`. Successful-upload removal also resolves
both local layouts. Deploy the updated Vault alongside Agent for canonical
`<account-directory>/yyyy/mm/dd/<timestamp>-<deviceKey>.mp4` storage keys and
metadata-driven Hub integration events.
Directory decryption also processes dated subdirectories and writes each output
to a sibling `decrypted/` directory; those outputs are excluded from recording
lists and automatic cleanup.
## Direct S3 recording layout
Direct S3 uploads store recordings as
`<s3.username>/yyyy/mm/dd/<timestamp>-<deviceKey>.mp4`. The timestamp is the
recording's Unix timestamp in milliseconds, and the date is its UTC date, not the upload
date. Timestamp and device key come from the recording's `.metadata` upload
checkpoint, which stores the timestamp in milliseconds. The uploader also
preserves checkpoint duration, FPS (when available), and encryption status as S3
object metadata. The device key must be non-empty and contain no path separators.
Retried uploads use the same object key, even after midnight. Millisecond
precision keeps recordings starting within the same second distinct.
This replaces the previous `<s3.username>/<filename>.mp4` layout for new uploads.
Existing objects are not moved; consumers of direct S3 uploads must support both
layouts when reading historical recordings. Updated Kerberos Vault deployments
use the same filename and dated layout under the authenticated account directory
for both direct Vault uploads and Hub-proxied uploads.
Only historical recordings with missing, empty, or FPS-only queue markers fall
back to the legacy filename format and configured Agent key. A structured
checkpoint takes precedence over both the filename and current configured key;
an invalid or unreadable checkpoint is reported as an upload error, not silently
replaced with filename-derived values.
For older structured checkpoints, missing camera name, region, and change count
are recovered from a validated legacy filename. Populated checkpoint fields
take precedence, and the checkpoint timestamp and device key remain authoritative.
The shorter filename cannot be decoded by legacy filename-only consumers.
Integrations must preserve structured recording metadata, including the device
key (`productid`) and recording timestamp (`event-timestamp`), as well as the full
object key.
+4 -59
View File
@@ -61,6 +61,7 @@ There are a myriad of cameras out there (USB, IP and other cameras), and it migh
1. [Encryption](#encryption)
2. [H264 vs H265](#h264-vs-h265)
3. [Recording file structure](README-FILE-STRUCTURE.md)
### Contributing
@@ -76,60 +77,6 @@ There are a myriad of cameras out there (USB, IP and other cameras), and it migh
1. [What is new?](#what-is-new)
1. [Contributors](#contributors)
### Direct S3 recording layout
Direct S3 uploads store recordings as
`<s3.username>/yyyy/mm/dd/<timestamp>-<deviceKey>.mp4`. The timestamp is the
recording's Unix timestamp in milliseconds, and the date is its UTC date, not the upload
date. Timestamp and device key come from the recording's `.metadata` upload
checkpoint, which stores the timestamp in milliseconds. The uploader also
preserves checkpoint duration, FPS (when available), and encryption status as S3
object metadata. The device key must be non-empty and contain no path separators.
Retried uploads use the same object key, even after midnight. Millisecond
precision keeps recordings starting within the same second distinct.
This replaces the previous `<s3.username>/<filename>.mp4` layout for new uploads.
Existing objects are not moved; consumers of direct S3 uploads must support both
layouts when reading historical recordings. Updated Kerberos Vault deployments
use the same filename and dated layout under the authenticated account directory
for both direct Vault uploads and Hub-proxied uploads.
Only historical recordings with missing, empty, or FPS-only queue markers fall
back to the legacy filename format and configured Agent key. A structured
checkpoint takes precedence over both the filename and current configured key;
an invalid or unreadable checkpoint is reported as an upload error, not silently
replaced with filename-derived values.
For older structured checkpoints, missing camera name, region, and change count
are recovered from a validated legacy filename. Populated checkpoint fields
take precedence, and the checkpoint timestamp and device key remain authoritative.
The shorter filename cannot be decoded by legacy filename-only consumers.
Integrations must preserve structured recording metadata, including the device
key (`productid`) and recording timestamp (`event-timestamp`), as well as the full
object key.
### Local recording layout
New local recordings are stored under
`data/recordings/yyyy/mm/dd/<timestamp>-<deviceKey>.mp4`, using the recording's UTC
start date and Unix-millisecond timestamp. For example:
`data/recordings/2026/01/02/1767355200123-device-key.mp4`.
The filename no longer embeds the camera name, region, change count, or duration,
and it does not change when the recording is finalized.
Those attributes, together with FPS and encryption status, are captured in the
`.metadata` upload checkpoint and sent as structured HTTP/tus metadata.
Existing flat recordings and dated recordings with older long filenames remain
supported without a migration. Recording lists, day filters, playback, uploaders,
and automatic cleanup handle both filename formats and layouts. Upload queue
checkpoints remain flat in `data/cloud/`. Successful-upload removal also resolves
both local layouts. Deploy the updated Vault alongside Agent for canonical
`<account-directory>/yyyy/mm/dd/<timestamp>-<deviceKey>.mp4` storage keys and
metadata-driven Hub integration events.
Directory decryption also processes dated subdirectories and writes each output
to a sibling `decrypted/` directory; those outputs are excluded from recording
lists and automatic cleanup.
## Quickstart - Docker
The easiest way to get your Kerberos Agent up and running is to use our public image on [Docker hub](https://hub.docker.com/r/kerberos/agent). Once you have selected a specific tag, run `docker` command below, which will open the web interface of your Kerberos agent on port `80`, and off you go. For a more configurable and persistent deployment have a look at [Running and automating a Kerberos Agent](#running-and-automating-a-kerberos-agent).
@@ -662,9 +609,7 @@ The Kerberos Agent is divided in two parts: a `machinery` and `web` part. Both p
### UI
The `web` is a **React** project, built with [Vite](https://vite.dev), which is
the main entry point for an end user to view recordings, a livestream, and
modify the configuration of the `machinery`.
The `web` is a **React** project which is the main entry point for an end user to view recordings, a livestream, and modify the configuration of the `machinery`.
git clone https://github.com/kerberos-io/agent
cd ui
@@ -673,7 +618,7 @@ modify the configuration of the `machinery`.
This starts the web app on port `3000`. In development, the UI connects to the
Agent API on port `8082`. Override that port when needed:
VITE_AGENT_API_PORT=9090 yarn start
REACT_APP_AGENT_API_PORT=9090 yarn start
![login-agent](./assets/img/agent-login.gif)
@@ -693,7 +638,7 @@ You can simply run the `machinery` using following commands.
This will launch the Kerberos Agent and run a webserver on port `8082`, matching
the UI development default. You can change the port together with
`VITE_AGENT_API_PORT`. We strongly support the usage of
`REACT_APP_AGENT_API_PORT`. We strongly support the usage of
[Goland](https://www.jetbrains.com/go/) or
[Visual Studio Code](https://code.visualstudio.com/), as it comes with all the
debugging and linting features built in.
+60 -27
View File
@@ -1,37 +1,70 @@
# Kerberos Agent UI
# Getting Started with Create React App
The web interface of the Kerberos Agent: a React app built with
[Vite](https://vite.dev) and tested with [Vitest](https://vitest.dev).
Requires Node.js 20.19 or newer.
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Scripts
## Available Scripts
- `yarn start`: starts the dev server on
[http://localhost:3000](http://localhost:3000) with hot reload.
- `yarn build`: builds for production and moves the output to
`../machinery/www`, where the Agent serves it.
- `yarn preview`: serves the production build from `../machinery/www` on
port 3000. Run `yarn build` first.
- `yarn test`: runs the test suite once. `yarn test:watch` keeps it running.
- `yarn lint`: lints `src/` with ESLint.
- `yarn format`: formats the code with Prettier.
In the project directory, you can run:
## Configuration
### `yarn start`
In development the UI talks to the Agent API on port `8082` of the same host.
Override it with `VITE_AGENT_API_PORT`:
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
VITE_AGENT_API_PORT=9090 yarn start
The page will reload if you make edits.\
You will also see any lint errors in the console.
In production builds the UI uses the host and port it was served from.
### `yarn test`
Runtime settings that differ per deployment (such as demo mode) live in
`public/env.js`, which the Agent can replace without rebuilding the UI.
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
## Layout
### `yarn build`
- `index.html`: the HTML entry point; Vite injects the bundle here.
- `src/`: application code. `src/index.jsx` is the entry module.
- `public/`: copied unchanged to the build root (favicons, fonts, locales, `env.js`).
- Bundled JS, CSS and assets go to `static/` in the build, so they don't mix
with the `assets/` folder from `public/`.
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `yarn build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
-26
View File
@@ -1,26 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png?v=1">
<link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png?v=1">
<link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png?v=1">
<link rel="manifest" href="/favicons/site.webmanifest?v=1">
<link rel="mask-icon" href="/favicons/safari-pinned-tab.svg?v=1" color="#b4524e">
<link rel="shortcut icon" href="/favicons/favicon.ico?v=1">
<meta name="msapplication-TileColor" content="#b4524e">
<meta name="msapplication-config" content="/favicons/browserconfig.xml?v=1">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="/manifest.json" />
<script src="/env.js"></script>
<title>Kerberos Agent | Video surveillance for everyone </title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>
+22 -14
View File
@@ -1,12 +1,9 @@
{
"name": "agent-ui",
"version": "0.1.0",
"engines": {
"node": ">=20.19.0"
},
"dependencies": {
"@giantmachines/redux-websocket": "^1.5.1",
"@kerberos-io/ui": "https://github.com/kerberos-io/ui/releases/download/v1.77.1/kerberos-io-ui-1.77.1.tgz",
"@kerberos-io/ui": "^1.76.0",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@testing-library/jest-dom": "^5.16.5",
@@ -32,6 +29,7 @@
"react-router": "^5.2.0",
"react-router-dom": "^5.3.3",
"react-router-redux": "^4.0.8",
"react-scripts": "5.*",
"react-tooltip": "^4.2.21",
"redux": "^4.2.0",
"redux-devtools-extension": "^2.13.9",
@@ -46,28 +44,38 @@
"crypto": false
},
"scripts": {
"start": "vite",
"build": "vite build && rm -rf ../machinery/www && mv build ../machinery/www",
"preview": "vite preview --outDir ../machinery/www",
"test": "vitest run",
"test:watch": "vitest",
"start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true GENERATE_SOURCEMAP=false REACT_APP_ENVIRONMENT=production react-scripts build && rm -rf ../machinery/www && mv build ../machinery/www",
"test": "DISABLE_ESLINT_PLUGIN=true react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint --debug 'src/**/*.{js,jsx,ts,tsx}'",
"format": "prettier --write \"**/*.{js,jsx,json,md}\""
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@vitejs/plugin-react": "^6.3.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"jsdom": "^29.1.1",
"sass": "^1.108.2",
"vite": "^8.3.8",
"vitest": "^4.1.12"
"sass": "^1.54.4",
"sass-loader": "^10.3.1"
},
"resolutions": {
"@tootallnate/once": "^2.0.1",
"serialize-javascript": "^7.1.3",
"uuid": "^11.1.1"
}
}
+48
View File
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/favicons/apple-touch-icon.png?v=1">
<link rel="icon" type="image/png" sizes="32x32" href="%PUBLIC_URL%/favicons/favicon-32x32.png?v=1">
<link rel="icon" type="image/png" sizes="16x16" href="%PUBLIC_URL%/favicons/favicon-16x16.png?v=1">
<link rel="manifest" href="%PUBLIC_URL%/favicons/site.webmanifest?v=1">
<link rel="mask-icon" href="%PUBLIC_URL%/favicons/safari-pinned-tab.svg?v=1" color="#b4524e">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicons/favicon.ico?v=1">
<meta name="msapplication-TileColor" content="#b4524e">
<meta name="msapplication-config" content="%PUBLIC_URL%/favicons/browserconfig.xml?v=1">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<script src="%PUBLIC_URL%/env.js"></script>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Kerberos Agent | Video surveillance for everyone </title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
+28 -33
View File
@@ -1,5 +1,4 @@
/* eslint-env jest */
import { vi } from 'vitest';
/* eslint-disable react/prop-types */
import React from 'react';
import { interval } from 'rxjs';
@@ -7,11 +6,11 @@ import { App } from './App';
const subscriptions = [];
vi.mock('rxjs', () => ({
interval: vi.fn(),
jest.mock('rxjs', () => ({
interval: jest.fn(),
}));
vi.mock('@kerberos-io/ui', () => {
jest.mock('@kerberos-io/ui', () => {
const Mock = ({ children }) => <div>{children}</div>;
return {
Badge: Mock,
@@ -28,46 +27,42 @@ vi.mock('@kerberos-io/ui', () => {
};
});
vi.mock('./components/LanguageSelect/LanguageSelect', () => ({
default: () => null,
jest.mock('./components/LanguageSelect/LanguageSelect', () => () => null);
jest.mock('./actions', () => ({ logout: jest.fn() }));
jest.mock('./actions/agent', () => ({
getDashboardInformation: jest.fn(),
}));
vi.mock('./actions', () => ({ logout: vi.fn() }));
vi.mock('./actions/agent', () => ({
getDashboardInformation: vi.fn(),
jest.mock('./config', () => ({
MODE: 'release',
URL: 'http://localhost',
WS_URL: 'ws://localhost/ws',
}));
vi.mock('./config', () => ({
default: {
MODE: 'release',
URL: 'http://localhost',
WS_URL: 'ws://localhost/ws',
},
}));
vi.mock('react-redux', () => ({
jest.mock('react-redux', () => ({
connect: () => (Component) => Component,
}));
vi.mock('react-i18next', () => ({
jest.mock('react-i18next', () => ({
withTranslation: () => (Component) => Component,
}));
vi.mock('react-router-dom', () => ({
jest.mock('react-router-dom', () => ({
Link: ({ children }) => <>{children}</>,
}));
vi.mock('@giantmachines/redux-websocket', () => ({
connect: vi.fn(),
disconnect: vi.fn(),
send: vi.fn(),
jest.mock('@giantmachines/redux-websocket', () => ({
connect: jest.fn(),
disconnect: jest.fn(),
send: jest.fn(),
}));
vi.mock('uuid', () => ({
v4: vi.fn(() => 'uuid-1'),
jest.mock('uuid', () => ({
v4: jest.fn(() => 'uuid-1'),
}));
describe('App lifecycle refresh behaviour', () => {
const baseProps = () => ({
t: (value) => value,
dispatchLogout: vi.fn(),
dispatchConnect: vi.fn(),
dispatchDisconnect: vi.fn(),
dispatchSend: vi.fn(),
dispatchGetDashboardInformation: vi.fn((onSuccess) => {
dispatchLogout: jest.fn(),
dispatchConnect: jest.fn(),
dispatchDisconnect: jest.fn(),
dispatchSend: jest.fn(),
dispatchGetDashboardInformation: jest.fn((onSuccess) => {
if (onSuccess) {
onSuccess();
}
@@ -83,12 +78,12 @@ describe('App lifecycle refresh behaviour', () => {
beforeEach(() => {
subscriptions.length = 0;
vi.clearAllMocks();
jest.clearAllMocks();
interval.mockImplementation(() => ({
subscribe: vi.fn((callback) => {
subscribe: jest.fn((callback) => {
const subscription = {
callback,
unsubscribe: vi.fn(),
unsubscribe: jest.fn(),
};
subscriptions.push(subscription);
return subscription;
+4 -7
View File
@@ -1,18 +1,15 @@
/* eslint-env jest */
import { vi } from 'vitest';
import API from './api';
import { doGetDashboardInformation } from './agent';
vi.mock('./api', () => ({
default: {
get: vi.fn(),
},
jest.mock('./api', () => ({
get: jest.fn(),
}));
describe('dashboard API', () => {
it('bounds dashboard requests so polling can recover', async () => {
const onSuccess = vi.fn();
const onError = vi.fn();
const onSuccess = jest.fn();
const onError = jest.fn();
API.get.mockResolvedValue({
status: 200,
data: { uptime: '1 minute' },
@@ -1,23 +1,22 @@
/* eslint-env jest */
import { vi } from 'vitest';
import { ImageCanvas } from './ImageCanvas';
vi.mock('vott-ct', () => ({
jest.mock('vott-ct', () => ({
CanvasTools: {
Editor: vi.fn(),
Editor: jest.fn(),
Core: {
RegionData: vi.fn(),
Point2D: vi.fn(),
Tag: vi.fn(),
TagsDescriptor: vi.fn(),
RegionData: jest.fn(),
Point2D: jest.fn(),
Tag: jest.fn(),
TagsDescriptor: jest.fn(),
Colors: {
Color: vi.fn(),
Color: jest.fn(),
},
},
},
}));
vi.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
jest.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
SelectionMode: {
NONE: 'none',
RECT: 'rect',
@@ -25,7 +24,7 @@ vi.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
},
}));
vi.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
jest.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
RegionDataType: {
Polygon: 'polygon',
},
@@ -33,9 +32,9 @@ vi.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
describe('ImageCanvas update guards', () => {
const callbacks = {
onAddRegion: vi.fn(),
onUpdateRegion: vi.fn(),
onDeleteRegion: vi.fn(),
onAddRegion: jest.fn(),
onUpdateRegion: jest.fn(),
onDeleteRegion: jest.fn(),
};
const baseProps = () => ({
@@ -46,7 +45,7 @@ describe('ImageCanvas update guards', () => {
});
beforeEach(() => {
vi.clearAllMocks();
jest.clearAllMocks();
});
it('ignores unrelated parent updates', () => {
@@ -56,8 +55,8 @@ describe('ImageCanvas update guards', () => {
};
const canvas = new ImageCanvas(props);
canvas.props = props;
canvas.loadImage = vi.fn();
canvas.loadData = vi.fn();
canvas.loadImage = jest.fn();
canvas.loadData = jest.fn();
canvas.componentDidUpdate({
...props,
@@ -72,8 +71,8 @@ describe('ImageCanvas update guards', () => {
const props = baseProps();
const canvas = new ImageCanvas(props);
canvas.props = props;
canvas.loadImage = vi.fn();
canvas.loadData = vi.fn();
canvas.loadImage = jest.fn();
canvas.loadData = jest.fn();
canvas.componentDidUpdate({
...props,
@@ -98,8 +97,8 @@ describe('ImageCanvas update guards', () => {
width: 100,
height: 100,
};
canvas.loadImage = vi.fn();
canvas.loadData = vi.fn();
canvas.loadImage = jest.fn();
canvas.loadData = jest.fn();
canvas.componentDidUpdate({
...props,
+3 -3
View File
@@ -1,6 +1,6 @@
const { hostname, host, protocol } = window.location;
const websocketprotocol = protocol === 'http:' ? 'ws:' : 'wss:';
const devAgentPort = import.meta.env.VITE_AGENT_API_PORT || '8082';
const devAgentPort = process.env.REACT_APP_AGENT_API_PORT || '8082';
// Uncomment this when using codespaces or other special DNS names (which you can't control)
// replace this with the DNS name of the kerberos agent server (the codespace url)
@@ -22,7 +22,7 @@ const dev = {
};
const prod = {
ENV: import.meta.env.MODE,
ENV: process.env.REACT_APP_ENVIRONMENT,
HOSTNAME: hostname,
API_URL: `${protocol}//${host}/api`,
URL: `${protocol}//${host}`,
@@ -30,7 +30,7 @@ const prod = {
MODE: window['env']['mode'],
};
const config = import.meta.env.PROD ? prod : dev;
const config = process.env.REACT_APP_ENVIRONMENT === 'production' ? prod : dev;
export default {
// Add common config values here
+42 -44
View File
@@ -1,18 +1,17 @@
/* eslint-env jest */
import { vi } from 'vitest';
/* eslint-disable react/prop-types */
import React from 'react';
import { Settings } from './Settings';
vi.mock('rxjs', () => ({
interval: vi.fn(() => ({
subscribe: vi.fn(() => ({
unsubscribe: vi.fn(),
jest.mock('rxjs', () => ({
interval: jest.fn(() => ({
subscribe: jest.fn(() => ({
unsubscribe: jest.fn(),
})),
})),
}));
vi.mock('@kerberos-io/ui', () => {
jest.mock('@kerberos-io/ui', () => {
const Mock = ({ children }) => <div>{children}</div>;
return {
Breadcrumb: Mock,
@@ -32,37 +31,36 @@ vi.mock('@kerberos-io/ui', () => {
};
});
vi.mock('react-redux', () => ({
jest.mock('react-redux', () => ({
connect: () => (Component) => Component,
}));
vi.mock('react-i18next', () => ({
jest.mock('react-i18next', () => ({
withTranslation: () => (Component) => Component,
}));
vi.mock('react-router-dom', () => ({
jest.mock('react-router-dom', () => ({
Link: ({ children }) => <>{children}</>,
withRouter: (Component) => Component,
}));
vi.mock('@giantmachines/redux-websocket', () => ({
send: vi.fn(),
jest.mock('@giantmachines/redux-websocket', () => ({
send: jest.fn(),
}));
vi.mock('../../components/ImageCanvas/ImageCanvas', () => ({
default: () => null,
}));
vi.mock('../../websocket', () => ({
jest.mock('../../components/ImageCanvas/ImageCanvas', () => () => null);
jest.mock('../../websocket', () => ({
__esModule: true,
default: 'uuid-1',
}));
vi.mock('../../actions/agent', () => ({
addRegion: vi.fn(),
updateRegion: vi.fn(),
removeRegion: vi.fn(),
saveConfig: vi.fn(),
verifyOnvif: vi.fn(),
verifyCamera: vi.fn(),
verifyHub: vi.fn(),
verifyPersistence: vi.fn(),
verifySecondaryPersistence: vi.fn(),
getConfig: vi.fn(),
updateConfig: vi.fn(),
jest.mock('../../actions/agent', () => ({
addRegion: jest.fn(),
updateRegion: jest.fn(),
removeRegion: jest.fn(),
saveConfig: jest.fn(),
verifyOnvif: jest.fn(),
verifyCamera: jest.fn(),
verifyHub: jest.fn(),
verifyPersistence: jest.fn(),
verifySecondaryPersistence: jest.fn(),
getConfig: jest.fn(),
updateConfig: jest.fn(),
}));
describe('Settings liveview lifecycle', () => {
@@ -80,22 +78,22 @@ describe('Settings liveview lifecycle', () => {
connected: true,
config,
images: [],
dispatchVerifyHub: vi.fn(),
dispatchVerifyPersistence: vi.fn(),
dispatchVerifySecondaryPersistence: vi.fn(),
dispatchGetConfig: vi.fn(),
dispatchUpdateConfig: vi.fn(),
dispatchSaveConfig: vi.fn(),
dispatchAddRegion: vi.fn(),
dispatchUpdateRegion: vi.fn(),
dispatchRemoveRegion: vi.fn(),
dispatchVerifyCamera: vi.fn(),
dispatchVerifyOnvif: vi.fn(),
dispatchSend: vi.fn(),
dispatchVerifyHub: jest.fn(),
dispatchVerifyPersistence: jest.fn(),
dispatchVerifySecondaryPersistence: jest.fn(),
dispatchGetConfig: jest.fn(),
dispatchUpdateConfig: jest.fn(),
dispatchSaveConfig: jest.fn(),
dispatchAddRegion: jest.fn(),
dispatchUpdateRegion: jest.fn(),
dispatchRemoveRegion: jest.fn(),
dispatchVerifyCamera: jest.fn(),
dispatchVerifyOnvif: jest.fn(),
dispatchSend: jest.fn(),
});
beforeEach(() => {
vi.clearAllMocks();
jest.clearAllMocks();
});
it('starts and stops SD imagery with the conditions editor visibility', () => {
@@ -107,8 +105,8 @@ describe('Settings liveview lifecycle', () => {
selectedTab: 'conditions',
search: '',
};
settings.initialiseLiveview = vi.fn();
settings.stopLiveview = vi.fn();
settings.initialiseLiveview = jest.fn();
settings.stopLiveview = jest.fn();
settings.componentDidUpdate(props, {
...settings.state,
@@ -140,7 +138,7 @@ describe('Settings liveview lifecycle', () => {
search: '',
};
settings.sdLiveviewActive = true;
settings.requestSDLiveviewFrame = vi.fn();
settings.requestSDLiveviewFrame = jest.fn();
settings.componentDidUpdate(
{
@@ -159,7 +157,7 @@ describe('Settings liveview lifecycle', () => {
settings.props = props;
settings.sdLiveviewActive = true;
settings.requestStreamSubscription = {
unsubscribe: vi.fn(),
unsubscribe: jest.fn(),
};
settings.componentWillUnmount();
-28
View File
@@ -1,28 +0,0 @@
// eslint-plugin-import 2.x cannot resolve packages that only define "exports".
/* eslint-disable import/no-unresolved */
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
base: '/',
server: {
port: 3000,
host: true,
},
preview: {
port: 3000,
},
build: {
outDir: 'build',
// public/assets already holds static files; keep bundled output separate.
assetsDir: 'static',
sourcemap: false,
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/setupTests.js',
css: false,
},
});
+7371 -806
View File
File diff suppressed because it is too large Load Diff