forked from yvv/decision
Lot S : tests serveur repris sans Propositions seed en vigueur (modules, overview), rustfmt
modules.rs : 0 article en vigueur et 35 propositions en cours dans une base neuve (I1, E1 et E2 sont des Propositions seed) ; l'ajout des modules à une base existante se rejoue sur le seed de production du 02/11 (textes en vigueur), comme inertia.rs. overview.rs : le vote porte sur la Proposition seed I1 ; 41 modules à voter, inchangé. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,9 +183,10 @@ async fn a_new_base_has_its_title_and_the_order_of_each_section() {
|
||||
let id = doc["doc"]["id"].as_str().expect("id");
|
||||
let all = c.ok("GET", &format!("/api/docs/{id}/preview?mode=all"), None).await;
|
||||
assert_eq!(all["units"].as_array().expect("units").len(), 33);
|
||||
// The list of the group: the articles in force; no module has an open proposal yet.
|
||||
// The list of the group: the articles in force — none, I1, E1 and E2 are seed proposals
|
||||
// (ADR 0011), three more open versions —; no module has an open proposal yet.
|
||||
let g = c.ok("GET", "/api/groups/monnaie-libre", None).await;
|
||||
assert_eq!((g["docs"][0]["inForce"].as_u64(), g["docs"][0]["open"].as_u64()), (Some(3), Some(32)));
|
||||
assert_eq!((g["docs"][0]["inForce"].as_u64(), g["docs"][0]["open"].as_u64()), (Some(0), Some(35)));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -250,7 +251,8 @@ async fn articles_that_enter_or_leave_a_section_complete_an_order_under_vote() {
|
||||
.expect("id")
|
||||
.to_owned();
|
||||
yvv.vote(&p, "for").await;
|
||||
// The list of the group counts it among the proposals in progress, never among the articles.
|
||||
// The list of the group counts it among the proposals in progress, never among the articles
|
||||
// (none in force: I1, E1 and E2 are seed proposals, ADR 0011).
|
||||
let g = yvv.ok("GET", "/api/groups/essai", None).await;
|
||||
let before = doc["units"]
|
||||
.as_array()
|
||||
@@ -259,7 +261,7 @@ async fn articles_that_enter_or_leave_a_section_complete_an_order_under_vote() {
|
||||
.map(|u| u["proposals"].as_array().expect("p").iter().filter(|x| x["status"] == "open").count() as u64);
|
||||
assert_eq!(
|
||||
(g["docs"][0]["inForce"].as_u64(), g["docs"][0]["open"].as_u64()),
|
||||
(Some(3), Some(before.sum::<u64>() + 1))
|
||||
(Some(0), Some(before.sum::<u64>() + 1))
|
||||
);
|
||||
// A new article enters the section: at its end, and at the end of the order under vote.
|
||||
let created = chiara
|
||||
@@ -492,8 +494,17 @@ async fn a_new_article_goes_at_the_end_of_the_section_asked_for() {
|
||||
// A base born without modules, as production holds it, then the new version
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// The seed production runs on 2026-11-02 (3f10a0e): I1, E1 and E2 in force, seeds a
|
||||
/// minima. Since that day the seed puts them forward as seed proposals (ADR 0011,
|
||||
/// tests/seed_proposals.rs); the addition of the modules is replayed on the seed of then.
|
||||
fn production_config() -> Config {
|
||||
let mut cfg = Config::for_tests();
|
||||
cfg.seed_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/seed-production-2026-11-02");
|
||||
cfg
|
||||
}
|
||||
|
||||
fn seed_without_modules(tag: &str) -> std::path::PathBuf {
|
||||
let today = Config::for_tests().seed_dir.join("acte-engagement-certification.json");
|
||||
let today = production_config().seed_dir.join("acte-engagement-certification.json");
|
||||
let mut seed: Value = serde_json::from_str(&std::fs::read_to_string(today).expect("seed")).expect("json");
|
||||
seed.as_object_mut().expect("object").remove("modules");
|
||||
let dir = std::env::temp_dir().join(format!("ld-modules-seed-{tag}-{}", std::process::id()));
|
||||
@@ -554,7 +565,7 @@ async fn an_existing_document_receives_its_modules_once_from_what_it_holds() {
|
||||
let reads = read_order(&c.doc("essai").await, "conclusion");
|
||||
|
||||
// The new version starts: each document receives its modules, from what it holds.
|
||||
let state = AppState::new(Config::for_tests(), before.db.clone()).await.expect("state");
|
||||
let state = AppState::new(production_config(), before.db.clone()).await.expect("state");
|
||||
seed::ensure(&state).await.expect("seed");
|
||||
let rows: Vec<(String, String, Option<String>, Option<String>)> = sqlx::query_as(
|
||||
"SELECT d.group_slug, m.outcome, m.reason, m.created FROM module_amendments m JOIN documents d ON d.id = m.doc_id
|
||||
@@ -619,7 +630,7 @@ async fn an_existing_document_receives_its_modules_once_from_what_it_holds() {
|
||||
assert_eq!(json["modules"]["orders"][1]["articles"], json!(["T1", "E1", "E2"]));
|
||||
|
||||
// Once only: the next start adds nothing.
|
||||
let again = AppState::new(Config::for_tests(), state.db.clone()).await.expect("state");
|
||||
let again = AppState::new(production_config(), state.db.clone()).await.expect("state");
|
||||
seed::ensure(&again).await.expect("seed");
|
||||
let n: i64 =
|
||||
sqlx::query_scalar("SELECT COUNT(*) FROM units WHERE kind <> 'article'").fetch_one(&again.db).await.expect("n");
|
||||
|
||||
Reference in New Issue
Block a user