use crate::channels::slack::final_body::{folded_paragraphs, strip_folded_notes};
#[test]
fn a_note_cut_mid_word_is_still_matched() {
let folded = folded_paragraphs(Some("You're right, and it's the s".to_string()));
let body = "You're right, and it's the s\n\nharper version of the point.\n\n\
I knew the delivery mechanism was a read-only bind mount.";
let out = strip_folded_notes(body, &folded);
assert!(
out.starts_with("harper version of the point."),
"mid-word split was not consumed: {out:?}"
);
assert!(!out.contains("You're right"), "narration survived: {out:?}");
}
#[test]
fn narration_the_group_already_shows_is_dropped() {
let folded = folded_paragraphs(Some(
"Let me verify each claim against the host.\n\n\
Two discrepancies already. Let me dig before drawing conclusions.\n\n\
Root cause confirmed. Let me measure the blast radius."
.to_string(),
));
assert_eq!(folded.len(), 3);
let body = "Let me verify each claim against the host.\n\n\
Two discrepancies already. Let me dig before drawing conclusions.\n\n\
Root cause confirmed. Let me measure the blast radius.\n\n\
The service is in a restart loop.";
let out = strip_folded_notes(body, &folded);
assert_eq!(out, "The service is in a restart loop.");
}
#[test]
fn whitespace_differences_do_not_defeat_the_match() {
let folded = folded_paragraphs(Some("Checking the\nsocket now.".to_string()));
let body = "Checking the socket now.\n\nThe socket is absent.";
assert_eq!(strip_folded_notes(body, &folded), "The socket is absent.");
}
#[test]
fn a_body_with_no_folded_notes_is_untouched() {
let body = "Done. The socket line is added and the loop has stopped.";
assert_eq!(strip_folded_notes(body, &[]), body);
assert_eq!(strip_folded_notes(body, &folded_paragraphs(None)), body);
}
#[test]
fn a_body_that_does_not_start_with_the_narration_is_untouched() {
let folded = folded_paragraphs(Some("Checking the scan log.".to_string()));
let body = "The log holds zero verdicts since boot.";
assert_eq!(strip_folded_notes(body, &folded), body);
}
#[test]
fn consumption_stops_at_the_first_divergence() {
let folded = vec![
"First note.".to_string(),
"A note the final never repeats.".to_string(),
"Third note.".to_string(),
];
let body = "First note.\n\nThird note.\n\nThe answer.";
let out = strip_folded_notes(body, &folded);
assert_eq!(
out, "Third note.\n\nThe answer.",
"divergence must halt consumption rather than skip ahead"
);
}
#[test]
fn a_body_that_is_entirely_narration_yields_empty() {
let folded = folded_paragraphs(Some("Checking.\n\nStill checking.".to_string()));
let body = "Checking.\n\nStill checking.";
assert!(strip_folded_notes(body, &folded).trim().is_empty());
}
#[test]
fn prose_the_group_never_folded_survives() {
let folded = folded_paragraphs(Some("Checking the socket now.".to_string()));
let body = "Checking the socket now.\n\n\
Let me be clear about what I did not verify: the staging box.";
let out = strip_folded_notes(body, &folded);
assert_eq!(
out,
"Let me be clear about what I did not verify: the staging box."
);
}