0
0
Fork 0
Codesys-MCP-SP21-plus/tests/unit
Karstein Phobic Nyvold Kvistad 614a8458f0 feat(live-values): depth-1 sub-property descent
Extends the pump beyond top-level vars: when a var's declared type
resolves to another mirror .st file, we descend one level and read
each of that type's vars as <var>.<member>.

Parser: parseVarDecls(text) now returns name + declared type per
decl. ARRAY/POINTER/REFERENCE wrappers stripped to the inner type.
parseVarNames is kept as a thin wrapper for the existing callers.

Pump: new resolveTypeMirror(typeName, deviceRoot) dep. Pump itself
doesn't know how to find a type's source -- the caller plugs in a
strategy. server.ts wires a recursive walk under the device root
looking for '<typeName>.st'; the mirror layout guarantees stable
filenames for POU/FB/DUT (every code-bearing object).

Pump's deviceRootFor(absPath) parses the abs path back to the
device root by locating the '/mcp-mirror/<device>/' segment. If
that fails we fall back to the file's parent dir (still works for
same-folder type lookups, just won't find types in sibling folders).

Constructor now accepts partial deps and fills in safe defaults
(no-op resolveTypeMirror -> never descend, matching v0.3
top-level-only behaviour). Existing tests don't need to change.

407/407 tests pass; new coverage:
  - parseVarDecls: name+type extraction, ARRAY/POINTER/REFERENCE
    stripping, AT %loc prefix, missing-type pathological case
  - LiveValuesPump.tick: descends when resolver returns content;
    doesn't descend when resolver returns null (primitives)
2026-04-29 13:52:35 +02:00
..
approve-gate.test.ts feat(approve-gate): wire 9 modifying tools through phobiCS-tui 2026-04-29 08:22:09 +02:00
clamp-interval.test.ts test(e2e): regression coverage for the four 2026-04-29 fixes (#14) 2026-04-29 13:44:02 +02:00
detect.test.ts feat(cli): --print-config --for-project <path> picks the install that opens the project 2026-04-27 22:27:31 +02:00
get-user-selection.test.ts feat(mcp): register get_user_selection tool 2026-04-28 22:28:09 +02:00
inspect.test.ts feat(cli): --inspect <project> reads CODESYS profile + mandatory libs offline (no CODESYS needed) 2026-04-27 21:47:31 +02:00
ipc.test.ts Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00
launcher.test.ts fix(launcher): only refuse double-spawn of the SAME --codesys-path 2026-04-27 20:57:59 +02:00
live-values-pump.test.ts feat(live-values): depth-1 sub-property descent 2026-04-29 13:52:35 +02:00
live-values-write.test.ts feat(live-values): atomic writer for tui-live-values.json 2026-04-29 09:51:17 +02:00
mirror-paths.test.ts fix(mirror): per-project mirror dir name when multiple .project files share a parent 2026-04-27 22:22:09 +02:00
open-project-preflight.test.ts feat(open_project): pre-flight profile-mismatch check using offline .project inspection 2026-04-27 22:32:53 +02:00
script-manager.test.ts fix(create_folder): try project.create_folder(name, SV_POU) first; drop ScriptManager cache 2026-04-26 17:16:44 +02:00
ssh-version.test.ts feat(ssh): read_running_version_ssh -- read PLC project version over SSH, no CODESYS needed 2026-04-27 22:13:29 +02:00
state-read.test.ts feat(state): add CJS reader for phobiCS-tui state file 2026-04-28 22:26:15 +02:00
var-block-parse.test.ts feat(live-values): depth-1 sub-property descent 2026-04-29 13:52:35 +02:00