diff --git a/backend/src/services/email.rs b/backend/src/services/email.rs
index 77c830d..5e85d66 100644
--- a/backend/src/services/email.rs
+++ b/backend/src/services/email.rs
@@ -138,6 +138,10 @@ fn html_escape(s: &str) -> String {
pub fn build_synthesis_html(week: &str, date: &str, sections: &[NewsSection]) -> String {
let mut items_html = String::new();
+ if sections.is_empty() {
+ items_html.push_str("
Aucune section trouvee dans cette synthese.
");
+ }
+
for section in sections {
items_html.push_str(&format!(
r#"|
@@ -204,6 +208,10 @@ pub fn build_synthesis_text(week: &str, date: &str, sections: &[NewsSection]) ->
text.push_str(&"=".repeat(50));
text.push('\n');
+ if sections.is_empty() {
+ text.push_str("\nAucune section trouvee dans cette synthese.\n");
+ }
+
for section in sections {
text.push_str(&format!("\n{}\n", section.title.to_uppercase()));
text.push_str(&"-".repeat(section.title.len()));
@@ -353,4 +361,16 @@ mod tests {
assert!(text.contains("Generee le 2026-03-21"));
assert!(text.contains("Genere par AI Weekly Synth"));
}
+
+ #[test]
+ fn test_synthesis_html_empty_sections_shows_fallback() {
+ let html = build_synthesis_html("2026-W12", "21 mars 2026", &[]);
+ assert!(html.contains("Aucune section trouvee"));
+ }
+
+ #[test]
+ fn test_synthesis_text_empty_sections_shows_fallback() {
+ let text = build_synthesis_text("2026-W12", "21 mars 2026", &[]);
+ assert!(text.contains("Aucune section trouvee"));
+ }
}
|