feat: connect portal content and banner carousel

This commit is contained in:
richjohnrambo
2026-10-16 18:59:16 +08:00
parent a86db10342
commit bce5edfaf5
10 changed files with 332 additions and 85 deletions
+19 -5
View File
@@ -203,15 +203,29 @@ func TestNoticesRejectsOversizedPage(t *testing.T) {
}
}
func TestPopupNoticeMapsLatestUnreadNotice(t *testing.T) {
service := New(fakeRepository{notices: []store.MemberNotice{{
ID: 9, Title: "公告通知", Content: "新活动已上线", SourceType: 1,
}}})
func TestPopupNoticeUsesManagedContent(t *testing.T) {
service := New(fakeRepository{content: &store.Content{
ContentKey: "home_popup_content", Title: "公告通知", BodyText: "新活动已上线",
PublishedAt: "2026-10-16T08:00:00Z",
}})
notice, err := service.PopupNotice(context.Background(), 1, 7)
if err != nil {
t.Fatal(err)
}
if notice == nil || notice.ID != 9 || notice.Content != "新活动已上线" || notice.SourceType != "real" {
if notice == nil || notice.ID != 0 || notice.Content != "新活动已上线" || notice.SourceType != "managed_content" {
t.Fatalf("unexpected popup notice: %+v", notice)
}
}
func TestContentAliasesPublicAgreementRoutesToManagedText(t *testing.T) {
service := New(fakeRepository{content: &store.Content{
ContentKey: "platform_introduction", Title: "平台简介", BodyText: "服务条款正文",
}})
content, err := service.Content(context.Background(), 1, "user_agreement")
if err != nil {
t.Fatal(err)
}
if content.ContentKey != "user_agreement" || content.Title != "用户协议" || content.BodyText != "服务条款正文" {
t.Fatalf("unexpected aliased content: %+v", content)
}
}