diff --git a/collab-database/src/fields/type_option/checklist_type_option.rs b/collab-database/src/fields/type_option/checklist_type_option.rs index c68fa28ca..89be9e97a 100644 --- a/collab-database/src/fields/type_option/checklist_type_option.rs +++ b/collab-database/src/fields/type_option/checklist_type_option.rs @@ -108,8 +108,8 @@ mod checklist_type_option_tests { let json_value = json!({ "options": [ - { "id": "1", "name": "Option1", "color": 0 }, - { "id": "2", "name": "Option2", "color": 1 } + { "id": "1", "name": "Option1", "color": "Pink" }, + { "id": "2", "name": "Option2", "color": "LightPink" } ], "selected_option_ids": ["1"] }); diff --git a/collab-database/src/fields/type_option/select_type_option.rs b/collab-database/src/fields/type_option/select_type_option.rs index f48c6fe0b..6ad009c5b 100644 --- a/collab-database/src/fields/type_option/select_type_option.rs +++ b/collab-database/src/fields/type_option/select_type_option.rs @@ -120,7 +120,6 @@ impl SelectOption { } } #[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)] -#[serde(try_from = "u8", into = "u8")] #[repr(u8)] #[derive(Default)] pub enum SelectOptionColor { @@ -553,4 +552,35 @@ mod tests { let result = select_type_option.convert_raw_cell_data(&raw_data); assert_eq!(result, "Option 1, Option 2"); } + + #[test] + fn test_select_content_deser() { + let js_str = r#"{ + "options": [ + { + "id": "CEZD", + "name": "To Do", + "color": "Purple" + }, + { + "id": "TznH", + "name": "Doing", + "color": "Orange" + }, + { + "id": "__n6", + "name": "✅ Done", + "color": "Yellow" + } + ], + "disable_color": false + }"#; + + let select_ty_opt = serde_json::from_str::(js_str).unwrap(); + assert_eq!(select_ty_opt.options.len(), 3); + assert_eq!(select_ty_opt.options[0].name, "To Do"); + assert_eq!(select_ty_opt.options[1].color, SelectOptionColor::Orange); + assert_eq!(select_ty_opt.options[2].id, "__n6"); + assert!(!select_ty_opt.disable_color); + } }