Files
nuwiki/development/tests/test-calendar-vim-optout.vim
T
gffranco 87ba4c1764
CI / cargo fmt --check (push) Successful in 26s
CI / cargo clippy (push) Successful in 27s
CI / cargo test (push) Successful in 31s
CI / editor keymaps (push) Successful in 1m30s
test(calendar): add Vim + Neovim integration harnesses
Add headless harnesses covering the calendar-vim integration, wired into
CI alongside the existing keymap/config suites:

- test-calendar-vim.sh/.vim (+ -optout.vim): pure-VimL diary hooks
  (calendar_sign markers, calendar_action path resolution from wiki root,
  calendar window close), plugin/nuwiki.vim hook auto-wiring that
  overrides calendar-vim's defaults, and opt-out via g:nuwiki_use_calendar
  and g:nuwiki_no_calendar. Uses a stub calendar-vim on the runtimepath.
- test-calendar.sh/.lua: Neovim setup() wiring + window-close under the
  real window API, and opt-out via use_calendar = false.

Fixes surfaced by the suite:
- diary.vim: new diary entries set filetype 'vimwiki' (was the raw
  extension, e.g. 'wiki'); the stray FileType autocmd also blocked the
  calendar window from closing.
- init.lua: drop the redundant Neovim FileType autocmd (plugin/nuwiki.vim
  already wires both editors) and translate use_calendar=false into
  g:nuwiki_no_calendar so the opt-out actually disables wiring.
2026-05-31 21:45:50 -03:00

41 lines
1.5 KiB
VimL

" development/tests/test-calendar-vim-optout.vim — driven by test-calendar-vim.sh.
"
" Asserts that the calendar-vim integration stays OFF when the user opts out
" (g:nuwiki_use_calendar = 0 or g:nuwiki_no_calendar = 1). In that case the
" FileType autocmd must leave calendar-vim's own defaults untouched, so the
" hooks still point at 'calendar#diary' / 'calendar#sign' (set by the stub).
let s:results = []
let s:pass = 0
let s:fail = 0
let s:out = $NUWIKI_CALENDAR_RESULTS
function! s:record(ok, name, detail) abort
let l:line = (a:ok ? 'PASS' : 'FAIL') . ' ' . a:name
if a:detail !=# ''
let l:line .= ' — ' . a:detail
endif
call add(s:results, l:line)
if a:ok
let s:pass += 1
else
let s:fail += 1
endif
endfunction
" The buffer is already a loaded vimwiki file (FileType has fired). nuwiki must
" NOT have rewired the hooks — they should still be calendar-vim's defaults.
call s:record(&filetype ==# 'vimwiki', 'ftplugin.attached',
\ &filetype ==# 'vimwiki' ? '' : 'filetype=' . &filetype)
call s:record(get(g:, 'calendar_action', '') !=# 'vimwiki#diary#calendar_action',
\ 'optout.action_not_wired',
\ 'g:calendar_action=' . get(g:, 'calendar_action', ''))
call s:record(get(g:, 'calendar_sign', '') !=# 'vimwiki#diary#calendar_sign',
\ 'optout.sign_not_wired',
\ 'g:calendar_sign=' . get(g:, 'calendar_sign', ''))
call add(s:results, '')
call add(s:results, printf('SUMMARY: %d passed, %d failed', s:pass, s:fail))
call writefile(s:results, s:out)
execute (s:fail == 0 ? 'qall!' : 'cquit!')