summaryrefslogtreecommitdiffstats
path: root/src/tests/e2e/steps.rs
blob: c09fc9392d207b22491170a72406cb8ba9b454b8 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
use super::cases::{
    MOVE_FOCUS_LEFT_IN_NORMAL_MODE, MOVE_TAB_LEFT, MOVE_TAB_RIGHT, NEW_TAB_IN_TAB_MODE,
    SECOND_TAB_CONTENT, TAB_MODE,
};
use super::remote_runner::{RemoteTerminal, Step};

pub fn new_tab() -> Step {
    Step {
        name: "Open new tab",
        instruction: |mut remote_terminal: RemoteTerminal| -> bool {
            let mut step_is_complete = false;
            if remote_terminal.tip_appears() && remote_terminal.status_bar_appears() {
                remote_terminal.send_key(&TAB_MODE);
                remote_terminal.send_key(&NEW_TAB_IN_TAB_MODE);
                step_is_complete = true;
            }
            step_is_complete
        },
    }
}

pub fn check_second_tab_opened() -> Step {
    Step {
        name: "Check second tab opened",
        instruction: |remote_terminal: RemoteTerminal| -> bool {
            remote_terminal.status_bar_appears()
                && remote_terminal.tip_appears()
                && remote_terminal.snapshot_contains("Tab #2")
        },
    }
}

pub fn move_tab_left() -> Step {
    Step {
        name: "Move tab left",
        instruction: |mut remote_terminal: RemoteTerminal| -> bool {
            let mut step_is_complete = false;
            if remote_terminal.tip_appears() && remote_terminal.status_bar_appears() {
                remote_terminal.send_key(&MOVE_TAB_LEFT);
                step_is_complete = true;
            }
            step_is_complete
        },
    }
}

pub fn check_third_tab_moved_left() -> Step {
    Step {
        name: "Check third tab is in the middle",
        instruction: |remote_terminal: RemoteTerminal| -> bool {
            remote_terminal.status_bar_appears()
                && remote_terminal.tip_appears()
                && remote_terminal.snapshot_contains("Tab #1  Tab #3  Tab #2")
        },
    }
}

pub fn type_second_tab_content() -> Step {
    Step {
        name: "Type second tab content",
        instruction: |mut remote_terminal: RemoteTerminal| -> bool {
            let mut step_is_complete = false;
            if remote_terminal.tip_appears() && remote_terminal.status_bar_appears() {
                remote_terminal.send_key(&SECOND_TAB_CONTENT);
                step_is_complete = true;
            }
            step_is_complete
        },
    }
}

pub fn check_third_tab_opened() -> Step {
    Step {
        name: "Check third tab opened",
        instruction: |remote_terminal: RemoteTerminal| -> bool {
            remote_terminal.status_bar_appears()
                && remote_terminal.tip_appears()
                && remote_terminal.snapshot_contains("Tab #3")
        },
    }
}

pub fn switch_focus_to_left_tab() -> Step {
    Step {
        name: "Move focus to tab on the left",
        instruction: |mut remote_terminal: RemoteTerminal| -> bool {
            let mut step_is_complete = false;
            if remote_terminal.tip_appears() && remote_terminal.status_bar_appears() {
                remote_terminal.send_key(&MOVE_FOCUS_LEFT_IN_NORMAL_MODE);
                step_is_complete = true;
            }
            step_is_complete
        },
    }
}

pub fn check_focus_on_second_tab() -> Step {
    Step {
        name: "Check focus is on the second tab",
        instruction: |remote_terminal: RemoteTerminal| -> bool {
            remote_terminal.status_bar_appears()
                && remote_terminal.tip_appears()
                && remote_terminal.snapshot_contains("Tab #2 content")
        },
    }
}

pub fn move_tab_right() -> Step {
    Step {
        name: "Move tab right",
        instruction: |mut remote_terminal: RemoteTerminal| -> bool {
            let mut step_is_complete = false;
            if remote_terminal.tip_appears() && remote_terminal.status_bar_appears() {
                remote_terminal.send_key(&MOVE_TAB_RIGHT);
                step_is_complete = true;
            }
            step_is_complete
        },
    }
}

pub fn check_third_tab_moved_to_beginning() -> Step {
    Step {
        name: "Check third tab moved to beginning",
        instruction: |remote_terminal: RemoteTerminal| -> bool {
            remote_terminal.status_bar_appears()
                && remote_terminal.tip_appears()
                && remote_terminal.snapshot_contains("Tab #3  Tab #1  Tab #2")
        },
    }
}

pub fn check_third_tab_is_left_wrapped() -> Step {
    Step {
        name: "Check third tab is in last position",
        instruction: |remote_terminal: RemoteTerminal| -> bool {
            remote_terminal.status_bar_appears()
                && remote_terminal.tip_appears()
                && remote_terminal.snapshot_contains("Tab #2  Tab #1  Tab #3")
        },
    }
}

pub fn check_third_tab_is_right_wrapped() -> Step {
    Step {
        name: "Check third tab is in last position",
        instruction: |remote_terminal: RemoteTerminal| -> bool {
            remote_terminal.status_bar_appears()
                && remote_terminal.tip_appears()
                && remote_terminal.snapshot_contains("Tab #3  Tab #2  Tab #1")
        },
    }
}