0
0
Fork 0
Codesys-MCP-SP21-plus/tests
Karstein Phobic Nyvold Kvistad fc49e7ff8b fix(add_library): dedup pre-check + default to add_placeholder, opt-in direct/force
Empirical failure: add_library('Standard') on a project that already had Standard, * (System) silently created a SECOND direct Standard reference, pulling in unresolved transitive deps (e.g. yellow-warning IoStandard 3.1.3.1).
Root cause: script always called add_library() without checking lm.references first; never called add_placeholder() so the result was a direct (non-* (System)) reference.
Fix: (1) walk lm.references for an existing entry by bare name and no-op with a confirmation message unless force=true; (2) default to add_placeholder() so transitive deps resolve at compile (matches the modern '<Name>, * (System)' convention); (3) keep add_library() reachable via direct=true; (4) on miss, dump dir(lm) so unknown SPs surface the actual API.
Docs: https://content.helpme-codesys.com/en/ScriptingEngine/ScriptLibManObject.html

Mildly breaking for callers: previous behaviour was always direct
add_library(); pass direct=true to restore. The dedup default also flips
'add second copy' to 'no-op' -- pass force=true to restore.

Test updated: tests/integration/e2e.test.ts now passes USE_DIRECT='0' and
FORCE_DUP='0' alongside LIBRARY_NAME, asserts add_placeholder + dedup
strings appear in the rendered script.

### Manual smoke test
1. mcp__codesys__add_library libraryName=Standard against a project that
   already has Standard listed: expect SCRIPT_SUCCESS with body 'Library
   Already Present: Standard' and NO second entry in the Library Manager.
2. mcp__codesys__add_library libraryName=Util on a project without Util:
   expect a new entry rendered as 'Util, * (System)' (placeholder, not
   direct).
3. mcp__codesys__add_library libraryName=Standard direct=true: expect a
   direct (non-* (System)) reference even on dedup hit if also force=true.
4. mcp__codesys__list_project_libraries should reflect each result.
2026-04-28 20:54:34 +02:00
..
integration fix(add_library): dedup pre-check + default to add_placeholder, opt-in direct/force 2026-04-28 20:54:34 +02:00
unit feat(open_project): pre-flight profile-mismatch check using offline .project inspection 2026-04-27 22:32:53 +02:00
bench-results-v5.json test(bench): v5 sweep -- fix set_pou_code params, all 10 cases pass 2026-04-26 19:30:48 +02:00
bench-results.json fix: 4 broken-tool fixes (compile json long, connect_to_device LoginMode, 2026-04-26 16:53:25 +02:00
bench.mjs test(bench): v5 sweep -- fix set_pou_code params, all 10 cases pass 2026-04-26 19:30:48 +02:00
mock_watcher.py Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00
test-fixes.mjs fix(create_folder): try project.create_folder(name, SV_POU) first; drop ScriptManager cache 2026-04-26 17:16:44 +02:00
TEST_OVERVIEW.md rename: Codesys-MCP-SP22+ -> Codesys-MCP-SP21+ + multi-install README + missing tools 2026-04-26 22:02:46 +02:00