Compare commits

...
Author SHA1 Message Date
Cédric VerstraetenandClaude Opus 5.5 485ec02c55 ui: address lint findings in the Vite migration
- vite.config.mjs: disable import/no-unresolved; eslint-plugin-import 2.x
  cannot resolve packages that only define "exports" (vite, plugin-react)
- ui/README.md: turn the scripts table into a list to keep lines short
- README.md: wrap the edited UI paragraph

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:38:12 +00:00
Cédric Verstraeten 00398a4dd7 Merge branch 'fix/dependabot-alerts' into feat/ui-vite 2026-11-21 21:37:08 +00:00
Cédric VerstraetenandClaude Opus 5.5 7e8431c11c ui: install @kerberos-io/ui 1.77.1 from its GitHub release
Replace the vendored tarball with the one attached to the kerberos-io/ui
v1.77.1 GitHub release, as uug-ai/factory already does. That tarball is
built by the ui repo's release workflow and ships with a .sha256 file
(e9f94f44...); yarn.lock pins it by hash.

Its JS is identical to the locally built tarball, and its CSS differs
only in selector order within @extend-generated rules.

This removes ui/vendor and the extra COPY line in the Dockerfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:58:37 +00:00
Cédric VerstraetenandClaude Opus 5.5 6cd077daa3 ui: vendor @kerberos-io/ui 1.77.1 to clear the last Dependabot alerts
@kerberos-io/ui 1.77.1 moves its build tools (@svgr/webpack,
svg-react-loader, sass-loader, Storybook, Rollup plugins) out of its
runtime dependencies. Those pulled svgo 1 and decode-uri-component 0.2
into the agent's lockfile.

1.77.1 is tagged on GitHub but was never published to npm, so install
it from a tarball built from kerberos-io/ui@ae1faa7 (tag v1.77.1) and
committed under ui/vendor. Compared with the published 1.77.0 the
exports are identical; the only code change is the bundled uuid (8 -> 11).

The Dockerfile copies ui/vendor before `yarn --frozen-lockfile`.
ui/vendor/README.md records the checksum and how to switch back to the
registry once a fixed version is published.

Clears the remaining 5 Dependabot alerts (svgo, decode-uri-component).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:42:30 +00:00
Cédric VerstraetenandClaude Opus 5.5 6c49611211 ui: migrate from Create React App to Vite
react-scripts 5 is unmaintained and pins vulnerable versions of
webpack-dev-server, webpack-dev-middleware, postcss 7 and svgo.

- build and dev server: Vite 8 with @vitejs/plugin-react
- tests: Vitest 4 with jsdom (jest.* -> vi.*; mocked default exports
  now return { default })
- index.html moves to ui/ and loads src/index.jsx as a module
- REACT_APP_ENVIRONMENT is replaced by import.meta.env.PROD/MODE, and
  REACT_APP_AGENT_API_PORT is renamed to VITE_AGENT_API_PORT
- bundled output goes to static/ so it does not mix with public/assets
- package.json is not "type": "module": that would switch CommonJS
  interop to Node semantics and break default imports such as
  @giantmachines/redux-websocket
- sass 1.54 -> 1.108 (Vite needs the modern compiler API); sass-loader
  removed
- requires Node >= 20.19

`yarn build` still writes to machinery/www, so the Dockerfile and CI
workflow are unchanged.

Clears the remaining 9 react-scripts Dependabot alerts. Five alerts for
svgo 1 and decode-uri-component 0.2 remain; they come from build-tool
dependencies of @kerberos-io/ui and are not part of the bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:18:54 +00:00
12 changed files with 1007 additions and 7594 deletions
+5 -3
View File
@@ -662,7 +662,9 @@ The Kerberos Agent is divided in two parts: a `machinery` and `web` part. Both p
### UI
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`.
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`.
git clone https://github.com/kerberos-io/agent
cd ui
@@ -671,7 +673,7 @@ The `web` is a **React** project which is the main entry point for an end user t
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:
REACT_APP_AGENT_API_PORT=9090 yarn start
VITE_AGENT_API_PORT=9090 yarn start
![login-agent](./assets/img/agent-login.gif)
@@ -691,7 +693,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
`REACT_APP_AGENT_API_PORT`. We strongly support the usage of
`VITE_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.
+27 -60
View File
@@ -1,70 +1,37 @@
# Getting Started with Create React App
# Kerberos Agent UI
This project was bootstrapped with [Create React App](https://github.com/facebook/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.
## Available Scripts
## Scripts
In the project directory, you can run:
- `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.
### `yarn start`
## Configuration
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
In development the UI talks to the Agent API on port `8082` of the same host.
Override it with `VITE_AGENT_API_PORT`:
The page will reload if you make edits.\
You will also see any lint errors in the console.
VITE_AGENT_API_PORT=9090 yarn start
### `yarn test`
In production builds the UI uses the host and port it was served from.
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.
Runtime settings that differ per deployment (such as demo mode) live in
`public/env.js`, which the Agent can replace without rebuilding the UI.
### `yarn build`
## Layout
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)
- `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/`.
+26
View File
@@ -0,0 +1,26 @@
<!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>
+14 -22
View File
@@ -1,9 +1,12 @@
{
"name": "agent-ui",
"version": "0.1.0",
"engines": {
"node": ">=20.19.0"
},
"dependencies": {
"@giantmachines/redux-websocket": "^1.5.1",
"@kerberos-io/ui": "^1.76.0",
"@kerberos-io/ui": "https://github.com/kerberos-io/ui/releases/download/v1.77.1/kerberos-io-ui-1.77.1.tgz",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@testing-library/jest-dom": "^5.16.5",
@@ -29,7 +32,6 @@
"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",
@@ -44,38 +46,28 @@
"crypto": false
},
"scripts": {
"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",
"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",
"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",
"sass": "^1.54.4",
"sass-loader": "^10.3.1"
"jsdom": "^29.1.1",
"sass": "^1.108.2",
"vite": "^8.3.8",
"vitest": "^4.1.12"
},
"resolutions": {
"@tootallnate/once": "^2.0.1",
"serialize-javascript": "^7.1.3",
"uuid": "^11.1.1"
}
}
-48
View File
@@ -1,48 +0,0 @@
<!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>
+33 -28
View File
@@ -1,4 +1,5 @@
/* eslint-env jest */
import { vi } from 'vitest';
/* eslint-disable react/prop-types */
import React from 'react';
import { interval } from 'rxjs';
@@ -6,11 +7,11 @@ import { App } from './App';
const subscriptions = [];
jest.mock('rxjs', () => ({
interval: jest.fn(),
vi.mock('rxjs', () => ({
interval: vi.fn(),
}));
jest.mock('@kerberos-io/ui', () => {
vi.mock('@kerberos-io/ui', () => {
const Mock = ({ children }) => <div>{children}</div>;
return {
Badge: Mock,
@@ -27,42 +28,46 @@ jest.mock('@kerberos-io/ui', () => {
};
});
jest.mock('./components/LanguageSelect/LanguageSelect', () => () => null);
jest.mock('./actions', () => ({ logout: jest.fn() }));
jest.mock('./actions/agent', () => ({
getDashboardInformation: jest.fn(),
vi.mock('./components/LanguageSelect/LanguageSelect', () => ({
default: () => null,
}));
jest.mock('./config', () => ({
MODE: 'release',
URL: 'http://localhost',
WS_URL: 'ws://localhost/ws',
vi.mock('./actions', () => ({ logout: vi.fn() }));
vi.mock('./actions/agent', () => ({
getDashboardInformation: vi.fn(),
}));
jest.mock('react-redux', () => ({
vi.mock('./config', () => ({
default: {
MODE: 'release',
URL: 'http://localhost',
WS_URL: 'ws://localhost/ws',
},
}));
vi.mock('react-redux', () => ({
connect: () => (Component) => Component,
}));
jest.mock('react-i18next', () => ({
vi.mock('react-i18next', () => ({
withTranslation: () => (Component) => Component,
}));
jest.mock('react-router-dom', () => ({
vi.mock('react-router-dom', () => ({
Link: ({ children }) => <>{children}</>,
}));
jest.mock('@giantmachines/redux-websocket', () => ({
connect: jest.fn(),
disconnect: jest.fn(),
send: jest.fn(),
vi.mock('@giantmachines/redux-websocket', () => ({
connect: vi.fn(),
disconnect: vi.fn(),
send: vi.fn(),
}));
jest.mock('uuid', () => ({
v4: jest.fn(() => 'uuid-1'),
vi.mock('uuid', () => ({
v4: vi.fn(() => 'uuid-1'),
}));
describe('App lifecycle refresh behaviour', () => {
const baseProps = () => ({
t: (value) => value,
dispatchLogout: jest.fn(),
dispatchConnect: jest.fn(),
dispatchDisconnect: jest.fn(),
dispatchSend: jest.fn(),
dispatchGetDashboardInformation: jest.fn((onSuccess) => {
dispatchLogout: vi.fn(),
dispatchConnect: vi.fn(),
dispatchDisconnect: vi.fn(),
dispatchSend: vi.fn(),
dispatchGetDashboardInformation: vi.fn((onSuccess) => {
if (onSuccess) {
onSuccess();
}
@@ -78,12 +83,12 @@ describe('App lifecycle refresh behaviour', () => {
beforeEach(() => {
subscriptions.length = 0;
jest.clearAllMocks();
vi.clearAllMocks();
interval.mockImplementation(() => ({
subscribe: jest.fn((callback) => {
subscribe: vi.fn((callback) => {
const subscription = {
callback,
unsubscribe: jest.fn(),
unsubscribe: vi.fn(),
};
subscriptions.push(subscription);
return subscription;
+7 -4
View File
@@ -1,15 +1,18 @@
/* eslint-env jest */
import { vi } from 'vitest';
import API from './api';
import { doGetDashboardInformation } from './agent';
jest.mock('./api', () => ({
get: jest.fn(),
vi.mock('./api', () => ({
default: {
get: vi.fn(),
},
}));
describe('dashboard API', () => {
it('bounds dashboard requests so polling can recover', async () => {
const onSuccess = jest.fn();
const onError = jest.fn();
const onSuccess = vi.fn();
const onError = vi.fn();
API.get.mockResolvedValue({
status: 200,
data: { uptime: '1 minute' },
@@ -1,22 +1,23 @@
/* eslint-env jest */
import { vi } from 'vitest';
import { ImageCanvas } from './ImageCanvas';
jest.mock('vott-ct', () => ({
vi.mock('vott-ct', () => ({
CanvasTools: {
Editor: jest.fn(),
Editor: vi.fn(),
Core: {
RegionData: jest.fn(),
Point2D: jest.fn(),
Tag: jest.fn(),
TagsDescriptor: jest.fn(),
RegionData: vi.fn(),
Point2D: vi.fn(),
Tag: vi.fn(),
TagsDescriptor: vi.fn(),
Colors: {
Color: jest.fn(),
Color: vi.fn(),
},
},
},
}));
jest.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
vi.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
SelectionMode: {
NONE: 'none',
RECT: 'rect',
@@ -24,7 +25,7 @@ jest.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
},
}));
jest.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
vi.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
RegionDataType: {
Polygon: 'polygon',
},
@@ -32,9 +33,9 @@ jest.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
describe('ImageCanvas update guards', () => {
const callbacks = {
onAddRegion: jest.fn(),
onUpdateRegion: jest.fn(),
onDeleteRegion: jest.fn(),
onAddRegion: vi.fn(),
onUpdateRegion: vi.fn(),
onDeleteRegion: vi.fn(),
};
const baseProps = () => ({
@@ -45,7 +46,7 @@ describe('ImageCanvas update guards', () => {
});
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});
it('ignores unrelated parent updates', () => {
@@ -55,8 +56,8 @@ describe('ImageCanvas update guards', () => {
};
const canvas = new ImageCanvas(props);
canvas.props = props;
canvas.loadImage = jest.fn();
canvas.loadData = jest.fn();
canvas.loadImage = vi.fn();
canvas.loadData = vi.fn();
canvas.componentDidUpdate({
...props,
@@ -71,8 +72,8 @@ describe('ImageCanvas update guards', () => {
const props = baseProps();
const canvas = new ImageCanvas(props);
canvas.props = props;
canvas.loadImage = jest.fn();
canvas.loadData = jest.fn();
canvas.loadImage = vi.fn();
canvas.loadData = vi.fn();
canvas.componentDidUpdate({
...props,
@@ -97,8 +98,8 @@ describe('ImageCanvas update guards', () => {
width: 100,
height: 100,
};
canvas.loadImage = jest.fn();
canvas.loadData = jest.fn();
canvas.loadImage = vi.fn();
canvas.loadData = vi.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 = process.env.REACT_APP_AGENT_API_PORT || '8082';
const devAgentPort = import.meta.env.VITE_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: process.env.REACT_APP_ENVIRONMENT,
ENV: import.meta.env.MODE,
HOSTNAME: hostname,
API_URL: `${protocol}//${host}/api`,
URL: `${protocol}//${host}`,
@@ -30,7 +30,7 @@ const prod = {
MODE: window['env']['mode'],
};
const config = process.env.REACT_APP_ENVIRONMENT === 'production' ? prod : dev;
const config = import.meta.env.PROD ? prod : dev;
export default {
// Add common config values here
+44 -42
View File
@@ -1,17 +1,18 @@
/* eslint-env jest */
import { vi } from 'vitest';
/* eslint-disable react/prop-types */
import React from 'react';
import { Settings } from './Settings';
jest.mock('rxjs', () => ({
interval: jest.fn(() => ({
subscribe: jest.fn(() => ({
unsubscribe: jest.fn(),
vi.mock('rxjs', () => ({
interval: vi.fn(() => ({
subscribe: vi.fn(() => ({
unsubscribe: vi.fn(),
})),
})),
}));
jest.mock('@kerberos-io/ui', () => {
vi.mock('@kerberos-io/ui', () => {
const Mock = ({ children }) => <div>{children}</div>;
return {
Breadcrumb: Mock,
@@ -31,36 +32,37 @@ jest.mock('@kerberos-io/ui', () => {
};
});
jest.mock('react-redux', () => ({
vi.mock('react-redux', () => ({
connect: () => (Component) => Component,
}));
jest.mock('react-i18next', () => ({
vi.mock('react-i18next', () => ({
withTranslation: () => (Component) => Component,
}));
jest.mock('react-router-dom', () => ({
vi.mock('react-router-dom', () => ({
Link: ({ children }) => <>{children}</>,
withRouter: (Component) => Component,
}));
jest.mock('@giantmachines/redux-websocket', () => ({
send: jest.fn(),
vi.mock('@giantmachines/redux-websocket', () => ({
send: vi.fn(),
}));
jest.mock('../../components/ImageCanvas/ImageCanvas', () => () => null);
jest.mock('../../websocket', () => ({
__esModule: true,
vi.mock('../../components/ImageCanvas/ImageCanvas', () => ({
default: () => null,
}));
vi.mock('../../websocket', () => ({
default: 'uuid-1',
}));
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(),
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(),
}));
describe('Settings liveview lifecycle', () => {
@@ -78,22 +80,22 @@ describe('Settings liveview lifecycle', () => {
connected: true,
config,
images: [],
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(),
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(),
});
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});
it('starts and stops SD imagery with the conditions editor visibility', () => {
@@ -105,8 +107,8 @@ describe('Settings liveview lifecycle', () => {
selectedTab: 'conditions',
search: '',
};
settings.initialiseLiveview = jest.fn();
settings.stopLiveview = jest.fn();
settings.initialiseLiveview = vi.fn();
settings.stopLiveview = vi.fn();
settings.componentDidUpdate(props, {
...settings.state,
@@ -138,7 +140,7 @@ describe('Settings liveview lifecycle', () => {
search: '',
};
settings.sdLiveviewActive = true;
settings.requestSDLiveviewFrame = jest.fn();
settings.requestSDLiveviewFrame = vi.fn();
settings.componentDidUpdate(
{
@@ -157,7 +159,7 @@ describe('Settings liveview lifecycle', () => {
settings.props = props;
settings.sdLiveviewActive = true;
settings.requestStreamSubscription = {
unsubscribe: jest.fn(),
unsubscribe: vi.fn(),
};
settings.componentWillUnmount();
+28
View File
@@ -0,0 +1,28 @@
// 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,
},
});
+800 -7365
View File
File diff suppressed because it is too large Load Diff