summaryrefslogtreecommitdiff
path: root/test/behaviour/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 16:17:51 -0300
committerGabriel Schneider <[email protected]>2026-11-03 16:21:16 -0300
commitd197289c331365081295cb44f27ee2893294cffa (patch)
treef4d64abdcdfcb714ece786fd050264dcc22a2bf5 /test/behaviour/panes.zig
parent86e9f8e241df16d96df542e08684af638c39fb89 (diff)
downloadpardes-d197289c331365081295cb44f27ee2893294cffa.tar.gz
pardes-d197289c331365081295cb44f27ee2893294cffa.zip
test: the behaviour-test step and test/session.zig, T1 of docs/next-tests.md: a Session drives the core as a 9P client does (walk by path, open, read or write, clunk, held lines run at the clunk as src/9p_io.zig runs them), the core opaque and the step's module importing session alone, so a behavioural test cannot reach past the 9P tree; keys (kbdin), click (on text found on /screen, mousein), screen, focused, refused and the refusal's words; test/behaviour/{other_files,panes,edit}.zig, a file a section of the reference: kbdin and mousein, a collapsed pane's ctl, name's leading blank, Putall, Edit blocks, moved out of src/ninep/ctl.zig (an Edit block left open now checked as a client sees it, an err in the log at its clunk), each checked to fail against a break (collapsed left off the ctl read, Putall saving nothing); the plan doc says the layout, the decisions and the progress
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/panes.zig')
-rw-r--r--test/behaviour/panes.zig40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
new file mode 100644
index 00000000..45b7152c
--- /dev/null
+++ b/test/behaviour/panes.zig
@@ -0,0 +1,40 @@
+//! docs/typ/reference.typ, Panes <panes>.
+const std = @import("std");
+const Session = @import("session").Session;
+
+test "panes: a collapsed pane's ctl says so" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const first = try s.focused();
+ _ = try s.newPane();
+ try s.write(s.at("/pane/{d}/ctl", .{first}), "Collapse\n");
+ try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{first})), " collapsed "));
+}
+
+test "panes: the ctl word name refuses a leading blank, as the name file does" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const ctl = s.at("/pane/{d}/ctl", .{try s.focused()});
+ try std.testing.expectEqual(@as(u16, 22), try s.refused(ctl, "name /tmp/lead.txt\n"));
+ try std.testing.expectEqualStrings("bad character in file name: a blank at its start", s.said);
+ try s.write(ctl, "name /tmp/ok.txt\n");
+ try s.expect(s.at("/pane/{d}/name", .{try s.focused()}), "/tmp/ok.txt\n");
+}
+
+test "panes: Putall saves every pane with unsaved edits to a file, one each, and leaves the rest" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "clean.txt", .data = "clean\n" });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)];
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const first = try s.focused();
+ try s.write(s.at("/pane/{d}/name", .{first}), "/tmp/pardes-putall-a.txt\n");
+ try s.write(s.at("/pane/{d}/body", .{first}), "edited\n");
+ // A file opened from disk, unedited.
+ try s.write(s.at("/pane/{d}/look", .{first}), s.at("{s}/clean.txt\n", .{dir}));
+ try std.testing.expectEqual(@as(usize, 0), s.saved);
+ try s.write("/ctl", "Putall\n");
+ try std.testing.expectEqual(@as(usize, 1), s.saved);
+}