Project · a roadmap bar's end and a workload bar's cap, tested
A roadmap bar ran through its last day, but no test looked at its end: a bar stopping at the last day's start stayed green. The roadmap test now asserts October's bar reaches the span's end. The workload bar's share, capped at the whole track, moves into Load::filled with a unit test, so a load past capacity cannot draw past its track unseen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
75f00883ac
commit
28973fe1d2
3 files changed
+26
-1
No files matched your search
@@ -366,3 +366,4 @@ Per-component lines live in `tasks/`. Tags there:
|
||||
| T31a | 1 | PASS | |
|
||||
| T31b | 1 | FAIL | a focused card past the board's fold stayed out of view; left and right steps that keep a card's place went untested |
|
||||
| T31b | 2 | PASS | |
|
||||
| T31c | 1 | FAIL | a roadmap bar's end and the workload bar's cap went untested |
|
||||
@@ -223,4 +223,9 @@ fn a_roadmap_draws_only_what_falls_in_its_months(cx: &mut TestAppContext) {
|
||||
(share - 30.0 / 61.0).abs() < 0.01,
|
||||
"October starts 30 of 61 days in: {share}"
|
||||
);
|
||||
let end = (half.right() - map.left()) / map.size.width;
|
||||
assert!(
|
||||
(end - 1.0).abs() < 0.01,
|
||||
"October runs through its last day: {end}"
|
||||
);
|
||||
}
|
||||
+20
-1
@@ -41,6 +41,11 @@ impl Load {
|
||||
pub fn over(&self) -> bool {
|
||||
self.assigned > self.capacity
|
||||
}
|
||||
|
||||
/// The share of the track the bar fills, whole at capacity and past it.
|
||||
pub(crate) fn filled(&self) -> f32 {
|
||||
(self.assigned / self.capacity).min(1.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Who carries how much: each person with a bar of their work against what they can take, red past it, and the two counts.
|
||||
@@ -84,7 +89,7 @@ impl RenderOnce for WorkloadView {
|
||||
} else {
|
||||
colors.hue(0, "workload")
|
||||
};
|
||||
let share = (load.assigned / load.capacity).min(1.0);
|
||||
let share = load.filled();
|
||||
let count = format!("{:.0} / {:.0} {}", load.assigned, load.capacity, self.unit);
|
||||
let key = load.person.key.clone();
|
||||
div()
|
||||
@@ -150,3 +155,17 @@ impl RenderOnce for WorkloadView {
|
||||
.children(rows.collect::<Vec<_>>())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Load;
|
||||
use crate::project::Person;
|
||||
|
||||
#[test]
|
||||
fn a_bar_fills_its_share_and_stops_at_capacity() {
|
||||
let ana = Person::new("ana", "Ana Lima");
|
||||
assert_eq!(Load::new(ana.clone(), 190.0, 168.0).filled(), 1.0);
|
||||
assert_eq!(Load::new(ana.clone(), 7.0, 10.0).filled(), 0.7);
|
||||
assert!(Load::new(ana, 11.0, 10.0).over());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user