//! WHERE THE OWNER'S "MAKE THIS MAC A RUNNER" STANDS — the held act's two //! steps, as the two typed columns the device page draws (`runner_confirm`, //! `runner_drop`). Values only; the definition says the words. /// The two steps' values for one device row: `None` when no order stands /// and the device is no runner (nothing to show). /// /// - `runner_confirm`: `waiting` (ordered, the serving Mac has not answered /// since), `short` (it answered that something is still owed), /// `confirmed` (it holds everything); /// - `runner_drop`: `waiting` until the Mac is a runner, `done` after. #[must_use] pub fn steps( scope: Option<&str>, ordered_at: Option<&str>, confirmed_at: Option<&str>, problem: Option<&str>, ) -> Option<(&'static str, &'static str)> { if scope == Some("runner") { return Some(("confirmed", "done")); } let ordered = ordered_at?; let confirm = if problem.is_some() { "short" } else if confirmed_at.is_some_and(|at| at >= ordered) { "confirmed" } else { "waiting" }; Some((confirm, "waiting")) } #[cfg(test)] mod tests { use super::steps; /// RULE: A step reads confirmed only on the serving Mac's answer at or after the owner's order, and done only once the row is a runner — an old confirmation never stands for a new order. #[test] fn the_steps_follow_the_order_and_the_answer() { assert_eq!(steps(Some("full"), None, None, None), None); let order = Some("2026-10-14T07:00:00.000Z"); assert_eq!(steps(Some("full"), order, None, None), Some(("waiting", "waiting"))); assert_eq!(steps(Some("full"), order, Some("2026-10-13T07:00:00.000Z"), None), Some(("waiting", "waiting"))); assert_eq!(steps(Some("full"), order, Some("2026-10-14T07:05:00.000Z"), None), Some(("confirmed", "waiting"))); assert_eq!(steps(Some("full"), order, None, Some("[]")), Some(("short", "waiting"))); assert_eq!(steps(Some("runner"), None, None, None), Some(("confirmed", "done"))); } }