fix tests

This commit is contained in:
Felix Ableitner 2024-02-01 16:51:38 +01:00
parent f2180e5e0b
commit dbd8e931a4
4 changed files with 13 additions and 7 deletions

View File

@ -7,7 +7,7 @@ IBIS_BACKEND_PORT="${IBIS_BACKEND_PORT:-8081}"
# https://stackoverflow.com/a/52033580
(trap 'kill 0' SIGINT;
# start frontend
trunk serve -w src/frontend/ --proxy-backend http://127.0.0.1:$IBIS_BACKEND_PORT &
CARGO_TARGET_DIR=target/frontend trunk serve -w src/frontend/ --proxy-backend http://127.0.0.1:$IBIS_BACKEND_PORT &
# # start backend, with separate target folder to avoid rebuilds from arch change
CARGO_TARGET_DIR=target/backend cargo watch -x run
cargo watch -x run
)

View File

@ -216,9 +216,15 @@ pub(in crate::backend::api) async fn fork_article(
pub(super) async fn resolve_article(
Query(query): Query<ResolveObject>,
data: Data<MyDataHandle>,
) -> MyResult<Json<DbArticle>> {
let article = ObjectId::from(query.id).dereference(&data).await?;
Ok(Json(article))
) -> MyResult<Json<ArticleView>> {
let article: DbArticle = ObjectId::from(query.id).dereference(&data).await?;
let edits = DbEdit::read_for_article(&article, &data.db_connection)?;
let latest_version = edits.last().unwrap().hash.clone();
Ok(Json(ArticleView {
article,
edits,
latest_version,
}))
}
/// Search articles for matching title or body text.

View File

@ -156,7 +156,7 @@ impl ApiClient {
Ok(handle_json_res(req).await.unwrap())
}
pub async fn resolve_article(&self, id: Url) -> MyResult<DbArticle> {
pub async fn resolve_article(&self, id: Url) -> MyResult<ArticleView> {
let resolve_object = ResolveObject { id };
self.get_query("article/resolve", Some(resolve_object))
.await

View File

@ -31,7 +31,7 @@ pub fn Search() -> impl IntoView {
join!(search, resolve_article, resolve_instance);
search_results.instance = resolve_instance.ok();
if let Ok(article) = resolve_article {
search_results.articles.push(article);
search_results.articles.push(article.article);
}
search_results.articles.append(&mut search.unwrap())
} else {