Merge pull request #1250 from trheyi/main

Refactor team configuration tests to remove uploader and avatar agent…
This commit is contained in:
Max 2025-10-28 17:24:21 +08:00 committed by GitHub
commit b1958ee788
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 41 deletions

View file

@ -105,8 +105,6 @@ func TestGetTeamConfigPublic(t *testing.T) {
assert.Equal(t, originalConfig.Role, publicConfig.Role, "Role should be preserved")
assert.Equal(t, originalConfig.Roles, publicConfig.Roles, "Roles should be preserved")
assert.Equal(t, originalConfig.Invite, publicConfig.Invite, "Invite config should be preserved")
assert.Equal(t, originalConfig.Uploader, publicConfig.Uploader, "Uploader should be preserved (public field)")
assert.Equal(t, originalConfig.AvatarAgent, publicConfig.AvatarAgent, "AvatarAgent should be preserved (public field)")
// Test robot configuration
if originalConfig.Robot != nil {

View file

@ -51,19 +51,6 @@ func TestTeamConfigStructure(t *testing.T) {
// Verify team config structure is valid
assert.IsType(t, &user.TeamConfig{}, teamConfig, "Should return correct team config type")
// Test uploader field (public field)
if teamConfig.Uploader != "" {
t.Logf("Uploader configured: %s", teamConfig.Uploader)
assert.NotEmpty(t, teamConfig.Uploader, "Uploader should not be empty if set")
}
// Test avatar_agent field (public field, optional)
if teamConfig.AvatarAgent != "" {
t.Logf("Avatar agent configured: %s", teamConfig.AvatarAgent)
} else {
t.Log("Avatar agent not configured (optional field)")
}
// Test roles configuration
if teamConfig.Roles != nil {
assert.IsType(t, []*user.TeamRole{}, teamConfig.Roles, "Roles should be slice of TeamRole pointers")
@ -176,19 +163,6 @@ func TestTeamConfigAPI(t *testing.T) {
// Verify team config structure
assert.IsType(t, &user.TeamConfig{}, &teamConfig, "Should return correct team config type")
// Test uploader field (public field)
if teamConfig.Uploader != "" {
t.Logf("API returned uploader: %s", teamConfig.Uploader)
assert.NotEmpty(t, teamConfig.Uploader, "Uploader should not be empty if set")
}
// Test avatar_agent field (public field, optional)
if teamConfig.AvatarAgent != "" {
t.Logf("API returned avatar_agent: %s", teamConfig.AvatarAgent)
} else {
t.Log("API returned no avatar_agent (optional field)")
}
// Test roles if present
if teamConfig.Roles != nil {
assert.IsType(t, []*user.TeamRole{}, teamConfig.Roles, "Roles should be slice of TeamRole pointers")

View file

@ -344,12 +344,10 @@ func GetTeamConfigPublic(locale string) *TeamConfig {
// Create a deep copy of the config to avoid modifying the original
publicConfig := &TeamConfig{
Type: originalConfig.Type,
Role: originalConfig.Role,
Roles: originalConfig.Roles, // Shallow copy is OK for roles (read-only)
Invite: originalConfig.Invite, // Shallow copy is OK for invite config (read-only)
Uploader: originalConfig.Uploader, // Public information
AvatarAgent: originalConfig.AvatarAgent, // Public information
Type: originalConfig.Type,
Role: originalConfig.Role,
Roles: originalConfig.Roles, // Shallow copy is OK for roles (read-only)
Invite: originalConfig.Invite, // Shallow copy is OK for invite config (read-only)
}
// Handle robot config - create a copy without sensitive fields

View file

@ -680,13 +680,11 @@ type RobotDefaults struct {
// TeamConfig represents the team configuration loaded from DSL files
type TeamConfig struct {
Roles []*TeamRole `json:"roles,omitempty"`
Robot *RobotConfig `json:"robot,omitempty"`
Invite *InviteConfig `json:"invite,omitempty"`
Type string `json:"type,omitempty"` // Default subscription type for new teams
Role string `json:"role,omitempty"` // Default user role for team creator
Uploader string `json:"uploader,omitempty"` // Uploader for avatar and attachments (default: __yao.attachment)
AvatarAgent string `json:"avatar_agent,omitempty"` // Agent ID for avatar generation (optional)
Roles []*TeamRole `json:"roles,omitempty"`
Robot *RobotConfig `json:"robot,omitempty"`
Invite *InviteConfig `json:"invite,omitempty"`
Type string `json:"type,omitempty"` // Default subscription type for new teams
Role string `json:"role,omitempty"` // Default user role for team creator
}
// TeamRole represents a team role configuration