╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
40 // holds the sub-header then the list/diff split, whose first child is the 41 // list scroll. 42 const content = &view.box.children.values()[1].widget.box; 43 const lb = &content.children.values()[0].widget.scroll.child.box; 44 const next_id = lb.children.keys()[lb.children.count() - 1]; 45 46 const route = ui.crossPageLink(root_focus, next_id, session.data); 47 try std.testing.expect(route != null); 48 } 49 50 // a ref name with a '/' is url-encoded in the route, so it survives the 51 // '/'-delimited url round-trip as a single segment (kind + value) rather than 52 // being mis-parsed as extra path. 53 test "encoded ref name survives the commits url round-trip" { 54 var arena = std.heap.ArenaAllocator.init(std.testing.allocator); 55 defer arena.deinit(); 56 const RP = ui.RoutablePage; 57 58 // the route layer holds the value already url-encoded ("feature%2Ffoo"). 59 const route = RP.repoCommitsRoute("alice/ziglings", .branch, "feature%2Ffoo", 0).?; 60 const url = try route.urlAlloc(&arena); 61 try std.testing.expectEqualStrings("/repo/alice/ziglings/commits/branch:feature%2Ffoo", url); 62 63 // parsing it back yields the same route, and the ref splits out intact. 64 const parsed = RP.fromUrl(url); 65 try std.testing.expect(parsed != null); 66 const ref = RP.repoCommitsRef(parsed.?.repo_commits.slice()); 67 try std.testing.expectEqual(RP.RefOrOid.branch, ref.ref_or_oid.?); 68 try std.testing.expectEqualStrings("feature%2Ffoo", ref.value); 69 } 70