@@ -150,6 +150,47 @@ func TestEditorAutocompletionWithEmptyInput(t *testing.T) {
assert.Equal(t, "", testEditor.currentQuery)
}
+func TestEditorAutoCompletion_WIP(t *testing.T) {
+ testEditor := newEditor(&app.App{}, mockDirLister([]string{"file1.txt", "file2.txt"}))
+ require.NotNil(t, testEditor)
+
+ // open the completions menu by simulating a '/' key press
+ testEditor.Focus()
+ keyPressMsg := tea.KeyPressMsg{
+ Text: "/",
+ }
+
+ m, msg := simulateUpdate(testEditor, keyPressMsg)
+ testEditor = m.(*editorCmp)
+
+ var openCompletionsMsg *completions.OpenCompletionsMsg
+ if batchMsg, ok := msg.(tea.BatchMsg); ok {
+ // Use our enhanced helper to check for OpenCompletionsMsg with specific completions
+ var found bool
+ openCompletionsMsg, found = assertBatchContainsOpenCompletionsMsg(t, batchMsg, []string{"file1.txt", "file2.txt"})
+ assert.True(t, found, "Expected to find OpenCompletionsMsg with specific completions in batched messages")
+ } else {
+ t.Fatal("Expected BatchMsg from cmds()")
+ }
+
+ assert.NotNil(t, openCompletionsMsg)
+}
+
+type noopEvent struct{}
+
+type updater interface {
+ Update(msg tea.Msg) (tea.Model, tea.Cmd)
+}
+
+func simulateUpdate(up updater, msg tea.Msg) (updater, tea.Msg) {
+ up, cmd := up.Update(msg)
+ if cmd != nil {
+ return up, cmd()
+ }
+ return up, noopEvent{}
+}
+
+/*
func TestEditorAutocompletion_StartFilteringOpens(t *testing.T) {
testEditor := newEditor(&app.App{}, mockDirLister([]string{"file1.txt", "file2.txt"}))
require.NotNil(t, testEditor)
@@ -176,7 +217,7 @@ func TestEditorAutocompletion_StartFilteringOpens(t *testing.T) {
assert.NotNil(t, openCompletionsMsg)
m, cmds = testEditor.Update(openCompletionsMsg)
- if
+
msg = cmds()
testEditor = m.(*editorCmp)
@@ -232,6 +273,7 @@ func TestEditorAutocompletion_StartFilteringOpens(t *testing.T) {
// Verify the editor still has completions open
assert.True(t, testEditor.isCompletionsOpen)
}
+*/
func TestEditorAutocompletion_SelectionOfNormalPathAddsToTextAreaClosesCompletion(t *testing.T) {
testEditor := newEditor(&app.App{}, mockDirLister([]string{"example_test.go", "file1.txt", "file2.txt"}))