aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/panes/unit/grid_tests.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-06-30 11:27:35 +0200
committerGitHub <noreply@github.com>2021-06-30 11:27:35 +0200
commited4fd2a8e77df304539ca7f445a78039028eaa8a (patch)
treeae48b03370b11f3f0987676584724463ac83460d /zellij-server/src/panes/unit/grid_tests.rs
parentMerge pull request #590 from a-kenji/clippy-fixes (diff)
downloadsl0ppij-ed4fd2a8e77df304539ca7f445a78039028eaa8a.tar.gz
sl0ppij-ed4fd2a8e77df304539ca7f445a78039028eaa8a.tar.xz
sl0ppij-ed4fd2a8e77df304539ca7f445a78039028eaa8a.zip
chore(tests): move all integration tests to be either unit or e2e tests - remove old testing infra (#589)
* tests(integration): move basic integration tests to be unit tests * fix(tests): silently fail threadbus for tests * tests(unit): move compatibility tests to become unit tests for grid * tests(unit): move close_pane tests to become unit tests for grid * tests(e2e): move basic layout test to e2e * tests(unit): move move_focus tests to be unit tests * tests(unit): move resize_down tests to be unit tests * tests(unit): move resize_left tests to be unit tests * tests(unit): move resize_right tests to be unit tests * tests(unit): move resize_up tests to be unit tests * tests(infra): remove unused infra * style(fmt): make rustfmt happy * debug * debug * debug * debug * chore(test): shift volume mounting around because github actions is a special child
Diffstat (limited to 'zellij-server/src/panes/unit/grid_tests.rs')
-rw-r--r--zellij-server/src/panes/unit/grid_tests.rs290
1 files changed, 290 insertions, 0 deletions
diff --git a/zellij-server/src/panes/unit/grid_tests.rs b/zellij-server/src/panes/unit/grid_tests.rs
index bce67e06..048d3d0a 100644
--- a/zellij-server/src/panes/unit/grid_tests.rs
+++ b/zellij-server/src/panes/unit/grid_tests.rs
@@ -555,3 +555,293 @@ fn wrap_wide_characters_at_the_end_of_the_line() {
}
assert_snapshot!(format!("{:?}", grid));
}
+
+/*
+ * These tests below are general compatibility tests for non-trivial scenarios running in the terminal.
+ * They use fake TTY input replicated from these scenarios.
+ *
+ */
+
+#[test]
+fn run_bandwhich_from_fish_shell() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "fish_and_bandwhich";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+fn fish_tab_completion_options() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "fish_tab_completion_options";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn fish_select_tab_completion_options() {
+ // the difference between this and the previous test is that here we press <TAB>
+ // twice, meaning the selection moves between the options and the command line
+ // changes.
+ // this is not clearly seen in the snapshot because it does not include styles,
+ // but we can see the command line change and the cursor staying in place
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "fish_select_tab_completion_options";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn vim_scroll_region_down() {
+ // here we test a case where vim defines the scroll region as lesser than the screen row count
+ // and then scrolls down
+ // the region is defined here by vim as 1-26 (there are 28 rows)
+ // then the cursor is moved to line 26 and a new line is added
+ // what should happen is that the first line in the scroll region (1) is deleted
+ // and an empty line is inserted in the last scroll region line (26)
+ // this tests also has other steps afterwards that fills the line with the next line in the
+ // file
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "vim_scroll_region_down";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn vim_ctrl_d() {
+ // in vim ctrl-d moves down half a page
+ // in this case, it sends the terminal the csi 'M' directive, which tells it to delete X (13 in
+ // this case) lines inside the scroll region and push the other lines up
+ // what happens here is that 13 lines are deleted and instead 13 empty lines are added at the
+ // end of the scroll region
+ // vim makes sure to fill these empty lines with the rest of the file
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "vim_ctrl_d";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn vim_ctrl_u() {
+ // in vim ctrl-u moves up half a page
+ // in this case, it sends the terminal the csi 'L' directive, which tells it to insert X (13 in
+ // this case) lines at the cursor, pushing away (deleting) the last line in the scroll region
+ // this causes the effect of scrolling up X lines (vim replaces the lines with the ones in the
+ // file above the current content)
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "vim_ctrl_u";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn htop() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "htop";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn htop_scrolling() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "htop_scrolling";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn htop_right_scrolling() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "htop_right_scrolling";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn vim_overwrite() {
+ // this tests the vim overwrite message
+ // to recreate:
+ // * open a file in vim
+ // * open the same file in another window
+ // * change the file in the other window and save
+ // * change the file in the original vim window and save
+ // * confirm you would like to change the file by pressing 'y' and then ENTER
+ // * if everything looks fine, this test passed :)
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "vim_overwrite";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn clear_scroll_region() {
+ // this is actually a test of 1049h/l (alternative buffer)
+ // @imsnif - the name is a monument to the time I didn't fully understand this mechanism :)
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "clear_scroll_region";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn display_tab_characters_properly() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "tab_characters";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn neovim_insert_mode() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "nvim_insert";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn bash_cursor_linewrap() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 116, Palette::default());
+ let fixture_name = "bash_cursor_linewrap";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn fish_paste_multiline() {
+ // here we paste a multiline command in fish shell, making sure we support it
+ // going up and changing the colors of our line-wrapped pasted text
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 149, Palette::default());
+ let fixture_name = "fish_paste_multiline";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn git_log() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 149, Palette::default());
+ let fixture_name = "git_log";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn git_diff_scrollup() {
+ // this tests makes sure that when we have a git diff that exceeds the screen size
+ // we are able to scroll up
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(28, 149, Palette::default());
+ let fixture_name = "git_diff_scrollup";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn emacs_longbuf() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(60, 284, Palette::default());
+ let fixture_name = "emacs_longbuf_tutorial";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn top_and_quit() {
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(56, 235, Palette::default());
+ let fixture_name = "top_and_quit";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}
+
+#[test]
+pub fn exa_plus_omf_theme() {
+ // this tests that we handle a tab delimited table properly
+ // without overriding the previous content
+ // this is a potential bug because the \t character is a goto
+ // if we forwarded it as is to the terminal, we would be skipping
+ // over existing on-screen content without deleting it, so we must
+ // convert it to spaces
+ let mut vte_parser = vte::Parser::new();
+ let mut grid = Grid::new(56, 235, Palette::default());
+ let fixture_name = "exa_plus_omf_theme";
+ let content = read_fixture(fixture_name);
+ for byte in content {
+ vte_parser.advance(&mut grid, byte);
+ }
+ assert_snapshot!(format!("{:?}", grid));
+}