use crate::config::Config;
use crate::project::ProjectLayout;
use crate::store::hierarchy::Hierarchy;
use crate::store::node::NodeKind;
use crate::store::{InsertPosition, Store};
#[test]
#[ignore = "opens a real Store (embedding-model download) and uses the process-global active store; run locally with --ignored"]
fn bund_words_smoke_over_a_real_project() {
let tmp = tempfile::tempdir().expect("tempdir");
let cfg = Config::default();
let store = Store::open(ProjectLayout::new(tmp.path()), &cfg).expect("open store");
let h = Hierarchy::load(&store).unwrap();
let book = store
.create_node(&cfg, &h, NodeKind::Book, "Test Book", None, None, InsertPosition::End)
.unwrap();
let h = Hierarchy::load(&store).unwrap();
let chapter = store
.create_node(&cfg, &h, NodeKind::Chapter, "Chapter One", Some(&book), None, InsertPosition::End)
.unwrap();
let h = Hierarchy::load(&store).unwrap();
let mut para = store
.create_node(&cfg, &h, NodeKind::Paragraph, "Para One", Some(&chapter), None, InsertPosition::End)
.unwrap();
store
.update_paragraph_content(
&mut para,
b"= Para One\n\nThe harbor froze in January. Either it was a blessing or a curse.\n",
)
.unwrap();
let top_json = |code: &str| -> serde_json::Value {
let out = crate::scripting::eval(code).unwrap_or_else(|e| panic!("{code}: {e:#}"));
let top = out.top.unwrap_or_else(|| panic!("{code}: left no value on the stack"));
crate::scripting::value_to_json(&top)
};
let expect_list = |code: &str| {
assert!(top_json(code).is_array(), "{code} should push a list");
};
let expect_dict = |code: &str| {
assert!(top_json(code).is_object(), "{code} should push a dict");
};
let expect_string = |code: &str| {
assert!(top_json(code).is_string(), "{code} should push a string");
};
let runs = |code: &str| {
let _ = crate::scripting::eval(code);
};
expect_list("rigor.scan");
expect_list("\"Either you win or you lose, there is no middle ground.\" rigor.paragraph");
expect_list("cost.usage");
expect_list("wordnet.list");
expect_list("research.facts");
expect_list("research.undisputed");
expect_list("\"harbor\" 5 research.sources");
expect_list("locorum.build");
expect_list("locorum.malformed");
expect_list("verborum.build");
expect_list("doctor.scan");
expect_list("backup.list");
expect_list("planning.frameworks");
expect_list("\"three_act\" planning.beats");
expect_list("\"\" ink.words");
expect_dict("rigor.check");
expect_dict("goals.streak");
expect_dict("goals.snapshot");
expect_dict("cost.caps");
expect_dict("cost.today");
expect_dict("companions.findings");
expect_dict("companions.promotions");
expect_dict("companions.world");
expect_dict("companions.summary");
expect_dict("doctor.integrity");
expect_dict("doctor.vectors");
expect_string("research.report");
expect_string("\"md\" locorum.render");
expect_string("\"md\" verborum.render");
runs("\"00000000-0000-0000-0000-000000000000\" research.provenance");
runs("backup.last");
runs("\"cat\" \"en\" wordnet.lookup");
runs("\"cat\" \"en\" wordnet.suggest");
expect_list("\"harbor\" 9223372036854775807 research.sources");
runs("planning.check");
runs("planning.gaps");
}