folder tree

This commit is contained in:
2025-11-06 00:51:38 +01:00
parent 911051e75d
commit 4027ac66cb
5 changed files with 300 additions and 37 deletions
+75
View File
@@ -605,6 +605,81 @@ async fn upload_skips_existing_when_requested() -> Result<()> {
Ok(())
}
#[tokio::test]
async fn filter_documents_without_tags() -> Result<()> {
let _lock = acquire_db_lock().await;
let app = TestApp::new().await?;
let password = "tagfilter";
app.insert_user("tagfilter", password, "admin").await?;
let token = app.login_token("tagfilter", password).await?;
// Create a tag and upload a document that uses it.
let tag_payload = CreateTagPayload {
label: "with-tag",
color: None,
};
let tag_resp = app
.post_json("/api/tags", &tag_payload, Some(&token))
.await?;
assert!(tag_resp.status().is_success());
let tag_body = body_to_vec(tag_resp.into_body()).await?;
let tag: TagResponse = serde_json::from_slice(&tag_body)?;
let tag_json = format!("[\"{}\"]", tag.id);
let tagged_upload = app
.upload_document_with_extras(
"/api/documents",
"with-tag.txt",
"text/plain",
b"tagged",
None,
UploadExtras {
title: Some("With Tag"),
metadata_json: None,
tag_ids_json: Some(tag_json.as_str()),
correspondents_json: None,
issued_at: None,
skip_existing: None,
},
&token,
)
.await?;
assert!(tagged_upload.status().is_success());
let untagged_upload = app
.upload_document(
"/api/documents",
"without-tag.txt",
"text/plain",
b"untagged",
None,
&token,
)
.await?;
assert!(untagged_upload.status().is_success());
let untagged_body = body_to_vec(untagged_upload.into_body()).await?;
let untagged_detail: DocumentDetail = serde_json::from_slice(&untagged_body)?;
// Sanity: both documents appear in the default listing.
let all_resp = app.get("/api/documents", Some(&token)).await?;
assert_eq!(all_resp.status(), StatusCode::OK);
let all_body = body_to_vec(all_resp.into_body()).await?;
let all_docs: Vec<DocumentListItem> = serde_json::from_slice(&all_body)?;
assert_eq!(all_docs.len(), 2);
// Filter for documents without tags.
let none_resp = app.get("/api/documents?tags=none", Some(&token)).await?;
assert_eq!(none_resp.status(), StatusCode::OK);
let none_body = body_to_vec(none_resp.into_body()).await?;
let none_docs: Vec<DocumentListItem> = serde_json::from_slice(&none_body)?;
assert_eq!(none_docs.len(), 1);
assert_eq!(none_docs[0].id, untagged_detail.document.id);
app.cleanup().await?;
Ok(())
}
#[tokio::test]
async fn bulk_move_documents_to_folder() -> Result<()> {
let _lock = acquire_db_lock().await;