Dashboard: a focused tile's Left and Right, and a control's own arrows, tested

The arrows test also moves a focused tile right and back; a new test
focuses a button inside a card and shows its arrows leave the tiles.
A card given for a key with no tile fails loud, in both layouts.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-27 12:08:44 -04:00
1 parent 9fddf4b6bf
commit 15e34fcb35
3 files changed
+43 -4

No files matched your search

+1
View File
@@ -395,3 +395,4 @@ Per-component lines live in `tasks/`. Tags there:
| T33c | 3 | PASS | |
| T33d | 1 | FAIL | text fields never painted a highlight's wash; a tile's value ran past 280px; a stray + read as a hex digit; the WCAG thresholds, an exit's badge, a stopped row's load and the meter's clamp untested |
| T33d | 2 | PASS | |
| T34 | 1 | FAIL | a focused tile's Left and Right, and the guard that leaves arrows to a focused control inside a card, untested |
+10
View File
@@ -137,6 +137,11 @@ fn stacked(
.child(card)
})
.collect();
assert!(
cards.is_empty(),
"dashboard grid: cards with no tile: {:?}",
cards.iter().map(|(key, _)| key).collect::<Vec<_>>()
);
div()
.id(id)
.relative()
@@ -293,6 +298,11 @@ impl RenderOnce for DashboardGrid {
.into_any_element()
})
.collect();
assert!(
cards.is_empty(),
"dashboard grid: cards with no tile: {:?}",
cards.iter().map(|(key, _)| key).collect::<Vec<_>>()
);
let ghost = landing.as_ref().map(|tile| {
div()
.absolute()
+32 -4
View File
@@ -1,6 +1,6 @@
use gpui::{
AnyElement, App, Context, Entity, IntoElement, KeyBinding, ParentElement, Render, Styled,
TestAppContext, VisualTestContext, Window, div, px,
AnyElement, App, Context, Entity, FocusHandle, IntoElement, KeyBinding, ParentElement, Render,
Styled, TestAppContext, VisualTestContext, Window, div, px,
};
use super::{
@@ -8,6 +8,7 @@ use super::{
EventStream, MonitorAlert, StreamEvent, Tile, TimeWindow,
};
use crate::{
buttons::Button,
data_display::Tone,
forms::Choice,
primitives::{FocusNext, Severity},
@@ -19,6 +20,7 @@ struct Wall {
tiles: Vec<Tile>,
heard: Vec<Vec<Tile>>,
width: f32,
inside: FocusHandle,
}
impl Render for Wall {
@@ -32,7 +34,14 @@ impl Render for Wall {
cx.notify();
})
}),
|grid, tile| grid.card(tile.key.clone(), DashboardCard::new(tile.key.clone())),
|grid, tile| {
let card = DashboardCard::new(tile.key.clone());
let card = match tile.key.as_ref() {
"b" => card.body(Button::new("inside", "Inside").focus_handle(&self.inside)),
_ => card,
};
grid.card(tile.key.clone(), card)
},
);
div().w(px(self.width)).child(grid)
}
@@ -52,7 +61,7 @@ fn wall(cx: &mut TestAppContext) -> (Entity<Wall>, &mut VisualTestContext) {
Theme::update(cx, |theme| theme.reduced_motion = true);
cx.bind_keys([KeyBinding::new("tab", FocusNext, None)]);
});
let (host, cx) = cx.add_window_view(|_, _| Wall {
let (host, cx) = cx.add_window_view(|_, cx| Wall {
tiles: vec![
Tile::new("a", (0, 0), (6, 2)),
Tile::new("b", (6, 0), (6, 2)),
@@ -60,6 +69,7 @@ fn wall(cx: &mut TestAppContext) -> (Entity<Wall>, &mut VisualTestContext) {
],
heard: Vec::new(),
width: 1200.0,
inside: cx.focus_handle(),
});
settle(cx);
(host, cx)
@@ -95,6 +105,24 @@ fn arrows_step_a_focused_tile_past_its_neighbours_and_shift_grows_it(cx: &mut Te
assert_eq!(place(&host, "a", cx), (0, 0, 7, 2), "a grew a column");
assert_eq!(place(&host, "b", cx), (6, 2, 6, 2), "pushing b below it");
assert_eq!(place(&host, "c", cx), (0, 4, 12, 2), "and c below b");
press("right", cx);
assert_eq!(place(&host, "a", cx).0, 1, "Right moves a column over");
press("left", cx);
assert_eq!(place(&host, "a", cx).0, 0, "and Left back");
}
#[gpui::test]
fn arrows_in_a_control_inside_a_card_leave_the_tiles_where_they_are(cx: &mut TestAppContext) {
let (host, cx) = wall(cx);
let inside = host.read_with(cx, |wall, _| wall.inside.clone());
cx.update(|window, _| window.focus(&inside));
settle(cx);
press("right", cx);
press("down", cx);
assert!(
host.read_with(cx, |wall, _| wall.heard.is_empty()),
"the button keeps its keys"
);
}
type Part = fn(&Board, Entity<Board>) -> AnyElement;