Files
Marcos Paulo bc0b258e04 feat: engine and core crates: comment sidecars hidden and removed with the note, e2e comments test, extension tables, annotate text and arrow items
Sidecars (*.comments.json) stay out of the index and listings and follow rename and delete of their note; end-to-end comments test over a stub server (Ana comments and mentions Bob, Bob resolves, second sync changes nothing); viewer extension tables gain ico, ogv, 3gp, opus, aac; annotate crate: Edit::Replace for undoable text moves and edits, line items carry an arrow flag; syntax test fixed (TeX is a bundled grammar). Built by MiniMax M3.1 Flash and Claude Sonnet; verified with the full cargo xtask ci on the combined tree (4422 tests, clippy -D warnings, layers, tree, i18n).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 02:31:52 -03:00

51 lines
1.7 KiB
Rust

//! The sidecar that holds the comments of a note belongs to its note, not to
//! the user: the index never registers it, so it is neither a note nor an
//! attachment and never shows up in the search results.
use notescraft_index::{Index, is_comment_sidecar};
#[test]
fn a_comment_sidecar_is_not_an_attachment() {
let mut index = Index::new();
index.update_note("notes/Ideas.md", "# Ideas\n").unwrap();
index.add_file("notes/Ideas.md.comments.json").unwrap();
assert_eq!(index.files(), Vec::<&str>::new(), "the sidecar is not a file of the vault");
assert_eq!(index.node_ids(), vec!["notes/Ideas.md".to_owned()], "and not a node of the graph");
}
#[test]
fn a_comment_sidecar_is_never_a_note() {
let mut index = Index::new();
assert!(index.update_note("notes/Ideas.md.comments.json", "{}").is_err(), "a sidecar is not Markdown");
assert_eq!(index.notes(), Vec::<&str>::new());
}
#[test]
fn forgetting_a_sidecar_is_not_an_error() {
let mut index = Index::new();
index.add_file("notes/Ideas.md.comments.json").unwrap();
index.remove_file("notes/Ideas.md.comments.json").unwrap();
assert_eq!(index.files(), Vec::<&str>::new());
}
#[test]
fn the_other_files_of_the_vault_are_still_attachments() {
let mut index = Index::new();
index.add_file("notes/photo.png").unwrap();
index.add_file("notes/photo.png.annotations.json").unwrap();
assert_eq!(index.files(), vec!["notes/photo.png", "notes/photo.png.annotations.json"], "the sidecar of an image is a file of the vault");
}
#[test]
fn the_rule_answers_for_a_path() {
assert!(is_comment_sidecar("notes/Ideas.md.comments.json"));
assert!(!is_comment_sidecar("notes/Ideas.md"));
}