aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-integration-tests/tests/set_pane_frame_style.rs
blob: 5b18f965146e0a8289eb940a27e11a65c70ab231 (plain) (blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#![cfg(unix)]

use zellij_integration_tests::{
    claim_first_terminal_and_wait_for_prompt, split_right_and_wait_for_prompt, start_zellij, Size,
    TestRunner,
};
use zellij_utils::cli::CliAction;
use zellij_utils::input::options::PaneFrameStyle;

const FULL_FRAME_CORNER: &str = "┌";

fn ctrl_y() -> [u8; 1] {
    [0x19]
}

#[test]
fn set_pane_frame_style_through_the_cli() {
    let mut zellij = start_zellij();
    claim_first_terminal_and_wait_for_prompt(&zellij);

    zellij.wait_until("lone titles pane has no frame", |grid_snapshot| {
        grid_snapshot.status_bar_appears() && !grid_snapshot.contains(FULL_FRAME_CORNER)
    });

    let exit_code = zellij.run_cli_action(CliAction::SetPaneFrameStyle {
        style: PaneFrameStyle::Full,
    });
    assert_eq!(exit_code, 0, "set-pane-frame-style exited cleanly");

    zellij.wait_until(
        "full frames drawn after switching to full",
        |grid_snapshot| {
            grid_snapshot.contains(FULL_FRAME_CORNER) && grid_snapshot.contains("Pane #1")
        },
    );

    let exit_code = zellij.run_cli_action(CliAction::SetPaneFrameStyle {
        style: PaneFrameStyle::Titles,
    });
    assert_eq!(exit_code, 0, "set-pane-frame-style exited cleanly");

    zellij.wait_until(
        "frame removed after switching back to titles",
        |grid_snapshot| {
            grid_snapshot.status_bar_appears()
                && !grid_snapshot.contains(FULL_FRAME_CORNER)
                && !grid_snapshot.contains("Pane #1")
        },
    );

    zellij.quit();
}

#[test]
fn set_pane_frame_style_none_through_the_cli() {
    let mut zellij = start_zellij();
    claim_first_terminal_and_wait_for_prompt(&zellij);
    split_right_and_wait_for_prompt(&zellij);

    zellij.wait_until(
        "two titled panes start without full frames",
        |grid_snapshot| {
            grid_snapshot.contains("Pane #1")
                && grid_snapshot.contains("Pane #2")
                && !grid_snapshot.contains(FULL_FRAME_CORNER)
        },
    );

    let exit_code = zellij.run_cli_action(CliAction::SetPaneFrameStyle {
        style: PaneFrameStyle::None,
    });
    assert_eq!(exit_code, 0, "set-pane-frame-style none exited cleanly");

    zellij.wait_until(
        "titles and frames both removed in none mode",
        |grid_snapshot| {
            grid_snapshot.status_bar_appears()
                && !grid_snapshot.contains("Pane #1")
                && !grid_snapshot.contains("Pane #2")
                && !grid_snapshot.contains(FULL_FRAME_CORNER)
        },
    );

    let exit_code = zellij.run_cli_action(CliAction::SetPaneFrameStyle {
        style: PaneFrameStyle::Titles,
    });
    assert_eq!(exit_code, 0, "set-pane-frame-style titles exited cleanly");

    zellij.wait_until("pane titles return in titles mode", |grid_snapshot| {
        grid_snapshot.contains("Pane #1") && !grid_snapshot.contains(FULL_FRAME_CORNER)
    });

    zellij.quit();
}

#[test]
fn set_pane_frame_style_through_a_keybinding() {
    let mut zellij = TestRunner::new(Size {
        cols: 120,
        rows: 24,
    })
    .with_config("keybinds {\n normal {\n  bind \"Ctrl y\" { SetPaneFrameStyle \"full\"; }\n }\n}")
    .start();
    claim_first_terminal_and_wait_for_prompt(&zellij);

    zellij.wait_until("lone titles pane has no frame", |grid_snapshot| {
        grid_snapshot.status_bar_appears() && !grid_snapshot.contains(FULL_FRAME_CORNER)
    });

    zellij.send_stdin(&ctrl_y());

    zellij.wait_until(
        "keybinding switched the pane to full frames",
        |grid_snapshot| {
            grid_snapshot.contains(FULL_FRAME_CORNER) && grid_snapshot.contains("Pane #1")
        },
    );

    zellij.quit();
}