fix: type option transform for checklists (#4779)

This commit is contained in:
Richard Shiue 2024-02-28 22:04:32 +08:00 committed by GitHub
parent 2d6856a23d
commit 01f2b15f70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View File

@ -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,

View File

@ -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;
}