test(config): verify Vim/Neovim config payload parity
CI / cargo fmt --check (push) Successful in 15s
CI / cargo clippy (push) Successful in 27s
CI / cargo test (push) Successful in 30s
CI / editor keymaps (push) Successful in 1m24s

Expose the init_options payload builders publicly in both clients
(M.init_options/M.server_settings in Lua, nuwiki#lsp#settings() in Vim) so
they can be inspected. Add editor harnesses that dump each client's
server-bound config as deterministic key=value lines and diff against a
shared golden file: nvim == golden and vim == golden together prove the two
clients send identical config. Add a server-side test asserting the Vim flat
shape and the Neovim {nuwiki:{...}} wrapper desugar to the same WikiConfig.
Wire both harnesses into CI.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 19:24:20 -03:00
parent 47af0d6c1e
commit b922f0d612
9 changed files with 319 additions and 6 deletions
@@ -319,6 +319,54 @@ fn raw_wiki_parses_every_new_key() {
assert!(w.auto_toc);
}
#[test]
fn vim_flat_and_neovim_wrapped_payloads_desugar_identically() {
// Parity guard for the two client shapes:
// * Vim (`autoload/nuwiki/lsp.vim`) → flat init_options dict.
// * Neovim (`lua/nuwiki/lsp.lua`) → `{ nuwiki = { … } }` for
// `workspace/didChangeConfiguration` (server_settings()).
// Both must produce the same wikis; otherwise switching editors would
// silently change how the server resolves links/diary/HTML paths.
let inner = json!({
"wiki_root": "/tmp/base",
"file_extension": ".md",
"syntax": "vimwiki",
"log_level": "debug",
"wikis": [
{
"name": "personal",
"root": "/tmp/personal",
"file_extension": ".wiki",
"index": "home",
"diary_rel_path": "journal",
},
{ "name": "work", "root": "/tmp/work" },
],
});
let flat = config_from_json(inner.clone());
let wrapped = config_from_json(json!({ "nuwiki": inner }));
assert_eq!(flat.wikis.len(), wrapped.wikis.len());
for (a, b) in flat.wikis.iter().zip(wrapped.wikis.iter()) {
assert_eq!(a.name, b.name);
assert_eq!(a.root, b.root);
assert_eq!(a.file_extension, b.file_extension);
assert_eq!(a.syntax, b.syntax);
assert_eq!(a.index, b.index);
assert_eq!(a.diary_rel_path, b.diary_rel_path);
}
// And the desugared list matches the per-wiki values both clients send.
assert_eq!(flat.wikis[0].name, "personal");
assert_eq!(flat.wikis[0].root, PathBuf::from("/tmp/personal"));
assert_eq!(flat.wikis[0].file_extension, ".wiki");
assert_eq!(flat.wikis[0].index, "home");
assert_eq!(flat.wikis[0].diary_rel_path, "journal");
assert_eq!(flat.wikis[1].name, "work");
assert_eq!(flat.wikis[1].root, PathBuf::from("/tmp/work"));
}
#[test]
fn legacy_single_wiki_shape_picks_up_defaults() {
let cfg = config_from_json(serde_json::json!({