updated webclient setttings
This commit is contained in:
@@ -69,7 +69,7 @@ func TestWebmailSignatureCreateEditDeleteAndDefaults(t *testing.T) {
|
||||
if !got.IsDefaultNew || !got.IsDefaultReply {
|
||||
t.Fatalf("expected both defaults set, got %+v", got)
|
||||
}
|
||||
def, err := app.DB.GetDefaultSignature(mailboxID, false)
|
||||
def, err := app.DB.GetDefaultSignature(mailboxID, false, "")
|
||||
if err != nil || def == nil || def.ID != id {
|
||||
t.Fatalf("GetDefaultSignature(new) = %+v, err=%v", def, err)
|
||||
}
|
||||
@@ -91,6 +91,59 @@ func TestWebmailSignatureCreateEditDeleteAndDefaults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestWebmailSignatureSaveSetsAliasDefault confirms the "also set as default for a
|
||||
// specific alias" fields on the add/edit form (default_for_email/default_new/
|
||||
// default_reply) actually persist an alias-scoped default via
|
||||
// SetSignatureAliasDefault, and that GetDefaultSignature picks it up for that alias
|
||||
// specifically (not the mailbox's own primary address).
|
||||
func TestWebmailSignatureSaveSetsAliasDefault(t *testing.T) {
|
||||
app := newTestApp(t)
|
||||
mux := app.Mux()
|
||||
domains, _ := app.DB.ListDomains()
|
||||
mailboxID := createTestMailboxWithPassword(t, app, "sigalias@example.com", domains[0].ID, "sigalias-password-1!")
|
||||
if _, err := app.DB.CreateAlias(mailboxID, "support@example.com", domains[0].ID, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cookie := webmailLoginSession(t, app, mailboxID)
|
||||
|
||||
form := url.Values{
|
||||
"id": {""}, "name": {"Support"}, "content_html": {"<p>Support team</p>"},
|
||||
"default_for_email": {"support@example.com"}, "default_new": {"1"}, "default_reply": {"1"},
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodPost, MailboxPrefix+"/signatures/save", strings.NewReader(form.Encode()))
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.AddCookie(cookie)
|
||||
rec := httptest.NewRecorder()
|
||||
mux.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusFound {
|
||||
t.Fatalf("save: status=%d body=%s", rec.Code, rec.Body.String())
|
||||
}
|
||||
|
||||
sigs, err := app.DB.ListSignatures(mailboxID)
|
||||
if err != nil || len(sigs) != 1 {
|
||||
t.Fatalf("expected 1 signature, got %d (err=%v)", len(sigs), err)
|
||||
}
|
||||
sigID := sigs[0].ID
|
||||
|
||||
forNew, err := app.DB.GetDefaultSignature(mailboxID, false, "support@example.com")
|
||||
if err != nil || forNew == nil || forNew.ID != sigID {
|
||||
t.Fatalf("expected support@example.com's new-message default to be the saved signature, got %+v (err=%v)", forNew, err)
|
||||
}
|
||||
forReply, err := app.DB.GetDefaultSignature(mailboxID, true, "support@example.com")
|
||||
if err != nil || forReply == nil || forReply.ID != sigID {
|
||||
t.Fatalf("expected support@example.com's reply default to be the saved signature, got %+v (err=%v)", forReply, err)
|
||||
}
|
||||
// The mailbox's own primary address is untouched — alias defaults are additive,
|
||||
// not a replacement for the mailbox-wide default.
|
||||
primary, err := app.DB.GetDefaultSignature(mailboxID, false, "sigalias@example.com")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if primary != nil {
|
||||
t.Fatalf("expected no default for the mailbox's own primary address, got %+v", primary)
|
||||
}
|
||||
}
|
||||
|
||||
// TestWebmailSignatureOnlyOneDefaultPerMailbox confirms setting a second signature as
|
||||
// the default-for-new clears the flag from whichever one had it before.
|
||||
func TestWebmailSignatureOnlyOneDefaultPerMailbox(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user