fix: retain last workspace when restart app

This commit is contained in:
Zack Fu Zi Xiang 2024-04-05 13:36:33 +08:00
parent 7ca3f215a3
commit 3ef7c4990b
No known key found for this signature in database

View File

@ -51,15 +51,22 @@ async fn af_cloud_workspace_change_name_and_icon() {
#[tokio::test]
async fn af_cloud_create_workspace_test() {
let name = uuid::Uuid::new_v4().to_string();
let email;
let second_workspace_id;
{
user_localhost_af_cloud().await;
let test = EventIntegrationTest::new().await;
let test = EventIntegrationTest::new_with_name(name.clone()).await;
let user_profile_pb = test.af_cloud_sign_up().await;
email = user_profile_pb.email;
let workspaces = test.get_all_workspaces().await.items;
let first_workspace_id = workspaces[0].workspace_id.as_str();
assert_eq!(workspaces.len(), 1);
let created_workspace = test.create_workspace("my second workspace").await;
second_workspace_id = created_workspace.workspace_id.clone();
assert_eq!(created_workspace.name, "my second workspace");
let workspaces = get_synced_workspaces(&test, user_profile_pb.id).await;
@ -87,6 +94,23 @@ async fn af_cloud_create_workspace_test() {
created_workspace.workspace_id
);
}
}
{
// Restart the app and read current workspace
user_localhost_af_cloud().await;
let test = EventIntegrationTest::new_with_name(name).await;
test.af_cloud_sign_in_with_email(&email).await.unwrap();
let user_profile_pb = test.get_user_profile().await.unwrap();
let workspaces = get_synced_workspaces(&test, user_profile_pb.id).await;
assert_eq!(workspaces.len(), 2);
{
let folder_ws = test.folder_read_current_workspace().await;
assert_eq!(folder_ws.id, second_workspace_id);
}
}
}
#[tokio::test]