From 2256076ed174b25a5decc2631ee6abaa9fa1a3c1 Mon Sep 17 00:00:00 2001 From: "Julien Tant (aider)" Date: Wed, 12 Feb 2025 17:06:22 -0700 Subject: [PATCH] refactor: Make color field optional in custom profile attributes --- .../public/model/custom_profile_attributes.go | 4 ---- .../model/custom_profile_attributes_test.go | 23 ++++++++----------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/server/public/model/custom_profile_attributes.go b/server/public/model/custom_profile_attributes.go index 006db039174..4719261d97b 100644 --- a/server/public/model/custom_profile_attributes.go +++ b/server/public/model/custom_profile_attributes.go @@ -111,10 +111,6 @@ func (c CustomProfileAttributesSelectOption) IsValid() error { return errors.New("name cannot be empty") } - if c.Color == "" { - return errors.New("color cannot be empty") - } - return nil } diff --git a/server/public/model/custom_profile_attributes_test.go b/server/public/model/custom_profile_attributes_test.go index 0b6d14fd2c5..a8044221947 100644 --- a/server/public/model/custom_profile_attributes_test.go +++ b/server/public/model/custom_profile_attributes_test.go @@ -52,7 +52,7 @@ func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) { wantErr string }{ { - name: "valid option", + name: "valid option with color", option: CustomProfileAttributesSelectOption{ ID: NewId(), Name: "Test Option", @@ -60,6 +60,14 @@ func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) { }, wantErr: "", }, + { + name: "valid option without color", + option: CustomProfileAttributesSelectOption{ + ID: NewId(), + Name: "Test Option", + }, + wantErr: "", + }, { name: "empty ID", option: CustomProfileAttributesSelectOption{ @@ -87,15 +95,6 @@ func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) { }, wantErr: "name cannot be empty", }, - { - name: "empty color", - option: CustomProfileAttributesSelectOption{ - ID: NewId(), - Name: "Test Option", - Color: "", - }, - wantErr: "color cannot be empty", - }, } for _, tt := range tests { @@ -200,7 +199,7 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) { wantErr: "options list cannot be empty", }, { - name: "valid options", + name: "valid options with and without color", options: CustomProfileAttributesSelectOptions{ { ID: NewId(), @@ -210,7 +209,6 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) { { ID: NewId(), Name: "Option 2", - Color: "#00FF00", }, }, wantErr: "", @@ -226,7 +224,6 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) { { ID: "", Name: "Option 2", - Color: "#00FF00", }, }, wantErr: "invalid option at index 1: id cannot be empty",