╭ changed ──────╮ │src/test/ui.zig│ ╰───────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 4 const Commits = @import("../ui/Repo/Commits.zig"); │ │ 5 const Events = @import("../ui/Repo/Events.zig"); │ │ 6 const xit = @import("xit"); │ │ 7 + │ │ 8 +test "preloaded thread forms receive typing after switching tabs" { │ │ 9 + const allocator = std.testing.allocator; │ │10 + var arena = std.heap.ArenaAllocator.init(allocator); │ │11 + defer arena.deinit(); │ │12 + var session = ui.Session{ .arena = &arena, .page_arena = &arena, .is_terminal = true, .data = .{ .host_kind = .local } }; │ │13 + session.data.current_page = ui.RoutablePage.repoIssuesRoute("", .open, "", "") orelse return error.BadRoute; │ │14 + const data = try ui.Repo.Issues.emptyResult(arena.allocator(), "", "", "", "", 0, "", .open); │ │15 + var root = ui.Widget{ .repo_issues = try ui.Repo.Issues.View.init(allocator, &data, &session) }; │ │16 + defer root.deinit(allocator); │ │17 + const focus = root.getFocus(); │ │18 + const constraint = xit.xitui.layout.Constraint{ │ │19 + .min_size = .{ .width = null, .height = null }, │ │20 + .max_size = .{ .width = 100, .height = 40 }, │ │21 + }; │ │22 + try root.build(allocator, constraint, focus); │ │23 + │ │24 + // switch to the preloaded new tab without recreating the page │ │25 + for ([_]xit.xitui.input.Key{ .arrow_right, .arrow_right, .arrow_right, .arrow_down }) |key| { │ │26 + try ui.inputKey(allocator, &root, key, &session); │ │27 + try root.build(allocator, constraint, focus); │ │28 + } │ │29 + for ([_][]const u8{ "title", "tags", "description" }) |name| { │ │30 + const input = session.text_inputs.get(focus.grandchild_id orelse return error.NoFocus) orelse return error.MissingInput;│ │31 + try std.testing.expectEqualStrings(name, input.options.name); │ │32 + try ui.inputKey(allocator, &root, .{ .codepoint = 'x' }, &session); │ │33 + try root.build(allocator, constraint, focus); │ │34 + const value = try input.text(allocator); │ │35 + defer allocator.free(value); │ │36 + try std.testing.expectEqualStrings("x", value); │ │37 + try ui.inputKey(allocator, &root, .tab, &session); │ │38 + try root.build(allocator, constraint, focus); │ │39 + } │ │40 +} │ │41 │ │42 test "web controls omit hidden inputs but retain off-screen inputs" { │ │43 const wgt = xit.xitui.widget; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯