Implement sidebar tree view state persistence
This commit is contained in:
@@ -2402,6 +2402,76 @@ mod tests {
|
||||
.list_user_ui_preferences("bob", Some("local:_mnt_Data1T_mnote"), Some("local_folder"))
|
||||
.expect("list bob preferences");
|
||||
assert!(bob_preferences.is_empty());
|
||||
|
||||
let sidebar_scope = "filetree:root-hash:design-hash";
|
||||
let sidebar_value = serde_json::json!({
|
||||
"schemaVersion": 1,
|
||||
"treeKind": "filetree",
|
||||
"rootUri": "file:///mnt/Data1T/mnote",
|
||||
"scope": "design",
|
||||
"expandedRelativePaths": ["design/05-editor-mainline"],
|
||||
"expandedIds": [],
|
||||
"selectedId": "",
|
||||
"focusedId": "",
|
||||
"activeId": "",
|
||||
"scrollTop": 0
|
||||
})
|
||||
.to_string();
|
||||
let sidebar_first = store
|
||||
.upsert_user_ui_preference(UpsertUserUiPreferenceInput {
|
||||
id: None,
|
||||
user_id: "alice".to_string(),
|
||||
workspace_id: Some("local:_mnt_Data1T_mnote".to_string()),
|
||||
source_kind: Some("local_folder".to_string()),
|
||||
scope_kind: "sidebar_tree".to_string(),
|
||||
scope_id: sidebar_scope.to_string(),
|
||||
key: "sidebarTreeViewState.v1".to_string(),
|
||||
value_json: sidebar_value,
|
||||
})
|
||||
.expect("insert sidebar tree view state");
|
||||
let sidebar_updated = store
|
||||
.upsert_user_ui_preference(UpsertUserUiPreferenceInput {
|
||||
id: None,
|
||||
user_id: "alice".to_string(),
|
||||
workspace_id: Some("local:_mnt_Data1T_mnote".to_string()),
|
||||
source_kind: Some("local_folder".to_string()),
|
||||
scope_kind: "sidebar_tree".to_string(),
|
||||
scope_id: sidebar_scope.to_string(),
|
||||
key: "sidebarTreeViewState.v1".to_string(),
|
||||
value_json: serde_json::json!({
|
||||
"schemaVersion": 1,
|
||||
"treeKind": "filetree",
|
||||
"rootUri": "file:///mnt/Data1T/mnote",
|
||||
"scope": "design",
|
||||
"expandedRelativePaths": ["design/05-editor-mainline", "design/05-editor-mainline/process"],
|
||||
"expandedIds": [],
|
||||
"selectedId": "",
|
||||
"focusedId": "",
|
||||
"activeId": "",
|
||||
"scrollTop": 0
|
||||
})
|
||||
.to_string(),
|
||||
})
|
||||
.expect("upsert sidebar tree view state");
|
||||
assert_eq!(sidebar_updated.id, sidebar_first.id);
|
||||
assert_eq!(sidebar_updated.revision, sidebar_first.revision + 1);
|
||||
|
||||
let alice_sidebar_preferences = store
|
||||
.list_user_ui_preferences(
|
||||
"alice",
|
||||
Some("local:_mnt_Data1T_mnote"),
|
||||
Some("local_folder"),
|
||||
)
|
||||
.expect("list alice sidebar preferences");
|
||||
assert!(alice_sidebar_preferences.iter().any(|preference| {
|
||||
preference.scope_kind == "sidebar_tree"
|
||||
&& preference.scope_id == sidebar_scope
|
||||
&& preference.key == "sidebarTreeViewState.v1"
|
||||
}));
|
||||
let bob_sidebar_preferences = store
|
||||
.list_user_ui_preferences("bob", Some("local:_mnt_Data1T_mnote"), Some("local_folder"))
|
||||
.expect("list bob sidebar preferences");
|
||||
assert!(bob_sidebar_preferences.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user