From 01f2b15f70669391b2273ad62811ca52e99d338b Mon Sep 17 00:00:00 2001 From: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Date: Wed, 28 Feb 2024 22:04:32 +0800 Subject: [PATCH] fix: type option transform for checklists (#4779) --- .../text_type_option/text_type_option.rs | 1 + .../tests/database/field_test/test.rs | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs index 32e9096e87..5f39f6ad24 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs @@ -73,6 +73,7 @@ impl TypeOptionTransform for RichTextTypeOption { || transformed_field_type.is_multi_select() || transformed_field_type.is_number() || transformed_field_type.is_url() + || transformed_field_type.is_checklist() { Some(StrCellData::from(stringify_cell_data( cell, diff --git a/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs b/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs index 03b42a69b7..bc54883697 100644 --- a/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs +++ b/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs @@ -206,7 +206,7 @@ async fn grid_switch_from_multi_select_to_text_test() { // Test when switching the current field from Checkbox to Text test // input: // check -> "Yes" -// unchecked -> "" +// unchecked -> "No" #[tokio::test] async fn grid_switch_from_checkbox_to_text_test() { let mut test = DatabaseFieldTest::new().await; @@ -290,3 +290,24 @@ async fn grid_switch_from_number_to_text_test() { test.run_scripts(scripts).await; } + +/// Test when switching the current field from Checklist to Text test +#[tokio::test] +async fn grid_switch_from_checklist_to_text_test() { + let mut test = DatabaseFieldTest::new().await; + let field_rev = test.get_first_field(FieldType::Checklist); + + let scripts = vec![ + SwitchToField { + field_id: field_rev.id.clone(), + new_field_type: FieldType::RichText, + }, + AssertCellContent { + field_id: field_rev.id.clone(), + row_index: 0, + from_field_type: FieldType::Checklist, + expected_content: "First thing".to_string(), + }, + ]; + test.run_scripts(scripts).await; +}