From d0feff798d3126feb142824deed9d8676c448d81 Mon Sep 17 00:00:00 2001
From: sb-o <12798735+sb-o@users.noreply.github.com>
Date: Tue, 19 Sep 2023 21:15:31 +0100
Subject: [PATCH 1/2] Implements test for when buffer is longer than max

---
 spec/options/buffer_max_size_spec.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/spec/options/buffer_max_size_spec.rb b/spec/options/buffer_max_size_spec.rb
index 29ca8bc4..d380b0c4 100644
--- a/spec/options/buffer_max_size_spec.rb
+++ b/spec/options/buffer_max_size_spec.rb
@@ -25,6 +25,10 @@
       wait_for { session.content }.to eq(long_command)
     end
 
-    it 'is not provided when the buffer is longer than the specified length'
+    it 'is not provided when the buffer is longer than the specified length' do
+      session.send_string(long_command[0...(buffer_max_size + 1)])
+      sleep 1
+      expect(session.content).to eq(long_command[0...(buffer_max_size + 1)])
+    end
   end
 end

From 52723c1ddebffac20087518bb983a00db105b3bb Mon Sep 17 00:00:00 2001
From: sb-o <12798735+sb-o@users.noreply.github.com>
Date: Tue, 19 Sep 2023 21:19:23 +0100
Subject: [PATCH 2/2] Implements test where KEYS_QUEUED_COUNT supported

---
 spec/integrations/zle_input_stack_spec.rb | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/spec/integrations/zle_input_stack_spec.rb b/spec/integrations/zle_input_stack_spec.rb
index 12cfbc7b..e359c6f1 100644
--- a/spec/integrations/zle_input_stack_spec.rb
+++ b/spec/integrations/zle_input_stack_spec.rb
@@ -9,10 +9,17 @@
 
   let(:options) { ['unset ZSH_AUTOSUGGEST_USE_ASYNC', 'ZSH_AUTOSUGGEST_STRATEGY=test'] }
 
-  # TODO: This is only possible with the $KEYS_QUEUED_COUNT widget parameter, coming soon...
-  xit 'does not fetch a suggestion for every inserted character' do
+  # This is only possible with the $KEYS_QUEUED_COUNT widget parameter
+  it 'does not fetch a suggestion for every inserted character' do
     session.send_keys('C-b')
-    wait_for { session.content }.to eq('echo hello')
+
+    # Check if zsh >= 5.4
+    version_arr = ENV['TEST_ZSH_BIN'].split('zsh-')[1].split('.')
+    if version_arr[0].to_i >= 6 || (version_arr[0].to_i == 5 && version_arr[1].to_i >= 4)
+      wait_for { session.content }.to eq('echo hello')
+    else
+      skip "depends on KEYS_QUEUED_COUNT which requires zsh 5.4 or above"
+    end
   end
 
   it 'shows a suggestion when the widget completes' do