fix(web): prefill birthday in contact form for imported contacts
Docker Image bauen und veröffentlichen / docker (push) Successful in 20m27s
Docker Image bauen und veröffentlichen / docker (push) Successful in 20m27s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.arnef.de/arnef/nidus/internal/config"
|
||||
"git.arnef.de/arnef/nidus/internal/db"
|
||||
@@ -316,3 +318,24 @@ func TestAccountChangePassword(t *testing.T) {
|
||||
t.Fatal("expected password to have changed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBirthdayInputValueNormalizesFormats(t *testing.T) {
|
||||
year := time.Now().Year()
|
||||
cases := []struct {
|
||||
in string
|
||||
want string
|
||||
}{
|
||||
{"", ""},
|
||||
{"19920217", "1992-02-17"}, // vCard 3.0 compact
|
||||
{"19540805", "1954-08-05"}, // compact, no VALUE param
|
||||
{"--0219", fmt.Sprintf("%04d-02-19", year)}, // year-less -> current year
|
||||
{"2026-09-06", "2026-09-06"}, // already dashed (web-created)
|
||||
{"1604-02-27", "1604-02-27"}, // dashed, ancient year preserved
|
||||
{"garbage", "garbage"}, // unrecognized passes through
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := birthdayInputValue(c.in); got != c.want {
|
||||
t.Errorf("birthdayInputValue(%q) = %q, want %q", c.in, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user