feat: add public account overview visibility

This commit is contained in:
2026-08-14 14:38:22 +08:00
parent bf37999833
commit 915d26d51d
14 changed files with 660 additions and 62 deletions
+43 -2
View File
@@ -33,7 +33,7 @@ func TestAccountsAndPerAccountUsage(t *testing.T) {
}
defer s.DB.Close()
accounts, err := s.Accounts()
if err != nil || len(accounts) != 1 || accounts[0].ID != 1 {
if err != nil || len(accounts) != 1 || accounts[0].ID != 1 || accounts[0].PublicVisible {
t.Fatalf("default accounts = %#v, %v", accounts, err)
}
second, err := s.CreateAccount("Team workspace")
@@ -97,11 +97,52 @@ func TestExistingAccountsGainExpectedKind(t *testing.T) {
if err != nil || len(accounts) != 1 {
t.Fatalf("accounts = %#v, %v", accounts, err)
}
if accounts[0].ExpectedKind != "any" || accounts[0].ActualKind != "team" || accounts[0].ValidationStatus != "matched" {
if accounts[0].ExpectedKind != "any" || accounts[0].PublicVisible || accounts[0].ActualKind != "team" || accounts[0].ValidationStatus != "matched" {
t.Fatalf("migrated account = %#v", accounts[0])
}
}
func TestAccountVisibilitySettings(t *testing.T) {
s, err := Open(t.TempDir())
if err != nil {
t.Fatal(err)
}
defer s.DB.Close()
private, err := s.CreateAccount("私有账号")
if err != nil {
t.Fatal(err)
}
public, err := s.CreateAccountWithVisibility("公开账号", "team", true)
if err != nil {
t.Fatal(err)
}
if private.PublicVisible || !public.PublicVisible {
t.Fatalf("created accounts = %#v, %#v", private, public)
}
if err := s.UpdateAccountSettings(public.ID, "公开账号重命名", "team"); err != nil {
t.Fatal(err)
}
unchanged, err := s.Account(public.ID)
if err != nil {
t.Fatal(err)
}
if !unchanged.PublicVisible {
t.Fatal("legacy settings update unexpectedly changed public visibility")
}
visible := false
if err := s.UpdateAccountSettingsWithVisibility(public.ID, "公开账号重命名", "team", &visible); err != nil {
t.Fatal(err)
}
updated, err := s.Account(public.ID)
if err != nil {
t.Fatal(err)
}
if updated.PublicVisible {
t.Fatal("explicit false visibility update was not persisted")
}
}
func ptr(value string) *string { return &value }
func TestLegacyUsageMigratesToDefaultAccount(t *testing.T) {