Files
chandra/compositor/host/inspector_test.mbt
T
Claude c7a6c8376e
CI / test (push) Failing after 18s
Merge the 12-hour clock into the Digital Clock
clock-digital12 and clock-digital had become the same module (same lib/clock
code, same right-click settings), differing only in the starting format. Keep
one: the Digital Clock now starts in 12-hour mode with AM/PM, and its
"Time format" setting switches to 24-hour.

- components/clock-digital12 is gone (and from scripts/components.txt);
  lib/clock drops digital12_info/digital12_config.
- The default panel loads clock-digital.
- "clock-digital12" stays an alias (find_module, slot_of, saved panels) and is
  never listed in the module picker, even if an old .wasm is still installed.
- panel.edn gets :version 2. A version-1 panel is migrated once: the old
  12-hour clock becomes the Digital Clock with its settings (state.edn
  :module-config) moved over in 12-hour mode; a panel that had the old
  24-hour Digital Clock keeps 24-hour. The file is rewritten afterwards.
- Tests updated, plus a migration test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgnZsS91fwCreut8FL
2026-11-25 20:29:12 +00:00

59 lines
2.5 KiB
MoonBit

///| Interface Explorer: toggle from the panel, hover components, see their WIT.
///|
test "inspector shows the WIT interface of the hovered component" {
let socket_path = "/tmp/wayland-moon-inspect-" +
@sys.getpid().to_string() +
".sock"
let theme = @scene.ThemeTokens::moon_night()
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
let (c, shm, surf, xdg, _tl, _deco) = open_and_configure_client(
comp, socket_path, "T", "t",
)
commit_shm_frame(comp, c, shm, surf, xdg, 1UL)
ignore(comp.compose_frame()) // lays out the panel
assert_false(comp.shell.inspecting())
// Open the apps popup first; turning the explorer on must not close it.
let (lx, ly) = center_of(comp, "launcher")
click_at(comp, lx.to_int(), ly.to_int(), 0U)
assert_true(comp.shell.popup_open())
// Click the Interface Explorer button to turn inspect mode on.
let (bx, by) = center_of(comp, "inspector")
click_at(comp, bx.to_int(), by.to_int(), 1U)
assert_true(comp.shell.inspecting())
assert_true(comp.shell.popup_open())
assert_eq(comp.desired_cursor(), 4U)
// Hover the launcher.
let (lx, ly) = center_of(comp, "launcher")
comp.handle_input(@nested.InputEvent::PointerMove(lx, ly), 4U)
let lslot = comp.shell.slot_of("launcher")
assert_eq(comp.shell.hover_id, lslot)
assert_eq(comp.desired_cursor(), 3U)
// The explorer describes the module's real binary: what it exports and which capabilities it imports.
let lines = comp.shell.inspector_lines_for(lslot)
assert_true(lines.iter().any(l => l.has_prefix("# plasmoid")))
assert_true(lines.iter().any(l => l.has_prefix("# app launch")))
assert_true(lines.iter().any(l => l.has_prefix("# app catalog")))
let frame = comp.compose_frame()
let png = @renderer.encode_png(frame)
ignore(@sys.write_file_bytes("_build/inspector_launcher.png", png))
// Clock, panel, window title bar and desktop resolve to their own components.
let (cx, cy) = center_of(comp, "clock-digital")
comp.handle_input(@nested.InputEvent::PointerMove(cx, cy), 5U)
assert_eq(comp.shell.hover_id, comp.shell.slot_of("clock-digital"))
comp.handle_input(@nested.InputEvent::PointerMove(1270.0, 5.0), 6U)
assert_eq(comp.shell.hover_id, "desktop")
// Clicks are swallowed while inspecting; Escape leaves the mode.
comp.handle_input(@nested.InputEvent::PointerButton(0x110U, true), 7U)
assert_true(comp.shell.popup_open()) // unchanged: the click was swallowed
comp.handle_input(@nested.InputEvent::Key(1U, true), 8U)
assert_false(comp.shell.inspecting())
comp.close()
}