mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
test: more gh tui tests
This commit is contained in:
+40
-32
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user