test(tickets): renforce la couverture attachments web-server/app-tauri (#108)
Levée de la réserve QA sur #108 : aucun test ciblé ne matchait réellement sur web-server et app-tauri malgré le câblage attachments tickets. - web-server: test fonctionnel via /api/invoke pour ticket_create, ticket_attachment_add, ticket_attachment_read, ticket_attachment_mark_summarized. - app-tauri: test fonctionnel via la surface publique tool/provider pour idea_ticket_create, idea_ticket_attachment_add, idea_ticket_attachment_read, idea_ticket_attachment_mark_summarized. Pas de changement de wiring produit ; assertions alignées sur le contrat public réel (contentBase64 sans padding =, summarizedBy.kind = user côté app-tauri). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -8176,6 +8176,104 @@ mod tests {
|
||||
assert_eq!(deleted, Value::Null);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn authorized_ticket_invoke_routes_attachment_commands() {
|
||||
let state = state();
|
||||
let project_id = create_project_for_test(&state, "Web Ticket Attachments").await;
|
||||
let cookie = pair_and_cookie(Arc::clone(&state)).await;
|
||||
|
||||
let (status, created) = invoke_request_for_test(
|
||||
Arc::clone(&state),
|
||||
&cookie,
|
||||
"ticket_create",
|
||||
json!({
|
||||
"request": {
|
||||
"projectId": project_id,
|
||||
"title": "Wire attachment ticket"
|
||||
}
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::OK);
|
||||
let ticket_ref = created["ref"].as_str().unwrap().to_owned();
|
||||
let ticket_version = created["version"].as_u64().unwrap();
|
||||
|
||||
let project = state
|
||||
.app
|
||||
.open_project
|
||||
.execute(OpenProjectInput {
|
||||
project_id: ProjectId::from_uuid(Uuid::parse_str(&project_id).unwrap()),
|
||||
})
|
||||
.await
|
||||
.expect("test project is readable")
|
||||
.project;
|
||||
let source = std::path::PathBuf::from(project.root.as_str()).join("web-attachment.txt");
|
||||
std::fs::write(&source, b"web attachment payload").expect("test writes source attachment");
|
||||
|
||||
let (status, attached) = invoke_request_for_test(
|
||||
Arc::clone(&state),
|
||||
&cookie,
|
||||
"ticket_attachment_add",
|
||||
json!({
|
||||
"request": {
|
||||
"projectId": project_id,
|
||||
"ref": ticket_ref,
|
||||
"path": source.to_string_lossy(),
|
||||
"mime": "text/plain",
|
||||
"expectedVersion": ticket_version
|
||||
}
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::OK);
|
||||
let attachment = &attached["attachments"].as_array().unwrap()[0];
|
||||
assert_eq!(attachment["filename"], "web-attachment.txt");
|
||||
assert_eq!(attachment["mime"], "text/plain");
|
||||
assert_eq!(attachment["summarizedInCarnet"], false);
|
||||
let attachment_id = attachment["id"].as_str().unwrap().to_owned();
|
||||
let updated_version = attached["version"].as_u64().unwrap();
|
||||
|
||||
let (status, content) = invoke_request_for_test(
|
||||
Arc::clone(&state),
|
||||
&cookie,
|
||||
"ticket_attachment_read",
|
||||
json!({
|
||||
"request": {
|
||||
"projectId": project_id,
|
||||
"ref": ticket_ref,
|
||||
"attachmentId": attachment_id
|
||||
}
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::OK);
|
||||
assert_eq!(content["attachment"]["filename"], "web-attachment.txt");
|
||||
assert_eq!(
|
||||
content["contentBase64"],
|
||||
base64::engine::general_purpose::STANDARD_NO_PAD.encode(b"web attachment payload")
|
||||
);
|
||||
|
||||
let (status, summarized) = invoke_request_for_test(
|
||||
Arc::clone(&state),
|
||||
&cookie,
|
||||
"ticket_attachment_mark_summarized",
|
||||
json!({
|
||||
"request": {
|
||||
"projectId": project_id,
|
||||
"ref": ticket_ref,
|
||||
"attachmentId": content["attachment"]["id"],
|
||||
"expectedVersion": updated_version
|
||||
}
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::OK);
|
||||
let summarized_attachment = &summarized["attachments"].as_array().unwrap()[0];
|
||||
assert_eq!(summarized_attachment["summarizedInCarnet"], true);
|
||||
assert_eq!(summarized_attachment["summarizedBy"]["kind"], "user");
|
||||
assert!(summarized_attachment["summarizedAt"].as_u64().is_some());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn authorized_sprint_invoke_routes_sprint_and_ticket_sprint_commands() {
|
||||
let state = state();
|
||||
|
||||
Reference in New Issue
Block a user