story-kit: queue 101_story_test_coverage_http_chat_rs_to_80 for merge

This commit is contained in:
Dave
2026-02-23 22:00:33 +00:00
parent f45bc13522
commit a759a59a46
5 changed files with 92 additions and 0 deletions

View File

@@ -140,4 +140,56 @@ mod tests {
let val = store2.get(EDITOR_COMMAND_KEY);
assert_eq!(val, Some(json!("zed")));
}
#[tokio::test]
async fn get_editor_http_handler_returns_null_when_not_set() {
let dir = TempDir::new().unwrap();
let ctx = test_ctx(&dir);
let api = SettingsApi {
ctx: Arc::new(ctx),
};
let result = api.get_editor().await.unwrap().0;
assert!(result.editor_command.is_none());
}
#[tokio::test]
async fn set_editor_http_handler_stores_value() {
let dir = TempDir::new().unwrap();
let ctx = test_ctx(&dir);
let api = SettingsApi {
ctx: Arc::new(ctx),
};
let result = api
.set_editor(Json(EditorCommandPayload {
editor_command: Some("zed".to_string()),
}))
.await
.unwrap()
.0;
assert_eq!(result.editor_command, Some("zed".to_string()));
}
#[tokio::test]
async fn set_editor_http_handler_clears_value_when_null() {
let dir = TempDir::new().unwrap();
let ctx = test_ctx(&dir);
let api = SettingsApi {
ctx: Arc::new(ctx),
};
// First set a value
api.set_editor(Json(EditorCommandPayload {
editor_command: Some("code".to_string()),
}))
.await
.unwrap();
// Now clear it
let result = api
.set_editor(Json(EditorCommandPayload {
editor_command: None,
}))
.await
.unwrap()
.0;
assert!(result.editor_command.is_none());
}
}