落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package relation
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestBuild(t *testing.T) {
|
|
a := time.Date(1990, 1, 15, 0, 0, 0, 0, time.UTC)
|
|
b := time.Date(1992, 6, 8, 0, 0, 0, 0, time.UTC)
|
|
out := Build(a, b, "我", "TA")
|
|
if out.Summary["diff_one_liner"] == nil || out.Summary["overview"] == nil {
|
|
t.Fatal("missing summary fields")
|
|
}
|
|
dims, ok := out.Summary["dimension_compare"].([]map[string]any)
|
|
if !ok || len(dims) < 3 {
|
|
t.Fatalf("expected dimension_compare, got %#v", out.Summary["dimension_compare"])
|
|
}
|
|
secs, ok := out.Detail["sections"].([]map[string]any)
|
|
if !ok || len(secs) < 4 {
|
|
t.Fatalf("expected detail sections")
|
|
}
|
|
raw, _ := json.Marshal(out)
|
|
blob := string(raw)
|
|
for _, bad := range []string{"算命"} {
|
|
if strings.Contains(blob, bad) {
|
|
t.Fatalf("forbidden %q", bad)
|
|
}
|
|
}
|
|
if out.Summary["harmony_index"] == nil || out.Summary["star_compare"] == nil {
|
|
t.Fatal("missing match fields")
|
|
}
|
|
if out.Summary["love_index"] == nil || out.Summary["friend_index"] == nil || out.Summary["marriage_index"] == nil {
|
|
t.Fatal("missing match indices")
|
|
}
|
|
}
|
|
|
|
func TestBuildSameStyle(t *testing.T) {
|
|
d := time.Date(1990, 1, 15, 0, 0, 0, 0, time.UTC)
|
|
out := Build(d, d, "我", "TA")
|
|
if !strings.Contains(str(out.Summary["diff_one_liner"]), "接近") &&
|
|
!strings.Contains(str(out.Summary["diff_one_liner"]), "说明书") {
|
|
// same birth => same style; copy should mention 接近 or still valid
|
|
if out.Detail["weekly_practice"] == nil {
|
|
t.Fatal("missing weekly_practice")
|
|
}
|
|
}
|
|
}
|