fix: include attachment in test

drew created

Change summary

tui/composer_test.go | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)

Detailed changes

tui/composer_test.go 🔗

@@ -19,31 +19,38 @@ func TestComposerUpdate(t *testing.T) {
 		}
 
 		// Simulate pressing Tab to move to the 'Subject' field.
-		model, _ := composer.Update(tea.KeyMsg{Type: tea.KeyTab}) // model is tea.Model
-		composer = model.(*Composer)                             // Cast to *Composer
+		model, _ := composer.Update(tea.KeyMsg{Type: tea.KeyTab})
+		composer = model.(*Composer)
 		if composer.focusIndex != 1 {
-			t.Errorf("After one Tab, focusIndex should be 1, got %d", composer.focusIndex)
+			t.Errorf("After one Tab, focusIndex should be 1 (Subject), got %d", composer.focusIndex)
 		}
 
 		// Simulate pressing Tab again to move to the 'Body' field.
-		model, _ = composer.Update(tea.KeyMsg{Type: tea.KeyTab}) // model is tea.Model
-		composer = model.(*Composer)                             // Cast to *Composer
+		model, _ = composer.Update(tea.KeyMsg{Type: tea.KeyTab})
+		composer = model.(*Composer)
 		if composer.focusIndex != 2 {
-			t.Errorf("After two Tabs, focusIndex should be 2, got %d", composer.focusIndex)
+			t.Errorf("After two Tabs, focusIndex should be 2 (Body), got %d", composer.focusIndex)
 		}
 
-		// Simulate pressing Tab again to move to the 'Send' button.
-		model, _ = composer.Update(tea.KeyMsg{Type: tea.KeyTab}) // model is tea.Model
-		composer = model.(*Composer)                             // Cast to *Composer
+		// Simulate pressing Tab again to move to the 'Attachment' field.
+		model, _ = composer.Update(tea.KeyMsg{Type: tea.KeyTab})
+		composer = model.(*Composer)
 		if composer.focusIndex != 3 {
-			t.Errorf("After three Tabs, focusIndex should be 3 (Send), got %d", composer.focusIndex)
+			t.Errorf("After three Tabs, focusIndex should be 3 (Attachment), got %d", composer.focusIndex)
+		}
+
+		// Simulate pressing Tab again to move to the 'Send' button.
+		model, _ = composer.Update(tea.KeyMsg{Type: tea.KeyTab})
+		composer = model.(*Composer)
+		if composer.focusIndex != 4 {
+			t.Errorf("After four Tabs, focusIndex should be 4 (Send), got %d", composer.focusIndex)
 		}
 
 		// Simulate one more Tab to wrap around to the 'To' field.
-		model, _ = composer.Update(tea.KeyMsg{Type: tea.KeyTab}) // model is tea.Model
-		composer = model.(*Composer)                             // Cast to *Composer
+		model, _ = composer.Update(tea.KeyMsg{Type: tea.KeyTab})
+		composer = model.(*Composer)
 		if composer.focusIndex != 0 {
-			t.Errorf("After four Tabs, focusIndex should wrap to 0, got %d", composer.focusIndex)
+			t.Errorf("After five Tabs, focusIndex should wrap to 0, got %d", composer.focusIndex)
 		}
 	})
 
@@ -53,7 +60,7 @@ func TestComposerUpdate(t *testing.T) {
 		composer.subjectInput.SetValue("Test Subject")
 		composer.bodyInput.SetValue("This is the body.")
 		// Set focus to the Send button.
-		composer.focusIndex = 3
+		composer.focusIndex = 4
 
 		// Simulate pressing Enter to send the email.
 		_, cmd := composer.Update(tea.KeyMsg{Type: tea.KeyEnter})
@@ -70,9 +77,10 @@ func TestComposerUpdate(t *testing.T) {
 
 		// Verify the content of the message.
 		expectedMsg := SendEmailMsg{
-			To:      "recipient@example.com",
-			Subject: "Test Subject",
-			Body:    "This is the body.",
+			To:             "recipient@example.com",
+			Subject:        "Test Subject",
+			Body:           "This is the body.",
+			AttachmentPath: "", // Expect empty attachment path in this test
 		}
 		if !reflect.DeepEqual(sendMsg, expectedMsg) {
 			t.Errorf("Mismatched SendEmailMsg.\nGot:  %+v\nWant: %+v", sendMsg, expectedMsg)