fix: Vorlesen bei ausgefallenem Studio meldet das verständlich (503, JSON); Tests browser2vorlesen.3, browser2stimmen.6, admin2enginefenster.3; Version 0.1.17-rc3
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg6sxZ8wsKZAVLQ6Xj5
This commit is contained in:
@ -40,6 +40,8 @@ struct FixedEngine {
|
||||
fail: std::sync::atomic::AtomicBool,
|
||||
/// Lässt `stop` scheitern, während die Instanz weiterläuft (→ #1166).
|
||||
stop_fails: std::sync::atomic::AtomicBool,
|
||||
/// Das Studio hinter den Stimmen antwortet nicht (browser2vorlesen.3).
|
||||
studio_down: std::sync::atomic::AtomicBool,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@ -51,7 +53,13 @@ impl Engine for FixedEngine {
|
||||
capabilities: Capabilities::default(),
|
||||
}
|
||||
}
|
||||
async fn voices_reachable(&self) -> bool {
|
||||
!self.studio_down.load(Ordering::SeqCst)
|
||||
}
|
||||
async fn voices(&self) -> Vec<nexus_adapter::Voice> {
|
||||
if self.studio_down.load(Ordering::SeqCst) {
|
||||
return Vec::new();
|
||||
}
|
||||
vec![nexus_adapter::Voice {
|
||||
id: "Ryan".into(),
|
||||
name: "Ryan".into(),
|
||||
@ -365,6 +373,7 @@ async fn gateway_with(
|
||||
delay: Duration::from_millis(delay_ms),
|
||||
fail: std::sync::atomic::AtomicBool::new(fail),
|
||||
stop_fails: std::sync::atomic::AtomicBool::new(false),
|
||||
studio_down: std::sync::atomic::AtomicBool::new(false),
|
||||
});
|
||||
|
||||
let mut store = Store::open_in_memory().unwrap();
|
||||
@ -2959,6 +2968,55 @@ async fn playground(
|
||||
req.send().await.unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn vorlesen_ohne_studio_meldet_das_und_nicht_nicht_freigegeben() {
|
||||
// browser2vorlesen.3: Ist das Studio aus, ist die Stimmenliste leer. Die Meldung muss das sagen (503) und als
|
||||
// JSON mit Text ankommen, nicht als HTML-Seite („Fehler 403“ ohne Text).
|
||||
let gw = gateway(0, false).await;
|
||||
let (cookie, csrf) = ui_session(&gw, &gw.key_admin).await;
|
||||
gw.state
|
||||
.store()
|
||||
.set_voice_approved("Ryan", true, TEST_ADMIN, true)
|
||||
.unwrap();
|
||||
let sprechen = |body: Value| {
|
||||
gw.client
|
||||
.post(format!("{}/ui/chat/sprechen", gw.base))
|
||||
.header("origin", &gw.base)
|
||||
.header("cookie", &cookie)
|
||||
.header("x-csrf-token", &csrf)
|
||||
.header(CONTENT_TYPE, "application/json")
|
||||
.body(body.to_string())
|
||||
.send()
|
||||
};
|
||||
gw.engine.studio_down.store(true, Ordering::SeqCst);
|
||||
let resp = sprechen(json!({"model": "sprecher", "input": "Hallo", "voice": "Ryan"}))
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(resp.status(), 503);
|
||||
let json: Value = serde_json::from_str(&resp.text().await.unwrap()).unwrap();
|
||||
assert!(
|
||||
json["error"]["message"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.contains("nicht erreichbar"),
|
||||
"{json}"
|
||||
);
|
||||
// Läuft das Studio, aber die Stimme ist unbekannt, bleibt es bei 403, jetzt mit Text als JSON.
|
||||
gw.engine.studio_down.store(false, Ordering::SeqCst);
|
||||
let resp = sprechen(json!({"model": "sprecher", "input": "Hallo", "voice": "Unbekannt"}))
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(resp.status(), 403);
|
||||
let json: Value = serde_json::from_str(&resp.text().await.unwrap()).unwrap();
|
||||
assert!(
|
||||
json["error"]["message"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.contains("nicht freigegeben"),
|
||||
"{json}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn playground_liest_vor_nur_mit_sprachmodell_und_sitzung() {
|
||||
let gw = gateway(0, false).await;
|
||||
|
||||
Reference in New Issue
Block a user