2020-05-04 21:59:43 +03:00
|
|
|
//! Project Manager tests.
|
|
|
|
|
2022-03-10 08:21:57 +03:00
|
|
|
// === Non-Standard Linter Configuration ===
|
2022-03-10 07:57:59 +03:00
|
|
|
#![deny(non_ascii_idents)]
|
|
|
|
#![warn(unsafe_code)]
|
|
|
|
|
2022-03-10 07:32:33 +03:00
|
|
|
|
|
|
|
|
2020-05-04 21:59:43 +03:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2021-11-16 12:04:56 +03:00
|
|
|
use enso_gui::prelude::*;
|
2020-05-24 19:19:57 +03:00
|
|
|
|
2021-11-09 15:13:15 +03:00
|
|
|
use engine_protocol::project_manager::Client;
|
|
|
|
use engine_protocol::project_manager::API;
|
2021-11-16 12:04:56 +03:00
|
|
|
use enso_gui::transport::web::WebSocket;
|
2020-05-04 21:59:43 +03:00
|
|
|
|
2021-11-09 15:13:15 +03:00
|
|
|
use engine_protocol::project_manager::MissingComponentAction::Install;
|
2021-12-24 11:29:06 +03:00
|
|
|
use engine_protocol::project_manager::ProjectName;
|
2021-11-02 16:05:43 +03:00
|
|
|
use wasm_bindgen_test::wasm_bindgen_test_configure;
|
2020-05-04 21:59:43 +03:00
|
|
|
|
|
|
|
wasm_bindgen_test_configure!(run_in_browser);
|
|
|
|
|
|
|
|
|
|
|
|
//#[wasm_bindgen_test::wasm_bindgen_test(async)]
|
|
|
|
#[allow(dead_code)]
|
|
|
|
async fn project_life_cycle() {
|
2021-11-02 16:05:43 +03:00
|
|
|
let logger = Logger::new("test");
|
|
|
|
let ws = WebSocket::new_opened(logger, "ws://localhost:30535").await;
|
|
|
|
let ws = ws.expect("Couldn't connect to WebSocket server.");
|
|
|
|
let client = Client::new(ws);
|
2021-11-16 12:04:56 +03:00
|
|
|
let _executor = enso_gui::initializer::setup_global_executor();
|
2020-05-04 21:59:43 +03:00
|
|
|
|
|
|
|
executor::global::spawn(client.runner());
|
|
|
|
|
2021-12-24 11:29:06 +03:00
|
|
|
let name = ProjectName::new_unchecked("TestProject");
|
2021-12-11 00:01:45 +03:00
|
|
|
let creation = client.create_project(&name, &None, &None, &Install);
|
|
|
|
let created = creation.await.expect("Couldn't create project.");
|
|
|
|
let uuid = created.project_id;
|
2021-11-02 16:05:43 +03:00
|
|
|
let _address = client.open_project(&uuid, &Install).await.expect("Couldn't open project.");
|
2020-05-15 14:49:05 +03:00
|
|
|
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.");
|
2021-12-24 11:29:06 +03:00
|
|
|
assert!(list_response.projects.iter().any(|project| project.name == name));
|
2020-07-16 22:05:25 +03:00
|
|
|
|
2021-12-24 11:29:06 +03:00
|
|
|
let new_name = ProjectName::new_unchecked("NewTestProject");
|
2021-11-02 16:05:43 +03:00
|
|
|
client.rename_project(&uuid, &new_name).await.expect("Couldn't rename 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.");
|
2021-12-24 11:29:06 +03:00
|
|
|
assert!(!list_response.projects.iter().any(|project| project.name == name));
|
|
|
|
assert!(list_response.projects.iter().any(|project| project.name == new_name));
|
2020-07-16 22:05:25 +03:00
|
|
|
|
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.");
|
2021-12-24 11:29:06 +03:00
|
|
|
assert!(!list_response.projects.iter().any(|project| project.name == 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.");
|
|
|
|
}
|
|
|
|
}
|