test: more gh tui tests

This commit is contained in:
Slug-Boi
2025-04-16 13:26:40 +02:00
parent a0880457f7
commit 04a5cd3bd9
+40 -32
View File
@@ -392,42 +392,50 @@ func TestNewGitHubUserForm(t *testing.T) {
} }
} }
// // Test form submission with required field // Test form submission with required field
// func TestSubmitWithRequiredField(t *testing.T) { func TestSubmitWithRequiredField(t *testing.T) {
// m := NewGitHubUserForm(nil) setup()
// tm := teatest.NewTestModel( defer teardown()
// t, m, teatest.WithInitialTermSize(300, 300),
// )
// // Simulate filling in the required field
// tm.Type("Slug-Boi") m := NewGitHubUserForm(nil)
// tm.Send(tea.KeyMsg{Type: tea.KeyTab}) // Move to next field tm := teatest.NewTestModel(
// tm.Send(tea.KeyMsg{Type: tea.KeyTab}) t, m, teatest.WithInitialTermSize(300, 300),
// tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) // Submit )
// tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*5))
// // Check if the form was submitted // Simulate filling in the required field
// updated, _ := tm.FinalModel(t).(GitHubUserModel) tm.Type("Slug-Boi")
tm.Send(tea.KeyMsg{Type: tea.KeyTab}) // Move to next field
tm.Send(tea.KeyMsg{Type: tea.KeyTab}) // Move to submit button
tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) // Submit
tm.Send(tea.KeyMsg{Type: tea.KeyTab})
tm.Send(tea.KeyMsg{Type: tea.KeyTab})
tm.Send(tea.KeyMsg{Type: tea.KeyTab})
tm.Type("input@mail")
tm.Send(tea.KeyMsg{Type: tea.KeyTab})
tm.Send(tea.KeyMsg{Type: tea.KeyTab})
tm.Send(tea.KeyMsg{Type: tea.KeyTab})
tm.Send(tea.KeyMsg{Type: tea.KeyEnter}) // Submit
tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*5))
// Check if the form was submitted
updated, _ := tm.FinalModel(t).(model_ca)
// // Check if the form was submitted if updated.inputs[0].Value() != "th" {
// if !updated.submitted { t.Errorf("Expected 'Slug-Boi', got '%s'", updated.inputs[0].Value())
// t.Error("Form should submit with required field filled") }
// } if updated.inputs[1].Value() != "Theis" {
// } t.Errorf("Expected 'Slug-Boi', got '%s'", updated.inputs[1].Value())
}
// // Test error when required field missing if updated.inputs[2].Value() != "Slug-Boi" {
// func TestSubmitWithoutRequiredField(t *testing.T) { t.Errorf("Expected 'Slug-Boi', got '%s'", updated.inputs[2].Value())
// m := NewGitHubUserForm(nil) }
if updated.inputs[3].Value() != "input@mail" {
// // Simulate submit with empty username t.Errorf("Expected 'input@mail', got '%s'", updated.inputs[3].Value())
// updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyTab}) }
// updated, _ = updated.(GitHubUserModel).Update(tea.KeyMsg{Type: tea.KeyEnter}) }
// if !updated.(GitHubUserModel).showError {
// t.Error("Should show error when required field missing")
// }
// }
// Test temp auth toggle visibility // Test temp auth toggle visibility
func TestTempAuthToggleVisibility(t *testing.T) { func TestTempAuthToggleVisibility(t *testing.T) {