Compare commits

..
Author SHA1 Message Date
Cédric VerstraetenandClaude Opus 5.5 b80fc93f22 machinery: migrate MoQ publishing to moq.dev/moq v0.7
github.com/moq-dev/moq-go was renamed to moq.dev/moq. Its native library
(moq.dev/moq-ffi v0.4.27) ships without LLVM bitcode, so `go build -tags moq`
works on Go 1.26.11+, which rejects the bitcode in moq-go-ffi v0.3.x.

- github.com/moq-dev/moq-go v0.5.7 -> moq.dev/moq v0.7.27
  (moq-go-ffi v0.3.7 -> moq.dev/moq-ffi v0.4.27)
- BroadcastProducer.PublishMedia("avc3", nil) ->
  PublishVideo(moq.VideoFormatAvc3, nil); the rest of the API the agent
  uses is unchanged
- unpin Go: the build image goes back to golang:1.26-trixie and the
  devcontainer drops GOTOOLCHAIN=go1.26.10

Compatibility:
- the derived track name is still "0.avc3"
- the relay accepts the new client (wire protocol moq-lite-05 -> moq-lite-07)
- the catalog keeps the same rendition, codec and container; the
  per-rendition "timeline" moves to a top-level "archive" and a "clock"
  object is added. The Hub viewer's schema (@moq/hang 0.2.16, used by
  @moq/watch 0.2.17) accepts it, and timeline is optional and unused for
  live playback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:48:58 +00:00
18 changed files with 7611 additions and 1031 deletions
-4
View File
@@ -1,9 +1,5 @@
FROM mcr.microsoft.com/devcontainers/go:1.26-trixie
# Same pin as the main Dockerfile: Go 1.26.11 rejects moq-go-ffi v0.3.x's
# archives (LLVM bitcode), which breaks `go build -tags moq`.
ENV GOTOOLCHAIN=go1.26.10
# Install node environment
RUN apt-get update && \
apt-get install -y --no-install-recommends \
+1 -4
View File
@@ -1,8 +1,5 @@
# Pinned to 1.26.10: Go 1.26.11 rejects C archives containing LLVM bitcode
# ("disallowed LTO section .llvmbc"), and moq-go-ffi v0.3.x ships such archives.
# Unpin once the MoQ code moves to moq.dev/moq (moq-ffi v0.4.27+ is clean).
ARG GO_IMAGE=golang:1.26.10-trixie
ARG GO_IMAGE=golang:1.26-trixie
ARG RUNTIME_IMAGE=debian:trixie-slim
ARG VERSION=0.0.0
FROM ${GO_IMAGE} AS build-machinery
+3 -5
View File
@@ -662,9 +662,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 +671,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 +691,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.
+2 -2
View File
@@ -27,7 +27,6 @@ require (
github.com/kerberos-io/joy4 v1.0.64
github.com/kerberos-io/onvif v1.2.3
github.com/minio/minio-go/v6 v6.0.57
github.com/moq-dev/moq-go v0.5.7
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/pion/interceptor v0.1.47
github.com/pion/rtcp v1.2.17
@@ -47,6 +46,7 @@ require (
go.opentelemetry.io/otel/sdk v1.47.0
go.opentelemetry.io/otel/trace v1.47.0
golang.org/x/net v0.62.0
moq.dev/moq v0.7.27
)
require (
@@ -99,7 +99,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/moq-dev/moq-go-ffi v0.3.7 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pion/datachannel v1.6.2 // indirect
@@ -143,4 +142,5 @@ require (
gopkg.in/ini.v1 v1.42.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
moq.dev/moq-ffi v0.4.27 // indirect
)
+4 -4
View File
@@ -857,10 +857,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/moq-dev/moq-go v0.5.7 h1:LfFpgAU8FRMcnU85L5Lb03HzxhYbQ2+BhT/pJQdjy5U=
github.com/moq-dev/moq-go v0.5.7/go.mod h1:5K8zjKKjWe5lzfCtlfxoAfdCr3KX6EBuTOZsz0WBnzw=
github.com/moq-dev/moq-go-ffi v0.3.7 h1:+xwPOzTJHvB0tuTnW6znbvvOgT4yLnN7sMqXXZYh02M=
github.com/moq-dev/moq-go-ffi v0.3.7/go.mod h1:zxpOlUetvaoxWBnbXTdILtLLUytaoVuLvO36lftwWO0=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
@@ -2174,6 +2170,10 @@ modernc.org/tcl v1.15.1/go.mod h1:aEjeGJX2gz1oWKOLDVZ2tnEWLUrIn8H+GFu+akoDhqs=
modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ=
moq.dev/moq v0.7.27 h1:MICXMveLyoFBPj6Tu10oLH8NMhkYaDOa7oe6ay0RQ/c=
moq.dev/moq v0.7.27/go.mod h1:zdCa+pXvmwXg+qTXgVJzO9jX7GbI7R/AFGwWOx1BKg0=
moq.dev/moq-ffi v0.4.27 h1:PCXoyW1QTUN2XnM4pkAIBGpOAFjhm1OmCyPfPHszKPc=
moq.dev/moq-ffi v0.4.27/go.mod h1:a+uEvcnNtY3e9T4/3UqjHBnyYHNLY8rZp+/m7tmL5n8=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
+2 -2
View File
@@ -16,7 +16,7 @@ import (
"github.com/kerberos-io/agent/machinery/src/cloud/livemoq"
"github.com/kerberos-io/agent/machinery/src/models"
"github.com/kerberos-io/agent/machinery/src/packets"
"github.com/moq-dev/moq-go/moq"
"moq.dev/moq"
log "github.com/sirupsen/logrus"
)
@@ -292,7 +292,7 @@ func publishLiveStreamMoQ(ctx context.Context, config liveMoQConfig) error {
}
defer finishBroadcast()
stream, err := broadcast.PublishMedia("avc3", nil)
stream, err := broadcast.PublishVideo(moq.VideoFormatAvc3, nil)
if err != nil {
return fmt.Errorf("create H.264 media stream: %w", err)
}
+2 -2
View File
@@ -12,7 +12,7 @@ import (
"github.com/kerberos-io/agent/machinery/src/cloud/livemoq"
"github.com/kerberos-io/agent/machinery/src/models"
"github.com/moq-dev/moq-go/moq"
"moq.dev/moq"
)
func TestCloseLiveMoQPublisherFinishesBeforeClosingClient(t *testing.T) {
@@ -155,7 +155,7 @@ func TestNativeMoQClientCloseStopsActiveWriter(t *testing.T) {
server.Close()
t.Fatal(err)
}
stream, err := broadcast.PublishMedia("avc3", nil)
stream, err := broadcast.PublishVideo(moq.VideoFormatAvc3, nil)
if err != nil {
client.Close()
server.Close()
+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