Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins): UI components #2898

Merged
merged 13 commits into from
Nov 2, 2023
Prev Previous commit
Next Next commit
add tests for components
  • Loading branch information
imsnif committed Oct 31, 2023
commit db5c58c0bb1e7fce542eb2ef9158f9138801663b
2 changes: 2 additions & 0 deletions src/tests/e2e/remote_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ fn read_from_channel(
})));
let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
let debug = false;
let arrow_fonts = true;
let mut terminal_output = TerminalPane::new(
0,
pane_geom,
Expand All @@ -249,6 +250,7 @@ fn read_from_channel(
None,
None,
debug,
arrow_fonts,
); // 0 is the pane index
loop {
if !should_keep_running.load(Ordering::SeqCst) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pznested_list;1/1/20/3;$0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,8$$10,11,12,13,14,15,16,17,18,19,20,21,22,23,24$105,116,101,109,32,49,32,119,105,116,104,32,115,111,109,101,32,110,105,99,101,32,116,101,120,116,46,46,46;|$8$0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32$1,2,3,4,5,6,7,8,9,10,11,12,13,14$105,116,101,109,32,50,32,119,105,116,104,32,115,111,109,101,32,110,111,116,32,115,111,32,110,105,99,101,32,116,101,120,116;x$0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,8$$5,6,7,8,9,10,11,12,13,14,15,16,17,18,19$105,116,101,109,32,51,32,105,115,32,97,32,114,101,97,108,32,101,121,101,32,111,112,101,110,101,114;|$8$$0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,1,2,3,4,5,6,7,8,9,10,11,12,13,14$105,116,101,109,32,52,32,105,115,32,106,117,115,116,32,97,110,111,116,104,101,114,32,105,116,101,109,44,32,114,101,97,108,108,121\
1 change: 0 additions & 1 deletion src/tests/fixtures/ribbon-selected-ui-component

This file was deleted.

1 change: 1 addition & 0 deletions src/tests/fixtures/ribbon-ui-component-with-coordinates
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pzribbon;2/2/10/;1,2,3,4$114,105,98,98,111,110,32,49\
1 change: 1 addition & 0 deletions src/tests/fixtures/table-ui-component-with-coordinates
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pztable;4/4/20/3;3;5;116,105,116,108,101,49;116,105,116,108,101,50;116,105,116,108,101,51;1,2,3,4$99,111,110,116,101,110,116,32,49;$$0,1,2,3,4,5,6,7,8$99,111,110,116,101,110,116,32,50;99,111,110,116,101,110,116,32,51;x99,111,110,116,101,110,116,32,49,49;x99,111,110,116,101,110,116,32,50,50;x99,111,110,116,101,110,116,32,51,51;99,111,110,116,101,110,116,32,49,49,49;99,111,110,116,101,110,116,32,50,50,50;99,111,110,116,101,110,116,32,51,51;99,111,110,116,101,110,116,32,49,49;x99,111,110,116,101,110,116,32,50,50;99,111,110,116,101,110,116,32,51,51\
1 change: 1 addition & 0 deletions src/tests/fixtures/text-ui-component
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pztext;x0,1,2$3,4,5$7,8,9$102,111,111,32,98,97,114,32,98,97,122\
1 change: 1 addition & 0 deletions src/tests/fixtures/text-ui-component-with-coordinates
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pztext;58/4//;x0,1,2$3,4,5$7,8,9$102,111,111,32,98,97,114,32,98,97,122\
120 changes: 111 additions & 9 deletions zellij-server/src/panes/unit/grid_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3102,6 +3102,33 @@ fn table_ui_component() {
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn table_ui_component_with_coordinates() {
let mut vte_parser = vte::Parser::new();
let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
let terminal_emulator_color_codes = Rc::new(RefCell::new(HashMap::new()));
let debug = false;
let arrow_fonts = true;
let mut grid = Grid::new(
41,
110,
Rc::new(RefCell::new(Palette::default())),
terminal_emulator_color_codes,
Rc::new(RefCell::new(LinkHandler::new())),
Rc::new(RefCell::new(None)),
sixel_image_store,
Style::default(),
debug,
arrow_fonts,
);
let fixture_name = "table-ui-component-with-coordinates";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn ribbon_ui_component() {
let mut vte_parser = vte::Parser::new();
Expand Down Expand Up @@ -3130,10 +3157,7 @@ fn ribbon_ui_component() {
}

#[test]
fn ribbon_selected_ui_component() {
// this test doesn't actually test the "selected" part unfortunately since we remove styling
// when we take snapshots, but it's good to keep it to make sure the API is still alive at
// least
fn ribbon_ui_component_with_coordinates() {
let mut vte_parser = vte::Parser::new();
let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
let terminal_emulator_color_codes = Rc::new(RefCell::new(HashMap::new()));
Expand All @@ -3151,7 +3175,7 @@ fn ribbon_selected_ui_component() {
debug,
arrow_fonts,
);
let fixture_name = "ribbon-selected-ui-component";
let fixture_name = "ribbon-ui-component-with-coordinates";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
Expand All @@ -3161,17 +3185,14 @@ fn ribbon_selected_ui_component() {

#[test]
fn nested_list_ui_component() {
// this test doesn't actually test the "selected" part unfortunately since we remove styling
// when we take snapshots, but it's good to keep it to make sure the API is still alive at
// least
let mut vte_parser = vte::Parser::new();
let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
let terminal_emulator_color_codes = Rc::new(RefCell::new(HashMap::new()));
let debug = false;
let arrow_fonts = true;
let mut grid = Grid::new(
41,
110,
120,
Rc::new(RefCell::new(Palette::default())),
terminal_emulator_color_codes,
Rc::new(RefCell::new(LinkHandler::new())),
Expand All @@ -3188,3 +3209,84 @@ fn nested_list_ui_component() {
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn nested_list_ui_component_with_coordinates() {
let mut vte_parser = vte::Parser::new();
let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
let terminal_emulator_color_codes = Rc::new(RefCell::new(HashMap::new()));
let debug = false;
let arrow_fonts = true;
let mut grid = Grid::new(
41,
120,
Rc::new(RefCell::new(Palette::default())),
terminal_emulator_color_codes,
Rc::new(RefCell::new(LinkHandler::new())),
Rc::new(RefCell::new(None)),
sixel_image_store,
Style::default(),
debug,
arrow_fonts,
);
let fixture_name = "nested-list-ui-component-with-coordinates";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn text_ui_component() {
let mut vte_parser = vte::Parser::new();
let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
let terminal_emulator_color_codes = Rc::new(RefCell::new(HashMap::new()));
let debug = false;
let arrow_fonts = true;
let mut grid = Grid::new(
41,
120,
Rc::new(RefCell::new(Palette::default())),
terminal_emulator_color_codes,
Rc::new(RefCell::new(LinkHandler::new())),
Rc::new(RefCell::new(None)),
sixel_image_store,
Style::default(),
debug,
arrow_fonts,
);
let fixture_name = "text-ui-component";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn text_ui_component_with_coordinates() {
let mut vte_parser = vte::Parser::new();
let sixel_image_store = Rc::new(RefCell::new(SixelImageStore::default()));
let terminal_emulator_color_codes = Rc::new(RefCell::new(HashMap::new()));
let debug = false;
let arrow_fonts = true;
let mut grid = Grid::new(
41,
120,
Rc::new(RefCell::new(Palette::default())),
terminal_emulator_color_codes,
Rc::new(RefCell::new(LinkHandler::new())),
Rc::new(RefCell::new(None)),
sixel_image_store,
Style::default(),
debug,
arrow_fonts,
);
let fixture_name = "text-ui-component-with-coordinates";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ source: zellij-server/src/panes/./unit/grid_tests.rs
assertion_line: 3189
expression: "format!(\"{:?}\", grid)"
---
00 (C): > item 1
01 (C): > item 2
02 (C): - item 3
03 (C): > item 4
04 (C): - item 5 lsdkfjlskdj flksdjf lksdj flksjd f
05 (C): > item 6 sldkfjslkdfj lsdkjf lskdjf lskdjf lksdjf lskdjf
06 (C): > item 7
00 (C): > item 1
01 (C): > item 2
02 (C): - item 3
03 (C): > item 4
04 (C): - item 5 lsdkfjlskdj flksdjf lksdj flksjd f
05 (C): > item 6 sldkfjslkdfj lsdkjf lskdjf lskdjf lksdjf lskdjf
06 (C): > item 7
07 (C):
08 (C):
09 (C):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
source: zellij-server/src/panes/./unit/grid_tests.rs
assertion_line: 3237
expression: "format!(\"{:?}\", grid)"
---
00 (C):
01 (C): > item 1 with some
02 (C): - item 2 with som
03 (C): > item 3 is a real
04 (C):
05 (C):
06 (C):
07 (C):
08 (C):
09 (C):
10 (C):
11 (C):
12 (C):
13 (C):
14 (C):
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):
20 (C):
21 (C):
22 (C):
23 (C):
24 (C):
25 (C):
26 (C):
27 (C):
28 (C):
29 (C):
30 (C):
31 (C):
32 (C):
33 (C):
34 (C):
35 (C):
36 (C):
37 (C):
38 (C):
39 (C):
40 (C):

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
source: zellij-server/src/panes/./unit/grid_tests.rs
assertion_line: 3183
expression: "format!(\"{:?}\", grid)"
---
00 (C):
01 (C):
02 (C):  ribbon 
03 (C):
04 (C):
05 (C):
06 (C):
07 (C):
08 (C):
09 (C):
10 (C):
11 (C):
12 (C):
13 (C):
14 (C):
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):
20 (C):
21 (C):
22 (C):
23 (C):
24 (C):
25 (C):
26 (C):
27 (C):
28 (C):
29 (C):
30 (C):
31 (C):
32 (C):
33 (C):
34 (C):
35 (C):
36 (C):
37 (C):
38 (C):
39 (C):
40 (C):

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
source: zellij-server/src/panes/./unit/grid_tests.rs
assertion_line: 2896
assertion_line: 3102
expression: "format!(\"{:?}\", grid)"
---
00 (C): title1 title2 title3 title4 title5
01 (C): ──────────────────────────────────────────────────────────────────────────────────────────
02 (C): 1lksdjflksdjf lkjdsflksjdf lkjsdlkfjsfd lkjsdlkjfd lkjdslkjsdf
03 (C): 2lksdjflksdjf lkjdsflksjdf lkj😳😳sdlkfjsfd lkjsdlkjfd lkjdslkjsdf
04 (C): 3lksdjflksdjf lkjdsflksjdf lkjsd😳lkfjsfd lkjsdlkjfd lkjdslkjsdf
05 (C): 4lksdjflks222djf lk😳222jdsflksjdf lk222jsdlkfjsfd lkwwwjsdlkjfd lkjdslkjsdf
06 (C): 5lksdjflksdjf lkjdsflksjdf lkjsdlkfjsfd lksdjflksjfdlkjsdlkjfd lkjdrrrrslkjsdf
07 (C): 6lksdjflk😳sdjf l😳kjdsflksjdf lkjsdlkfjsfd lkjsdlkjfd lwwkwkjdslkjsdf
01 (C): 1lksdjflksdjf lkjdsflksjdf lkjsdlkfjsfd lkjsdlkjfd lkjdslkjsdf
02 (C): 2lksdjflksdjf lkjdsflksjdf lkj😳😳sdlkfjsfd lkjsdlkjfd lkjdslkjsdf
03 (C): 3lksdjflksdjf lkjdsflksjdf lkjsd😳lkfjsfd lkjsdlkjfd lkjdslkjsdf
04 (C): 4lksdjflks222djf lk😳222jdsflksjdf lk222jsdlkfjsfd lkwwwjsdlkjfd lkjdslkjsdf
05 (C): 5lksdjflksdjf lkjdsflksjdf lkjsdlkfjsfd lksdjflksjfdlkjsdlkjfd lkjdrrrrslkjsdf
06 (C): 6lksdjflk😳sdjf l😳kjdsflksjdf lkjsdlkfjsfd lkjsdlkjfd lwwkwkjdslkjsdf
07 (C):
08 (C):
09 (C):
10 (C):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
source: zellij-server/src/panes/./unit/grid_tests.rs
assertion_line: 3129
expression: "format!(\"{:?}\", grid)"
---
00 (C):
01 (C):
02 (C):
03 (C): title1
04 (C): content 1
05 (C): content 11
06 (C):
07 (C):
08 (C):
09 (C):
10 (C):
11 (C):
12 (C):
13 (C):
14 (C):
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):
20 (C):
21 (C):
22 (C):
23 (C):
24 (C):
25 (C):
26 (C):
27 (C):
28 (C):
29 (C):
30 (C):
31 (C):
32 (C):
33 (C):
34 (C):
35 (C):
36 (C):
37 (C):
38 (C):
39 (C):
40 (C):

Loading