╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ undo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
203 pub fn run(_: @This(), cursor: *Repo.DB.Cursor(.read_write)) !void { 204 const moment = try Repo.DB.HashMap(.read_write).init(cursor.*); 205 try moment.put(xit.hash.hashInt(.sha1, "undo"), .{ .bytes = "bad" }); 206 } 207 }; 208 const history = try Repo.DB.ArrayList(.read_write).init(repo.core.db.rootCursor()); 209 try history.appendContext(.{ .slot = try history.getSlot(-1) }, Corrupt{}); 210 211 var session = try ui.Session.init(&arena, &admin, .{ .user_id = &owner }); 212 session.io = io; 213 session.users_dir = users_dir; 214 // tabs switch in-page, so every tab carries the undo data and its failure 215 const files = try ui.Repo.init(&arena, &session, ui.RoutablePage.repoFilesRoute("alice:demo", null, "", "", 0).?); 216 try std.testing.expectEqual(0, files.undo.?.items.len); 217 try std.testing.expectEqualStrings("InvalidUndoRecord", files.undo.?.failure.?); 218 const undo = try ui.Repo.init(&arena, &session, ui.RoutablePage.repoUndoRoute("alice:demo", null).?); 219 try std.testing.expectEqualStrings("InvalidUndoRecord", undo.undo.?.failure.?); 220 221 var root = ui.Widget{ .repo_undo = try Undo.View.init(allocator, &undo.undo.?, &session) }; 222 defer root.deinit(allocator); 223 try root.build(allocator, constraint, root.getFocus()); 224 const html = try @import("../web.zig").generateHtml(allocator, &root, &session); 225 defer allocator.free(html); 226 try std.testing.expect(std.mem.indexOf(u8, html, "InvalidUndoRecord") != null); 227 } 228