╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ undo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
195 // append an invalid undo record without damaging the repository data. 196 const Corrupt = struct { 197 pub fn run(_: @This(), cursor: *Repo.DB.Cursor(.read_write)) !void { 198 const moment = try Repo.DB.HashMap(.read_write).init(cursor.*); 199 try moment.put(xit.hash.hashInt(.sha1, "undo"), .{ .bytes = "bad" }); 200 } 201 }; 202 const history = try Repo.DB.ArrayList(.read_write).init(repo.core.db.rootCursor()); 203 try history.appendContext(.{ .slot = try history.getSlot(-1) }, Corrupt{}); 204 205 var session = ui.Session{ .arena = &arena, .page_arena = &arena, .io = io, .local = .{ .path = path, .repo_kind = .xit }, .data = .{ .host_kind = .local } }; 206 // tabs switch in-page, so every tab carries the undo data and its failure 207 const files = try ui.Repo.init(&arena, &session, ui.RoutablePage.repoFilesRoute("", null, "", "", 0).?); 208 try std.testing.expectEqual(0, files.undo.?.items.len); 209 try std.testing.expectEqualStrings("InvalidUndoRecord", files.undo.?.failure.?); 210 const undo = try ui.Repo.init(&arena, &session, ui.RoutablePage.repoUndoRoute("", null).?); 211 try std.testing.expectEqualStrings("InvalidUndoRecord", undo.undo.?.failure.?); 212 213 var root = ui.Widget{ .repo_undo = try Undo.View.init(allocator, &undo.undo.?, &session) }; 214 defer root.deinit(allocator); 215 try root.build(allocator, constraint, root.getFocus()); 216 const html = try @import("../web.zig").generateHtml(allocator, &root, &session); 217 defer allocator.free(html); 218 try std.testing.expect(std.mem.indexOf(u8, html, "InvalidUndoRecord") != null); 219 } 220