Merge remote-tracking branch 'origin/codex/wooden-fish-template'
This commit is contained in:
@@ -8,8 +8,8 @@ use axum::{
|
||||
};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
#[cfg(test)]
|
||||
use module_runtime::build_creation_entry_config_response;
|
||||
use shared_contracts::creation_entry_config::CreationEntryConfigResponse;
|
||||
|
||||
use crate::{
|
||||
api_response::json_success_body, http_error::AppError, request_context::RequestContext,
|
||||
@@ -84,6 +84,12 @@ pub fn resolve_creation_entry_route_id(path: &str) -> Option<&'static str> {
|
||||
if normalized.starts_with("/api/creation/bark-battle") {
|
||||
return Some("bark-battle");
|
||||
}
|
||||
if normalized.starts_with("/api/runtime/wooden-fish") {
|
||||
return Some("wooden-fish");
|
||||
}
|
||||
if normalized.starts_with("/api/creation/wooden-fish") {
|
||||
return Some("wooden-fish");
|
||||
}
|
||||
if normalized.starts_with("/api/runtime/square-hole") {
|
||||
return Some("square-hole");
|
||||
}
|
||||
@@ -123,9 +129,8 @@ fn creation_entry_error_response(request_context: &RequestContext, error: AppErr
|
||||
error.into_response_with_context(Some(request_context))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn test_creation_entry_config_response()
|
||||
-> shared_contracts::creation_entry_config::CreationEntryConfigResponse {
|
||||
/// 中文注释:本地 debug 兜底也来自后端领域默认种子,避免前端恢复硬编码入口配置。
|
||||
pub(crate) fn default_creation_entry_config_response() -> CreationEntryConfigResponse {
|
||||
build_creation_entry_config_response(module_runtime::CreationEntryConfigSnapshot {
|
||||
config_id: module_runtime::CREATION_ENTRY_CONFIG_GLOBAL_ID.to_string(),
|
||||
start_card: module_runtime::CreationEntryStartCardSnapshot {
|
||||
@@ -143,6 +148,11 @@ pub(crate) fn test_creation_entry_config_response()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn test_creation_entry_config_response() -> CreationEntryConfigResponse {
|
||||
default_creation_entry_config_response()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -197,6 +207,14 @@ mod tests {
|
||||
resolve_creation_entry_route_id("/api/creation/bark-battle/drafts"),
|
||||
Some("bark-battle"),
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_creation_entry_route_id("/api/runtime/wooden-fish/runs/run-1"),
|
||||
Some("wooden-fish"),
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_creation_entry_route_id("/api/creation/wooden-fish/sessions"),
|
||||
Some("wooden-fish"),
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_creation_entry_route_id("/api/creation/edutainment/baby-object-match/assets"),
|
||||
Some("baby-object-match"),
|
||||
@@ -217,10 +235,10 @@ mod tests {
|
||||
.find(|item| item.id == "bark-battle")
|
||||
.expect("test creation entry config should include bark-battle");
|
||||
|
||||
assert_eq!(bark_battle.title, "汪汪声浪");
|
||||
assert_eq!(bark_battle.title, "\u{6c6a}\u{6c6a}\u{58f0}\u{6d6a}");
|
||||
assert!(bark_battle.visible);
|
||||
assert!(bark_battle.open);
|
||||
assert_eq!(bark_battle.badge, "可创建");
|
||||
assert_eq!(bark_battle.badge, "\u{53ef}\u{521b}\u{5efa}");
|
||||
assert_eq!(
|
||||
bark_battle.image_src,
|
||||
"/creation-type-references/bark-battle.webp"
|
||||
@@ -228,7 +246,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_creation_entry_config_response_keeps_baby_object_match_coming_soon() {
|
||||
fn test_creation_entry_config_response_keeps_baby_object_match_visible() {
|
||||
let config = test_creation_entry_config_response();
|
||||
let baby_object_match = config
|
||||
.creation_types
|
||||
@@ -236,10 +254,10 @@ mod tests {
|
||||
.find(|item| item.id == "baby-object-match")
|
||||
.expect("test creation entry config should include baby-object-match");
|
||||
|
||||
assert_eq!(baby_object_match.title, "宝贝识物");
|
||||
assert_eq!(baby_object_match.title, "\u{5b9d}\u{8d1d}\u{8bc6}\u{7269}");
|
||||
assert!(baby_object_match.visible);
|
||||
assert!(!baby_object_match.open);
|
||||
assert_eq!(baby_object_match.badge, "敬请期待");
|
||||
assert!(baby_object_match.open);
|
||||
assert_eq!(baby_object_match.badge, "\u{53ef}\u{521b}\u{5efa}");
|
||||
assert_eq!(baby_object_match.sort_order, 90);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user