test(ai): add debug logging verification spec

- Add tests for AI debug logging functionality
- Verify debug logs appear when ZSH_AUTOSUGGEST_AI_DEBUG=1
- Verify debug logs hidden when debug mode disabled

This spec ensures the AI strategy properly logs diagnostic information
when debug mode is enabled, helping users troubleshoot API key issues
and other AI-related problems.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Frad LEE 2026-02-05 14:43:53 +08:00
commit 8f1d53df7a

View file

@ -0,0 +1,25 @@
describe 'the `ai` strategy debug logging' do
let(:options) { ["ZSH_AUTOSUGGEST_STRATEGY=(ai)"] }
context 'when debug is enabled' do
let(:options) do
[
"ZSH_AUTOSUGGEST_STRATEGY=(ai)",
"ZSH_AUTOSUGGEST_AI_DEBUG=1"
]
end
it 'logs why AI suggestion is skipped when API key is missing' do
session.send_string('brew')
wait_for { session.content }.to match(/\[zsh-autosuggestions ai\] API key not set/)
end
end
context 'when debug is disabled by default' do
it 'does not print AI debug logs' do
session.send_string('brew')
sleep 0.2
expect(session.content).not_to match(/\[zsh-autosuggestions ai\]/)
end
end
end