fix(tui): default SMTP port to 465 in the account form

NewAccountForm prefilled defaults for mode, IMAP port, and both securities but
left SMTP port blank. Default it to 465 to match `account add --smtp-port`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-22 21:15:25 +01:00
parent 1b2fe99055
commit b3390a0a20
2 changed files with 14 additions and 0 deletions
+3
View File
@@ -203,6 +203,9 @@ func NewAccountForm(initial Fields, editing bool) AccountForm {
if initial.IMAPSecurity == "" { if initial.IMAPSecurity == "" {
initial.IMAPSecurity = "tls" initial.IMAPSecurity = "tls"
} }
if initial.SMTPPort == "" {
initial.SMTPPort = "465"
}
if initial.SMTPSecurity == "" { if initial.SMTPSecurity == "" {
initial.SMTPSecurity = "tls" initial.SMTPSecurity = "tls"
} }
+11
View File
@@ -111,6 +111,17 @@ func TestFieldsFromAccountRoundTrip(t *testing.T) {
} }
} }
func TestNewAccountFormDefaultsSMTPPort(t *testing.T) {
f := NewAccountForm(Fields{}, false).collect()
if f.SMTPPort != "465" {
t.Fatalf("SMTP port should default to 465, got %q", f.SMTPPort)
}
// The other prefilled defaults must remain intact.
if f.IMAPPort != "993" || f.Mode != "RO" || f.IMAPSecurity != "tls" || f.SMTPSecurity != "tls" {
t.Fatalf("existing defaults regressed: %+v", f)
}
}
func TestAccountFormSubmitValid(t *testing.T) { func TestAccountFormSubmitValid(t *testing.T) {
m := NewAccountForm(validFields(), false) m := NewAccountForm(validFields(), false)
// Enter submits; with valid fields the form completes. // Enter submits; with valid fields the form completes.