Machine-translated – improvements welcome. Suggest an improvement
Getting started¶
Prerequisites¶
- Node.js 26 (LTS) and npm
- Docker (for PostgreSQL 18; or your own PostgreSQL installation)
- optionally poppler-utils for the text layer of PDFs, thumbnails and redacting (text recognition is a package, see Packages with code)
- qpdf and poppler-utils for all tests (Debian/Ubuntu:
sudo apt install qpdf poppler-utils, macOS:brew install qpdf poppler). If one is missing, the tests that need it are skipped locally with a note (#1779); in CI nothing is ever missing. - optionally Python 3 with
mkdocs-materialfor the manuals
Fetching and starting the project¶
git clone https://github.com/motom001/dms.git && cd dms
npm install
docker compose up -d db # only the database
DATABASE_URL=postgres://dms:dms@localhost:5432/dms npm run dev
npm run dev in the root folder starts server (port 3000) and interface together; the interface runs on http://localhost:5173 and forwards /api and /hilfe to the server. Individually it works with npm run dev -w server and npm run dev -w web.
Without Docker for Ablago itself, the server creates its fixed folders (files, geheim, sicherung) under ./data in the project. DMS_DATENWURZEL=/other/folder moves them. At the first start with a working connection, the server takes over DATABASE_URL into the file ./data/geheim/datenbank.json. Afterwards the file applies; the variable is no longer needed. For another database, delete the file or change it under Workbench → Database connection.
On the first visit, the setup assistant guides you through setup. The server prints the setup code in the terminal; it is also in a file under ./data/geheim.
The console (dms in the container) also exists locally: after npm run build -w server, node server/dist/dms.js shows the commands. It talks to the running server.
Everything together as a container: docker compose up --build, then http://localhost:8080.
Two images from one Dockerfile¶
The Dockerfile has two targets (#208):
| Target | Image | Content |
|---|---|---|
dms (default) |
ghcr.io/motom001/dms |
only Ablago; PostgreSQL runs next to it (recommended) |
komplett |
ghcr.io/motom001/dms-komplett |
Ablago and PostgreSQL 18 in one container, started via deploy/komplett/start.sh (tini) |
docker build -t dms . # slim
docker build --target komplett -t dms-komplett . # with PostgreSQL
deploy/komplett-probe.sh dms-komplett # test as in CI: setup, restart, stop, crash, version check
deploy/vorlagen-probe.sh dms # NAS templates with the slim image
Apart from deploy/komplett/start.sh, deploy/ is excluded from the Docker build (.dockerignore). CI builds both images for amd64 and arm64, with a test on every pull request; on main and every week (new Alpine packages) both are published.
Checking¶
| Command | What |
|---|---|
npm test |
all tests (Node test runner): server (server/test/), user interface (web/test/) and shared code including language files (shared/test/) |
npm test -w server, npm test -w web, npm test --prefix shared |
only the tests of one part (#1282); shared is not a workspace of its own, hence --prefix |
npm run test:datei -w server -- test/<file>.test.ts |
a single test file, likewise with -w web or --prefix shared; in the web folder equivalently node --import tsx --import ./test/lader.mjs --test test/<file>.test.ts. The loader web/test/lader.mjs lets tests load interface modules that import CSS (*.css?raw, *.module.css) – without it these tests fail with “Unknown file extension .css”. The server's scripts load server/test/schnell.ts (#1358): fast scrypt parameters so that tests with passwords don't take longer; without it (e.g. node --import tsx --test … directly) the production parameters apply – correct, just slower |
TEST_DATABASE_URL=postgres://… npm test |
additionally the tests against PostgreSQL – every test file creates its own database next to it (see below); the role needs the right to create databases |
npm run typecheck |
TypeScript for shared, server and web |
npm run pruefen |
the quick rules of a pull request in about a minute (#1777): release snippet, baseline lists, formatting of the changed files, order of the smoke test areas – the same script as the job “regeln” in CI |
npm run lint, npm run lint:abh |
check ESLint (errors only) and dependencies – see Style and dependencies; npm run lint:hinweise also shows the complexity hints (#1779) |
npm run rauchtest -- <area> |
one area of the smoke tests locally: test build, fresh Ablago, Playwright – all in one command (#1779); without an area all of them |
npm run abdeckung -w server |
the server tests with test coverage measured (#1781): a table per domain folder, weakest first |
npm run build |
build interface and server as in the image |
CI on GitHub runs all of this plus the smoke tests of the interface, builds both images (dms, dms-komplett) for amd64 and arm64, records the manuals' screenshots and checks the interface at iPhone size.
main is red (#1772): A pull request does not have to be up to date with main before it is merged. So two green pull requests together can turn main red, and every open one inherits the failure. When “Prüfen und Image bauen” fails on main, the workflow “main ist rot” therefore opens an issue (or adds to the open one) and closes it as soon as main is green again. The rule: whoever caused the failure fixes it right away – if that cannot be done quickly, the pull request is reverted and the fix follows as a new pull request.
Tests with PostgreSQL: own database¶
npm test starts all test files at the same time. If they shared the database from TEST_DATABASE_URL, one file could take the tables away from another – red runs without a real fault. So every test file with PostgreSQL creates its own database, using the helper server/test/hilfe-db.ts:
import { eigeneDatenbank } from './hilfe-db';
const db = await eigeneDatenbank('my_file'); // dms_test_my_file_<pid>_<n>, migrated
const leer = await eigeneDatenbank('old', { migrieren: false }); // empty, e.g. for the state before a migration
// db.sql (at most 4 connections), db.url, db.ende()
The database is created next to the one from TEST_DATABASE_URL and dropped with ende(), at the latest after the file's last test. No test writes to the shared database itself; test/eigene-datenbank.test.ts fails CI as soon as a test file empties a schema again. Pools stay small so that many files at once stay below max_connections (default 100). If a file creates a fresh database per test, add { jeTest: true }: then afterEach closes it right after the test – otherwise a file holds four connections per test until it ends (QA round 11/2026: up to 74 in one file, “too many clients”).
Unread file streams (Node 26)¶
If nobody reads a file stream to the end and nobody closes it (destroy()), the file stays open until garbage collection cleans up the FileHandle. Under Node 24 that is only a warning (DEP0137) and a small leak, under Node 26 an error (“A FileHandle object was closed during garbage collection”, #1456). So that this shows up before the switch, npm run test:dateien -w server loads the test files that read real files with server/test/offene-dateien.ts and --expose-gc: the script remembers the place in the code for every open(), runs garbage collection regularly and fails the run as soon as Node has to close a FileHandle that way – with the file and the place it was opened in the log. In CI this runs as its own step in tests (1/3). When it finds something, close the stream where it is left lying, including error paths; don't rebuild oeffneStrom. To check a single file, run node --expose-gc --import tsx --import ./test/schnell.ts --import ./test/offene-dateien.ts --test test/<file>.test.ts in the server folder.
Quarantine for flaky tests¶
A test that is sometimes red and sometimes green without any change goes into server/test/quarantaene.json with an issue and a due date:
{ "name": "Name as in it(…)", "datei": "example.test.ts", "issue": 900, "faellig": "2026-12-06", "grund": "why it is flaky" }
It keeps running but does not fail CI; its result (passed, failed, not found) appears in the run summary. A name can also be a whole section (describe). Once the due date has passed, CI fails – then fix the test and remove the entry, or extend the date deliberately (90 days at most). The TAP log is evaluated with node --import tsx server/test/quarantaene.ts test.log <exit code>. Before quarantining, look for the cause: usually it is a fixed wait where the test should wait for an event.
Tests with a shifted clock¶
Calendar logic likes to break on particular days: the last day of a month, 29 February, the turn of the year, the start or end of daylight saving time. The workflow “Tests mit verstellter Uhr” (#1778, weekly and on demand) therefore runs the server tests at five such moments: faketime sets the system clock forward, the time zone is Europe/Berlin. It is not a required check; a red run is a finding for an issue.
A test that depends on “today” fixes the day itself instead of calculating with the real clock:
import { festeUhr } from './hilfe-uhr.ts';
it('Frist endet am Monatsletzten', (t) => {
const jetzt = festeUhr(t, '2027-04-30T21:45:00Z'); // Date and Date.now() stand at this moment, only in this test
const erwartet = new Date(jetzt.getFullYear(), jetzt.getMonth() + 1, 0).getDate(); // calculated from jetzt
assert.equal(fristTag(jetzt), erwartet);
});
festeUhr (server/test/hilfe-uhr.ts) only fixes Date (mock.timers of the Node test runner); timers keep running normally. In the workflow it gets the same moment as the system clock through TEST_JETZT – even when the test names a different one. So calculate the expectation from the return value of festeUhr instead of writing it down as a fixed value: only then does the workflow check the test on every key date instead of turning red on four of them without a fault in the code. PostgreSQL runs with the real clock in the workflow; now() and column defaults therefore return the real date. If a key date is red, first check whether the test compares a database timestamp with “today” from JavaScript before turning it into an issue.
Test coverage¶
npm run abdeckung -w server runs the server tests with coverage measured (--experimental-test-coverage), writes server/lcov.info and shows a table per domain folder under server/src/, weakest first (server/werkzeuge/abdeckung.mjs). The workflow “Testabdeckung” (#1781) does this weekly and on demand; the table is in the run summary. There is deliberately no threshold: the report shows where tests are missing and turns no run red. It is not measured in every pull request because the tests take about 70 % longer with it.
Smoke tests of the interface¶
The smoke tests under web/rauchtest/ walk through the most important paths once in the browser (Chromium with Playwright): setup in the wizard, signing in and the start page, “Take over document” (opening new post, choosing a folder type, taking values from the document; at the end splitting off a following document and turning post into a new or existing folder and just marking it as done), “+ New”, changing and saving a folder, search, admin mode with Workbench → Packages, editing a folder type, the tour and “Discover Ablago” for a new account, signing out – and three paths at phone size. Each test checks the visible result and that there were no errors in the console, no failed request and no response of 400 or above (apart from expected ones). They run in the rauchtests job after the build, one after another against one Ablago, and take a good quarter of an hour altogether (in November 2026 just under 200 tests). When working on one place, one area on its own is therefore usually worth it.
CI layout (#1056): The server tests run in three parallel jobs tests (1/3) to tests (3/3) (npm run test:teil -w server with TEST_TEIL=1/3 etc., node --test --test-shard), each with its own PostgreSQL. Alongside, rauchtests checks the release note, vulnerable dependencies, types, the build and the user interface. The small collecting job pruefen only turns green when all parts are green – it is the required check in the ruleset, and version and image wait for it. The interface tests (npm test -w web) and the tests of shared code (npm test --prefix shared) run as separate steps in rauchtests (#1282). Locally npm test still runs all tests. In image-probe the trial installations (templates, dms-komplett, update from the previous state) run at the same time, each with its own log as a group in the run; the browsers for smoke tests and handbook screenshots come from the cache per Playwright version, system libraries only if a browser would not start otherwise (#1059).
Locally they need a freshly built Ablago without a database connection, its own data root and a PostgreSQL in which the role may create databases – the first test goes through the wizard and creates the database itself:
VITE_MUSTER=1 npm run build # test build with the sample page /muster
DMS_DATENWURZEL=/tmp/rauchtest DMS_PROZESSE=1 PORT=3000 node server/dist/index.js &
cd web/rauchtest && npm ci && npx playwright install chromium && cd ../..
DMS_URL=http://localhost:3000 DMS_DATENWURZEL=/tmp/rauchtest DB_HOST=localhost DB_PASSWORT=dms node web/rauchtest/rauchtest.mjs
Playwright is pinned in web/rauchtest/package.json with its own lockfile (#1272) – run npm ci in that folder, not in the root folder. It is not a workspace, so it ends up neither in the app's dependency tree nor in the image. The tools for the manual screenshots (docs/handbuch/screenshots/) use the same installation via web/rauchtest/playwright.mjs. Dependabot brings new versions. If Chromium does not start on Linux because system libraries are missing, npx playwright install-deps chromium (in the folder web/rauchtest, with administrator rights) installs them – CI does the same. Without VITE_MUSTER=1 the sample page is missing, and the tests that open it (in bausteine-und-knoepfe.mjs) fail. DMS_PROZESSE=1 keeps Ablago at one process, as in CI.
For a second run, stop Ablago and delete the data root and the database dms_rauchtest (or change DB_NAME). If a test fails, a picture of the page is in rauchtest-fehler/ (in CI as the artefact rauchtest-fehler).
One area on its own (#1234): web/rauchtest/rauchtest.mjs only starts the setup and then the areas under web/rauchtest/bereiche/ in a fixed order. Every area includes the setup first itself (wizard and the data from vorbereiten()) and so also runs on its own against a freshly started Ablago, e.g. node web/rauchtest/bereiche/werkbank-post.mjs with the same variables as above – that takes seconds to a few minutes instead of a quarter of an hour. In the full run all areas share one Ablago: a test therefore does not rely on what another area created or changed; data it needs is created by vorbereiten() or by the test itself. If an area only fails in the full run, it depends on the state of an earlier one – then fix exactly that. For another area afterwards, restart Ablago with an empty data root and without the database dms_rauchtest. Do not use node --test on the folder: it starts the files in parallel against the same Ablago.
A new area (#1775): a new file under web/rauchtest/bereiche/ whose first line is // Reihenfolge im Gesamtlauf (#1775): <number>. rauchtest.mjs finds the areas itself and starts them by this number, smaller first; there is no shared list for two pull requests to collide on. The numbers go in steps of ten; a new area takes a free number at the place where it belongs in the run. npm run pruefen reports a missing or duplicate number. Locally npm run rauchtest -- <area> starts one area with everything it needs (test build, fresh Ablago with its own database, Playwright); --ohne-bau skips the build.
First cause and follow-on failures (#1773): Because all areas share one Ablago, one failure often drags others along. From the second red test on, the message therefore starts with “Möglicher Folgefehler (erste Ursache: …)”, and at the end of the run come “Erste Ursache” and the list of tests that turned red afterwards. In CI the first cause appears as an error annotation at the top of the run, the others as a warning. Fix the first cause first; the follow-on failures usually disappear with it.
With two processes (QA round 11/2026): web/rauchtest/zwei-prozesse.mjs is a quick subset (setup, start and search, workbench, post, mentions; about one minute) for an Ablago with DMS_PROZESSE=2. It first checks that two processes really run; after that every request goes to one of them in turn, and what one writes the other must see. In CI it runs in its own job rauchtests-zwei-prozesse in parallel to the full run, which stays at DMS_PROZESSE=1. Locally: start a fresh Ablago with DMS_PROZESSE=2, then node web/rauchtest/zwei-prozesse.mjs with the same variables as above.
When to add a smoke test: a new flow in the interface – a new page, a new path to a result – gets its smoke test in the same PR (in the file of its area under web/rauchtest/bereiche/); so does a path that easily breaks unnoticed during a rework. There is no coverage target; the server tests check the details. A test looks like this:
rauchtest('Favorit merken', { als: LENA }, async (s) => {
await s.goto(BASIS + '/ablage/start');
// … click and fill in like a person would: getByRole, getByLabel, visible texts
await s.getByRole('button', { name: 'Aus den Favoriten entfernen' }).waitFor(); // visible result
});
The tests search for the German texts of the interface. { handy: true } opens the test at phone size, erwartet: [{ status: 404, pfad: /…/ }] allows responses that belong to this path. Always wait for an element or event, never a fixed time – otherwise the test becomes flaky. Data that several tests need is created by vorbereiten() in web/rauchtest/einrichtung.mjs through the API.
axe and touch targets only on a settled page (#1266): These checks measure colours and positions – anything still fading or shifting is measured wrongly. Runs used to fail without a real fault (contrast 2.4:1 of a button in the middle of the colour transition after switching to dark, a touch target “moved by 1 px” because the system status was still loading). Therefore:
axePruefenandtippflaechenPruefen(web/rauchtest/muster.mjs) wait themselves withseiteRuhig: mouse moved away (hover changes colours), no recent open request (requests open for 2 s already do not count: long-lived connections and ends Playwright never reports), fonts loaded, no finite animation or transition left (document.getAnimations()), layout unchanged over two animation frames. If the page still shifts while a touch target is measured, the element is measured again once the page has settled.- Always switch light/dark with
schemaWechseln(s, 'dark')fromhilfen.mjs, neveremulateMediadirectly, no fixed waiting time (waitForTimeout), no reload and nomouse.move(0, 0)just for axe. seiteRuhigonly knows about open requests for contexts watched byanfragenZaehlen(kontext)–rauchtest()andmusterAufnehmendo this themselves; your own contexts (e.g. in screenshot scripts) call it afternewContext.- A spinner (endless animation) does not hold up the wait; if a page does not settle within 3 s, the test log gets a line
# seiteRuhig: … nicht ruhig …naming the open condition, and it is measured anyway.
Manuals¶
pip install -r docs/handbuch/requirements.txt # the same versions as CI and image
mkdocs serve -f docs/handbuch/benutzer/mkdocs.yml
mkdocs serve -f docs/handbuch/benutzer/mkdocs.en.yml # the English version (#730)
The images (bilder/*.png) are created in CI with docs/handbuch/screenshots/aufnehmen.mjs and aren't in the repository. They are taken in a wide window as on a large screen (2048 × 1024, 125 % scaling, images 2560 × 1280); werkzeuge/bild_gross_hook.py shows them at text width in the manual and opens them full size on click. The images for the package catalogue come from pakete-aufnehmen.mjs in a separate part: it installs the template packages from the published catalogue with their examples and takes a list and an example folder per package, in a wide window (2048 × 1024, 125 % scaling, images 2560 × 1280) as on a large screen; they end up under benutzer/…/bilder/pakete/ with an index.json that the catalogue website reads. They are missing locally; you can ignore the warnings about them. English screenshots go to bilder/en/ (DMS_SPRACHE=en); until they exist, English pages show the German ones with a notice.
Offline help in the image¶
In the section hilfe, the Dockerfile builds all four manuals and the start page with docs/handbuch/werkzeuge/offline.py and puts them into web/dist/hilfe; the server delivers them under /hilfe/. For this, every manual has mkdocs.offline.yml (inherits from mkdocs.yml) with the hook werkzeuge/offline_hook.py:
- Screenshots (
bilder/…) become a notice with a link to the same page online (/dms/<handbuch>/vX.Y/…). - Links
https://help.ablago.app/<handbuch>/aktuell/…point to/hilfe/<handbuch>/…; templates stay online,api/openapi.jsonpoints to your own installation. - No version selection, no fonts from the internet, no source maps.
- English (#730):
mkdocs.en.offline.ymlbuilds the English version fromdocs-en/into/hilfe/<handbuch>/en/, with English search. Missing English pages and images come from the German folder viawerkzeuge/sprache_hook.py.
Locally: python3 docs/handbuch/werkzeuge/offline.py /tmp/hilfe. At the end the script checks that every link to /hilfe/… hits a page; CI additionally checks all targets of the context help. Without built manuals (npm run dev), the server redirects /hilfe/… to the online version of the release.