每账号仅一条 self(migration 40902);合盘只选 TA;账号昵称可改;首页穿衣/颜色/养生贴士。 Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
2.2 KiB
Go
67 lines
2.2 KiB
Go
package integration_test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
// ECR-011: one self per account; nickname patch; daily-tips envelope.
|
|
func TestECR011ProfileIntegrityNicknameTips(t *testing.T) {
|
|
r, _ := setupAPI(t)
|
|
key := mustRegister(t, r)
|
|
|
|
env, key := doJSON(t, r, http.MethodPost, "/api/v1/profiles", map[string]any{
|
|
"relation": "self", "birth_date": "1990-05-12", "display_name": "我",
|
|
}, key)
|
|
self := decodeData[map[string]any](t, env.Data)
|
|
selfID, _ := self["id"].(string)
|
|
if selfID == "" {
|
|
t.Fatal("missing self id")
|
|
}
|
|
|
|
_, key, status := doJSONExpect(t, r, http.MethodPost, "/api/v1/profiles", map[string]any{
|
|
"relation": "self", "birth_date": "1991-01-01", "display_name": "我2",
|
|
}, key, 40902)
|
|
if status != http.StatusConflict {
|
|
t.Fatalf("second self want HTTP 409, got %d", status)
|
|
}
|
|
|
|
env, key = doJSON(t, r, http.MethodPost, "/api/v1/profiles", map[string]any{
|
|
"relation": "other", "birth_date": "1992-08-20", "display_name": "TA",
|
|
}, key)
|
|
other := decodeData[map[string]any](t, env.Data)
|
|
otherID, _ := other["id"].(string)
|
|
|
|
_, key, status = doJSONExpect(t, r, http.MethodPost, "/api/v1/reports/synastry", map[string]any{
|
|
"profile_id_a": selfID, "profile_id_b": selfID,
|
|
}, key, 10000)
|
|
if status != http.StatusBadRequest {
|
|
t.Fatalf("same id synastry want HTTP 400, got %d", status)
|
|
}
|
|
|
|
env, key = doJSON(t, r, http.MethodPost, "/api/v1/reports/synastry", map[string]any{
|
|
"profile_id_a": selfID, "profile_id_b": otherID,
|
|
}, key)
|
|
|
|
env, key = doJSON(t, r, http.MethodPatch, "/api/v1/auth/me", map[string]any{
|
|
"nickname": "心语岛",
|
|
}, key)
|
|
me := decodeData[map[string]any](t, env.Data)
|
|
if me["nickname"] != "心语岛" {
|
|
t.Fatalf("nickname want 心语岛 got %#v", me["nickname"])
|
|
}
|
|
|
|
env, _ = doJSON(t, r, http.MethodGet, "/api/v1/home/daily-tips", nil, key)
|
|
tips := decodeData[map[string]any](t, env.Data)
|
|
if tips["clothing"] == nil || tips["palette"] == nil || tips["wellness"] == nil {
|
|
t.Fatalf("daily-tips missing fields: %#v", tips)
|
|
}
|
|
if _, ok := tips["clothing_index"].(float64); !ok {
|
|
t.Fatalf("clothing_index missing: %#v", tips["clothing_index"])
|
|
}
|
|
src, _ := tips["source"].(string)
|
|
if src != "llm" && src != "fallback" {
|
|
t.Fatalf("source want llm|fallback got %q", src)
|
|
}
|
|
}
|