feat(ECR-012–016): 合规、题库、时辰刷新、头像、MBTI OEJTS 与埋点

落地输入合规、探索题库、报告日/时辰刷新、账号头像、OEJTS 量表,并补齐 H5 埋点与 Admin 漏斗;同步 ESS 工件、切至自建 Git、清理 GitHub Actions。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-13 01:27:58 +08:00
co-authored by Cursor
parent 13860bf1ef
commit 89756f65b4
227 changed files with 7405 additions and 1407 deletions
+22 -42
View File
@@ -1,58 +1,38 @@
package explore
import (
"strings"
"testing"
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
)
func TestCatalogShape(t *testing.T) {
func TestCatalogHasScaleBankNearTop(t *testing.T) {
cats := Catalog()
if len(cats) < 6 {
t.Fatalf("want ≥6 L1 categories, got %d", len(cats))
if len(cats) < 2 {
t.Fatal("expected categories")
}
keys := map[string]bool{}
for _, c := range cats {
keys[c.Key] = true
if len(c.Items) < 1 {
t.Fatalf("category %s empty", c.Key)
}
for _, it := range c.Items {
if it.Path == "" || !strings.HasPrefix(it.Path, "/") {
t.Fatalf("bad path %#v", it)
}
}
if cats[1].Key != "tests" || cats[1].Title != "量表题库" {
t.Fatalf("second cat=%#v want 量表题库", cats[1])
}
for _, k := range []string{"decode", "star", "relation", "tests", "rhythm", "cards", "growth"} {
if !keys[k] {
t.Fatalf("missing category %s", k)
}
}
// 四核心应排在量表之前
if indexOf(cats, "tests") < indexOf(cats, "star") {
t.Fatal("tests should come after star")
if len(cats[1].Items) < 5 {
t.Fatalf("expected scale items, got %d", len(cats[1].Items))
}
}
func indexOf(cats []Category, key string) int {
for i, c := range cats {
if c.Key == key {
return i
}
func TestWithPublishedScalesReplacesItems(t *testing.T) {
cats := Catalog()
out := WithPublishedScales(cats, nil)
if len(out[1].Items) < 5 {
t.Fatal("nil scales should keep defaults")
}
return -1
}
func TestLexiconHardBanOnly(t *testing.T) {
blob := ""
for _, c := range Catalog() {
blob += c.Title + c.Description
for _, it := range c.Items {
blob += it.Title + it.Description
}
out = WithPublishedScales(cats, []repository.ScaleListItem{
{Slug: "mbti-lite", Title: "MBTI测试", Description: "from-db"},
{Slug: "eq-lite", Title: "情绪觉察探索", Description: "eq"},
})
if len(out[1].Items) != 2 {
t.Fatalf("items=%d", len(out[1].Items))
}
for _, bad := range []string{"占卜", "算命", "测测"} {
if strings.Contains(blob, bad) {
t.Fatalf("forbidden %q", bad)
}
if out[1].Items[0].Description != "from-db" || out[1].Items[0].Badge != "热" {
t.Fatalf("unexpected %#v", out[1].Items[0])
}
}