mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-22 16:37:43 +00:00

* chore: move to latest appflowy collab version * chore: filter mapping * chore: remove mutex folder * chore: cleanup borrow checker issues * chore: fixed flowy user crate compilation errors * chore: removed parking lot crate * chore: adjusting non locking approach * chore: remove with folder method * chore: fix folder manager * chore: fixed workspace database compilation errors * chore: initialize database plugins * chore: fix locks in flowy core * chore: remove supabase * chore: async traits * chore: add mutexes in dart ffi * chore: post rebase fixes * chore: remove supabase dart code * chore: fix deadlock * chore: fix page_id is empty * chore: use data source to init collab * chore: fix user awareness test * chore: fix database deadlock * fix: initialize user awareness * chore: fix open workspace test * chore: fix import csv * chore: fix update row meta deadlock * chore: fix document size test * fix: timestamp set/get type convert * fix: calculation * chore: revert Arc to Rc * chore: attach plugin to database and database row * chore: async get row * chore: clippy * chore: fix tauri build * chore: clippy * fix: duplicate view deadlock * chore: fmt * chore: tauri build --------- Co-authored-by: nathan <nathan@appflowy.io>
65 lines
2.0 KiB
Rust
65 lines
2.0 KiB
Rust
use std::time::Duration;
|
|
|
|
use flowy_database2::entities::FieldType;
|
|
use flowy_database2::services::field::DateCellData;
|
|
use lib_infra::util::timestamp;
|
|
|
|
use crate::database::block_test::script::DatabaseRowTest;
|
|
use crate::database::block_test::script::RowScript::*;
|
|
|
|
// Create a new row at the end of the grid and check the create time is valid.
|
|
#[tokio::test]
|
|
async fn created_at_field_test() {
|
|
let mut test = DatabaseRowTest::new().await;
|
|
let row_count = test.row_details.len();
|
|
test
|
|
.run_scripts(vec![CreateEmptyRow, AssertRowCount(row_count + 1)])
|
|
.await;
|
|
|
|
// Get created time of the new row.
|
|
let row_detail = test.get_rows().await.last().cloned().unwrap();
|
|
let updated_at_field = test.get_first_field(FieldType::CreatedTime).await;
|
|
let cell = test
|
|
.editor
|
|
.get_cell(&updated_at_field.id, &row_detail.row.id)
|
|
.await
|
|
.unwrap();
|
|
let created_at_timestamp = DateCellData::from(&cell).timestamp.unwrap();
|
|
|
|
assert!(created_at_timestamp > 0);
|
|
assert!(created_at_timestamp <= timestamp());
|
|
}
|
|
|
|
// Update row and check the update time is valid.
|
|
#[tokio::test]
|
|
async fn update_at_field_test() {
|
|
let mut test = DatabaseRowTest::new().await;
|
|
let row_detail = test.get_rows().await.remove(0);
|
|
let last_edit_field = test.get_first_field(FieldType::LastEditedTime).await;
|
|
let cell = test
|
|
.editor
|
|
.get_cell(&last_edit_field.id, &row_detail.row.id)
|
|
.await
|
|
.unwrap();
|
|
let old_updated_at = DateCellData::from(&cell).timestamp.unwrap();
|
|
|
|
tokio::time::sleep(Duration::from_millis(1000)).await;
|
|
test
|
|
.run_script(UpdateTextCell {
|
|
row_id: row_detail.row.id.clone(),
|
|
content: "test".to_string(),
|
|
})
|
|
.await;
|
|
|
|
// Get the updated time of the row.
|
|
let row_detail = test.get_rows().await.remove(0);
|
|
let last_edit_field = test.get_first_field(FieldType::LastEditedTime).await;
|
|
let cell = test
|
|
.editor
|
|
.get_cell(&last_edit_field.id, &row_detail.row.id)
|
|
.await
|
|
.unwrap();
|
|
let new_updated_at = DateCellData::from(&cell).timestamp.unwrap();
|
|
assert!(old_updated_at < new_updated_at);
|
|
}
|