2020-05-04 21:59:43 +03:00
|
|
|
//! Project Manager tests.
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2020-05-24 19:19:57 +03:00
|
|
|
use ide::prelude::*;
|
|
|
|
|
2020-05-04 21:59:43 +03:00
|
|
|
use enso_protocol::project_manager::API;
|
|
|
|
use enso_protocol::project_manager::Client;
|
2020-06-25 00:24:46 +03:00
|
|
|
use ide::ide::*;
|
2020-05-04 21:59:43 +03:00
|
|
|
use ide::transport::web::WebSocket;
|
|
|
|
|
|
|
|
use wasm_bindgen_test::wasm_bindgen_test_configure;
|
|
|
|
|
|
|
|
wasm_bindgen_test_configure!(run_in_browser);
|
|
|
|
|
|
|
|
|
|
|
|
//#[wasm_bindgen_test::wasm_bindgen_test(async)]
|
|
|
|
#[allow(dead_code)]
|
|
|
|
async fn project_life_cycle() {
|
2020-11-30 14:38:35 +03:00
|
|
|
let logger = Logger::new("test");
|
|
|
|
let ws = WebSocket::new_opened(logger,"ws://localhost:30535").await;
|
2020-05-04 21:59:43 +03:00
|
|
|
let ws = ws.expect("Couldn't connect to WebSocket server.");
|
|
|
|
let client = Client::new(ws);
|
|
|
|
let _executor = setup_global_executor();
|
|
|
|
|
|
|
|
executor::global::spawn(client.runner());
|
|
|
|
|
|
|
|
let name = "TestProject".to_string();
|
2020-05-15 14:49:05 +03:00
|
|
|
let creation = client.create_project(&name).await.expect("Couldn't create project.");
|
2020-05-04 21:59:43 +03:00
|
|
|
let uuid = creation.project_id;
|
2020-05-15 14:49:05 +03:00
|
|
|
let _address = client.open_project(&uuid).await.expect("Couldn't open project.");
|
|
|
|
client.close_project(&uuid).await.expect("Couldn't close project.");
|
2020-07-16 22:05:25 +03:00
|
|
|
let list_response = client.list_projects(&None).await;
|
|
|
|
let list_response = list_response.expect("Couldn't list recent projects.");
|
|
|
|
assert!(list_response.projects.iter().any(|project| *project.name.deref() == name));
|
|
|
|
|
|
|
|
let new_name = "NewTestProject".to_string();
|
|
|
|
client.rename_project(&uuid,&new_name).await.expect("Couldn't rename project.");
|
|
|
|
let list_response = client.list_projects(&None).await;
|
|
|
|
let list_response = list_response.expect("Couldn't list recent projects.");
|
|
|
|
assert!(!list_response.projects.iter().any(|project| *project.name.deref() == name));
|
|
|
|
assert!(list_response.projects.iter().any(|project| *project.name.deref() == new_name));
|
|
|
|
|
2020-05-15 14:49:05 +03:00
|
|
|
client.delete_project(&uuid).await.expect("Couldn't delete project.");
|
2020-07-16 22:05:25 +03:00
|
|
|
let list_response = client.list_projects(&None).await;
|
|
|
|
let list_response = list_response.expect("Couldn't list recent projects.");
|
|
|
|
assert!(!list_response.projects.iter().any(|project| *project.name.deref() == name));
|
2020-05-04 21:59:43 +03:00
|
|
|
// FIXME[dg]: project/listSample isn't implemented on the server-side yet.
|
|
|
|
//client.list_samples(10).await.expect("Couldn't list samples.");
|
|
|
|
}
|
|
|
|
}
|