refactor: externalize filetree runtime helpers
This commit is contained in:
@@ -102,6 +102,14 @@ pub fn build_router(state: AppState) -> Router {
|
||||
"/api/mnote-browser-runtime/local-upload-runtime.js",
|
||||
get(web_shell::local_upload_runtime_asset),
|
||||
)
|
||||
.route(
|
||||
"/api/mnote-browser-runtime/filetree-runtime.js",
|
||||
get(web_shell::filetree_runtime_asset),
|
||||
)
|
||||
.route(
|
||||
"/api/mnote-browser-runtime/filetree-context-menu-runtime.js",
|
||||
get(web_shell::filetree_context_menu_runtime_asset),
|
||||
)
|
||||
.route(
|
||||
"/api/mnote-browser-runtime/tree-live-controller.js",
|
||||
get(web_shell::tree_live_controller_runtime_asset),
|
||||
@@ -508,6 +516,42 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mnote_browser_runtime_assets_are_explicitly_mounted() {
|
||||
for path in [
|
||||
"/api/mnote-browser-runtime/resource-open-runtime.js",
|
||||
"/api/mnote-browser-runtime/local-upload-runtime.js",
|
||||
"/api/mnote-browser-runtime/filetree-runtime.js",
|
||||
"/api/mnote-browser-runtime/filetree-context-menu-runtime.js",
|
||||
"/api/mnote-browser-runtime/tree-live-controller.js",
|
||||
"/api/mnote-browser-runtime/tree-shell-runtime.js",
|
||||
] {
|
||||
let response = app(false)
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri(path)
|
||||
.body(Body::empty())
|
||||
.expect("request"),
|
||||
)
|
||||
.await
|
||||
.expect("response");
|
||||
assert_eq!(
|
||||
response.status(),
|
||||
StatusCode::OK,
|
||||
"{path} 应返回 runtime asset"
|
||||
);
|
||||
let content_type = response
|
||||
.headers()
|
||||
.get(axum::http::header::CONTENT_TYPE)
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.unwrap_or("");
|
||||
assert!(
|
||||
content_type.starts_with("application/javascript"),
|
||||
"{path} 应声明 JavaScript content-type"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn dev_hot_reload_endpoint_is_mounted() {
|
||||
let response = app(false)
|
||||
|
||||
Reference in New Issue
Block a user