0
0
Fork 0
Codesys-MCP-SP21-plus/tests/integration
phobicdotno f0a44f877e
test(e2e): regression coverage for the four 2026-04-29 fixes (#14)
* feat(live-values): --live-values-interval <ms> CLI flag

Replaces the hardcoded 500ms poll with a configurable interval.
Clamped to [100, 60000] -- below 100 the read_variable IPC round-
trip-per-var dominates and the pump can't keep up; above 60000 a
session shorter than the interval would never see any update.

ServerConfig.liveValuesIntervalMs?: number plumbs through bin.ts
(parseInt + clamp) into the LiveValuesPump constructor and the
'Live-values pump started (<ms>ms)' log line.

Default unchanged at 500ms, so existing --live-values invocations
behave identically.

* test(e2e): regression coverage for the four 2026-04-29 fixes

Five new template-prep assertions:

1. set_symbol_access mutation lookup goes to get_all_signatures FIRST
   (PR #7). The configured-view probe is tracking-only and must come
   AFTER both compile=False/True all-signatures lookups -- if the order
   ever flips, the mutation hits the read-only view and CODESYS rejects
   the assignment with 'can only be changed in the list of all
   signatures/data types'.

2. set_symbol_access int->SymbolAccess coerce (PR #9). The fallback
   block must use type(maximal_access) and call enum_cls(int_val)
   BEFORE 'var.configured_access = requested_access'. Without it,
   non-zero ints are rejected with 'must be zero'.

3. set_signature_access_bulk same coerce, lazily on the first variable
   in the for-loop (PR #9). Verifies loop -> coerce -> assign order.

4. create_project without deviceName preserves the no-swap path
   (backwards compat for PR #8). Empty DEVICE_NAME substitutes; the
   if-DEVICE_NAME branch is in the template but the runtime gates it.

5. create_project deviceName swap (PRs #8/#10/#11/#12 combined).
   Verifies:
     - PromptHandling.NONE setter is rendered (script_prompt_handling
       is read-only -- earlier code silently failed).
     - device_repository accessed via script_engine, not as a builtin.
     - update() is the first-attempt mutation, remove+add only fires
       'if not update_ok'.
     - project.close() + precompilecache delete render after swap.

Vitest: 27/27 in tests/integration/e2e.test.ts (was 22).

---------

Co-authored-by: Karstein Phobic Nyvold Kvistad <karstein.kvistad@maritimerobotics.com>
2026-04-29 13:44:02 +02:00
..
e2e.test.ts test(e2e): regression coverage for the four 2026-04-29 fixes (#14) 2026-04-29 13:44:02 +02:00
README.md Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00

Manual CODESYS Integration Tests

These tests require a real CODESYS installation and cannot run in CI.

Prerequisites

  • CODESYS 3.5 SP19 or SP21 installed
  • No other CODESYS instances running
  • Node.js 18+

Steps

1. Build the package

npm run build

2. Test persistent mode

node dist/bin.js \
  --codesys-path "C:\path\to\CODESYS.exe" \
  --codesys-profile "CODESYS V3.5 SP21 Patch 3" \
  --mode persistent \
  --verbose

Verify:

  • CODESYS UI opens
  • Console shows "CODESYS watcher is ready"
  • The MCP server accepts connections

3. Test headless fallback

node dist/bin.js \
  --codesys-path "C:\path\to\CODESYS.exe" \
  --codesys-profile "CODESYS V3.5 SP21 Patch 3" \
  --mode headless

4. Test --detect flag

node dist/bin.js --detect

Verify: Lists installed CODESYS versions.

5. Ctrl+C shutdown

  • Press Ctrl+C during persistent mode
  • Verify CODESYS shuts down cleanly