feat: 收口 mindmap Phase 6 Leptos UI shell
This commit is contained in:
@@ -20,15 +20,16 @@ pub async fn mindmap_object_shell(
|
||||
"documentId": doc_id,
|
||||
"mindmapId": mindmap_id,
|
||||
"projection": {
|
||||
"schema": "mnote.mindmap_projection.v1",
|
||||
"source": "rust-kernel",
|
||||
"schema": "mnote.mindmap.simple_mind_map_scene.v1",
|
||||
"runtime": "simple-mind-map",
|
||||
"source": "compat-blob",
|
||||
"owner": "rust-kernel",
|
||||
"queryName": "mindmap.projection.get"
|
||||
"queryName": "mindmap.simple_mind_map_scene.get"
|
||||
},
|
||||
"island": {
|
||||
"kind": "react_mindmap_runtime",
|
||||
"kind": "leptos_mindmap_adapter",
|
||||
"mountId": "mnote-mindmap-island",
|
||||
"runtimeRole": "renderer_adapter",
|
||||
"runtimeRole": "simple_mind_map_adapter",
|
||||
"commandName": "mindmap.command.apply"
|
||||
},
|
||||
"requestId": context.trace.request_id,
|
||||
@@ -115,6 +116,47 @@ mod tests {
|
||||
}))
|
||||
}
|
||||
|
||||
fn app_with_mindmap_fixture() -> axum::Router {
|
||||
build_app(AppState::new(AppConfig {
|
||||
service_name: "mnote-web".into(),
|
||||
service_version: "0.1.0".into(),
|
||||
bind_addr: "127.0.0.1:0".into(),
|
||||
public_bind_addr: "127.0.0.1:3000".into(),
|
||||
legacy_next_base_url: Some("http://127.0.0.1:3100".into()),
|
||||
enable_legacy_next_compat: true,
|
||||
enable_debug_shell_routes: false,
|
||||
hermes_base_path: "/api/hermes".into(),
|
||||
compat_next_base_path: "/api/compat/next".into(),
|
||||
convex_url: None,
|
||||
convex_admin_key: None,
|
||||
allow_dev_fixtures: true,
|
||||
query_fixtures_json: Some(
|
||||
serde_json::json!({
|
||||
"mindmaps:get": {
|
||||
"ok": true,
|
||||
"source": "compat-blob",
|
||||
"revision": 7,
|
||||
"data": {
|
||||
"data": {"uid": "root", "text": "KMIND"},
|
||||
"children": [
|
||||
{"data": {"uid": "topic", "text": "二级节点"}, "children": []}
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"document_id": "doc_1",
|
||||
"mindmap_id": "mind_1"
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_string(),
|
||||
),
|
||||
mutation_fixtures_json: None,
|
||||
dev_user_id: "dev-user".into(),
|
||||
dev_user_name: "开发用户".into(),
|
||||
dev_user_email: "dev@mnote.local".into(),
|
||||
}))
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mindmap_shell_returns_rust_object_shell_contract() {
|
||||
let response = app()
|
||||
@@ -147,9 +189,42 @@ mod tests {
|
||||
.expect("body");
|
||||
let html = String::from_utf8(body.to_vec()).expect("utf8");
|
||||
assert!(html.contains("mnote.mindmap_shell.v1"));
|
||||
assert!(html.contains("data-react-island=\"mindmap_runtime\""));
|
||||
assert!(html.contains("mindmap.projection.get"));
|
||||
assert!(html.contains("data-leptos-mindmap-island=\"standalone\""));
|
||||
assert!(html.contains("mindmap.simple_mind_map_scene.get"));
|
||||
assert!(html.contains("mindmap.command.apply"));
|
||||
assert!(!html.contains("react_mindmap_runtime"));
|
||||
assert!(!html.contains("next-app-router"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mindmap_api_returns_same_adapter_contract_for_standalone_and_block() {
|
||||
let response = app_with_mindmap_fixture()
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri("/api/mindmap/doc_1/mind_1?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get")
|
||||
.body(Body::empty())
|
||||
.expect("request"),
|
||||
)
|
||||
.await
|
||||
.expect("response");
|
||||
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = to_bytes(response.into_body(), usize::MAX)
|
||||
.await
|
||||
.expect("body");
|
||||
let payload: serde_json::Value =
|
||||
serde_json::from_slice(&body).expect("adapter projection json");
|
||||
assert_eq!(
|
||||
payload["schema"],
|
||||
serde_json::json!("mnote.mindmap.simple_mind_map_scene.v1")
|
||||
);
|
||||
assert_eq!(payload["runtime"], serde_json::json!("simple-mind-map"));
|
||||
assert_eq!(payload["root"]["data"]["uid"], serde_json::json!("root"));
|
||||
assert_eq!(payload["root"]["data"]["text"], serde_json::json!("KMIND"));
|
||||
assert_eq!(payload["kernelRevision"], serde_json::json!(7));
|
||||
assert_eq!(
|
||||
payload["compatPayload"]["source"],
|
||||
serde_json::json!("compat-blob")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user