╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1 const std = @import("std"); 2 const ui = @import("../ui.zig"); 3 const Commits = @import("../ui/Repo/Commits.zig"); 4 5 // the "next" row at the bottom of the commits list must be recognized as a 6 // cross-page link (so a click navigates), exactly like the diff pane's "next". 7 test "commits list next row is a cross-page link" { 8 const allocator = std.testing.allocator; 9 10 var arena = std.heap.ArenaAllocator.init(allocator); 11 defer arena.deinit(); 12 const identity = "alice/ziglings"; 13 const oid0 = "1111111111111111111111111111111111111111"; 14 const next_oid = "2222222222222222222222222222222222222222"; 15 16 const data = Commits{ 17 .identity = identity, 18 .ref_or_oid = .object, 19 .ref_or_oid_value = oid0, 20 .commits = &.{ 21 .{ .oid = oid0, .date = "2024-01-01", .message = "first", .hunks = &.{}, .window_start = 0, .has_prev = false, .has_more = false }, 22 }, 23 .next_start = next_oid, 24 }; 25 26 var session = ui.Session{ .arena = &arena, .page_arena = &arena, .is_terminal = true }; 27 session.data.current_page = ui.RoutablePage.repoCommitsRoute(identity, .object, oid0, 0).?; 28 29 var view = try Commits.View.init(allocator, &data, &session); 30 defer view.deinit(allocator); 31 32 const root_focus = view.getFocus(); 33 try view.build(allocator, .{ 34 .min_size = .{ .width = null, .height = null }, 35 .max_size = .{ .width = 120, .height = 60 }, 36 }, root_focus); 37 38 // the "next" row is the last child of the list box. 39 const lb = &view.box.children.values()[0].widget.scroll.child.box; 40 const next_id = lb.children.keys()[lb.children.count() - 1]; 41 42 const route = ui.crossPageLink(root_focus, next_id, session.data.current_page); 43 try std.testing.expect(route != null); 44 } 45