| 1 | # Prompt and Display Tests |
| 2 | # Phase 6: Prompt customization, terminal display, window resize |
| 3 | |
| 4 | metadata: |
| 5 | category: "Prompt and Display" |
| 6 | description: "Tests for prompt customization and terminal display features" |
| 7 | phase: 6 |
| 8 | |
| 9 | tests: |
| 10 | # ============================================================= |
| 11 | # PS1 - PRIMARY PROMPT (verify prompt content appears) |
| 12 | # ============================================================= |
| 13 | - name: "PS1 sets custom prompt" |
| 14 | steps: |
| 15 | - send_line: "PS1='CUSTOM> '" |
| 16 | expect_output: "CUSTOM>" |
| 17 | match_type: "contains" |
| 18 | |
| 19 | - name: "PS1 with username escape shows username" |
| 20 | steps: |
| 21 | - send_line: "PS1='\\u$ '" |
| 22 | expect_output: "$" |
| 23 | match_type: "contains" |
| 24 | |
| 25 | - name: "PS1 with hostname escape shows host" |
| 26 | steps: |
| 27 | - send_line: "PS1='\\h: '" |
| 28 | expect_output: ":" |
| 29 | match_type: "contains" |
| 30 | |
| 31 | - name: "PS1 with working directory shows path" |
| 32 | steps: |
| 33 | - send_line: "PS1='W:\\w '" |
| 34 | expect_output: "W:" |
| 35 | match_type: "contains" |
| 36 | |
| 37 | - name: "PS1 with short directory shows basename" |
| 38 | steps: |
| 39 | - send_line: "PS1='\\W> '" |
| 40 | - send_line: "cd /tmp" |
| 41 | expect_output: "tmp>" |
| 42 | match_type: "contains" |
| 43 | |
| 44 | - name: "PS1 with time shows HH:MM:SS" |
| 45 | steps: |
| 46 | - send_line: "PS1='\\t '" |
| 47 | expect_output: ":" |
| 48 | match_type: "contains" |
| 49 | |
| 50 | - name: "PS1 with date shows day" |
| 51 | steps: |
| 52 | - send_line: "PS1='\\d '" |
| 53 | expect_output: " " |
| 54 | match_type: "contains" |
| 55 | |
| 56 | - name: "PS1 with shell name" |
| 57 | steps: |
| 58 | - send_line: "PS1='\\s> '" |
| 59 | expect_output: "" # shell-specific prompt — skip or parameterize |
| 60 | match_type: "contains" |
| 61 | |
| 62 | - name: "PS1 with newline" |
| 63 | steps: |
| 64 | - send_line: "PS1='L1\\nL2> '" |
| 65 | expect_output: "L2>" |
| 66 | match_type: "contains" |
| 67 | |
| 68 | - name: "PS1 with dollar sign for non-root" |
| 69 | steps: |
| 70 | - send_line: "PS1='D\\$ '" |
| 71 | expect_output: "D" |
| 72 | match_type: "contains" |
| 73 | |
| 74 | - name: "PS1 with literal backslash" |
| 75 | steps: |
| 76 | - send_line: "PS1='\\\\> '" |
| 77 | expect_output: "\\>" |
| 78 | match_type: "contains" |
| 79 | |
| 80 | - name: "PS1 with command substitution" |
| 81 | steps: |
| 82 | - send_line: "PS1='$(echo SUB)> '" |
| 83 | expect_output: "SUB>" |
| 84 | match_type: "contains" |
| 85 | |
| 86 | - name: "PS1 updates after cd" |
| 87 | steps: |
| 88 | - send_line: "PS1='\\W> '" |
| 89 | - send_line: "cd /tmp" |
| 90 | expect_output: "tmp>" |
| 91 | match_type: "contains" |
| 92 | |
| 93 | - name: "PS1 with variable expansion" |
| 94 | steps: |
| 95 | - send_line: "MYPS=TEST" |
| 96 | - send_line: "PS1='$MYPS> '" |
| 97 | expect_output: "TEST>" |
| 98 | match_type: "contains" |
| 99 | |
| 100 | # ============================================================= |
| 101 | # PS2 - CONTINUATION PROMPT |
| 102 | # ============================================================= |
| 103 | - name: "PS2 shown for multiline for loop" |
| 104 | steps: |
| 105 | - send_line: "PS2='MORE> '" |
| 106 | - send: "for i in 1 2; do" |
| 107 | - send_key: "Enter" |
| 108 | - send: "echo $i" |
| 109 | - send_key: "Enter" |
| 110 | - send: "done" |
| 111 | - send_key: "Enter" |
| 112 | expect_output: "1" |
| 113 | match_type: "contains" |
| 114 | |
| 115 | - name: "Incomplete quote shows continuation" |
| 116 | steps: |
| 117 | - send: "echo 'hello" |
| 118 | - send_key: "Enter" |
| 119 | - send: "world'" |
| 120 | - send_key: "Enter" |
| 121 | expect_output: "hello" |
| 122 | match_type: "contains" |
| 123 | |
| 124 | - name: "Incomplete command with pipe" |
| 125 | steps: |
| 126 | - send: "echo test |" |
| 127 | - send_key: "Enter" |
| 128 | - send: "cat" |
| 129 | - send_key: "Enter" |
| 130 | expect_output: "test" |
| 131 | match_type: "contains" |
| 132 | |
| 133 | # ============================================================= |
| 134 | # PROMPT COLORS (test that prompts with escapes still work) |
| 135 | # ============================================================= |
| 136 | - name: "PS1 with ANSI codes still displays" |
| 137 | steps: |
| 138 | - send_line: "PS1='\\033[31mRED\\033[0m> '" |
| 139 | - send_line: "echo COL987" |
| 140 | expect_output: "COL987" |
| 141 | match_type: "contains" |
| 142 | |
| 143 | - name: "PS1 with multiple colors" |
| 144 | steps: |
| 145 | - send_line: "PS1='\\033[32mG\\033[0m> '" |
| 146 | - send_line: "echo MUL654" |
| 147 | expect_output: "MUL654" |
| 148 | match_type: "contains" |
| 149 | |
| 150 | # ============================================================= |
| 151 | # PROMPT EDGE CASES |
| 152 | # ============================================================= |
| 153 | - name: "Empty PS1 still allows commands" |
| 154 | steps: |
| 155 | - send_line: "PS1=''; echo emptyps1" |
| 156 | expect_output: "emptyps1" |
| 157 | match_type: "contains" |
| 158 | |
| 159 | - name: "Very long prompt" |
| 160 | steps: |
| 161 | - send_line: "PS1='LONGPROMPT> '" |
| 162 | - send_line: "echo XYZ123" |
| 163 | expect_output: "XYZ123" |
| 164 | match_type: "contains" |
| 165 | |
| 166 | - name: "Special characters in prompt" |
| 167 | steps: |
| 168 | - send_line: "PS1='!@#> '" |
| 169 | - send_line: "echo ABC789" |
| 170 | expect_output: "ABC789" |
| 171 | match_type: "contains" |
| 172 | |
| 173 | - name: "Unicode arrow in prompt" |
| 174 | steps: |
| 175 | - send_line: "PS1='→ '" |
| 176 | - send_line: "echo UNI456" |
| 177 | expect_output: "UNI456" |
| 178 | match_type: "contains" |
| 179 | |
| 180 | - name: "Emoji in prompt" |
| 181 | steps: |
| 182 | - send_line: "PS1='🚀 '" |
| 183 | - send_line: "echo EMO321" |
| 184 | expect_output: "EMO321" |
| 185 | match_type: "contains" |
| 186 | |
| 187 | # ============================================================= |
| 188 | # WINDOW RESIZE (SIGWINCH) |
| 189 | # ============================================================= |
| 190 | - name: "Handle terminal resize" |
| 191 | steps: |
| 192 | - resize: |
| 193 | rows: 40 |
| 194 | cols: 120 |
| 195 | - send_line: "echo resized" |
| 196 | expect_output: "resized" |
| 197 | match_type: "contains" |
| 198 | |
| 199 | - name: "COLUMNS updated after resize" |
| 200 | steps: |
| 201 | - resize: |
| 202 | rows: 24 |
| 203 | cols: 100 |
| 204 | - send_line: "echo $COLUMNS" |
| 205 | expect_output: "100" |
| 206 | match_type: "contains" |
| 207 | |
| 208 | - name: "LINES updated after resize" |
| 209 | steps: |
| 210 | - resize: |
| 211 | rows: 50 |
| 212 | cols: 80 |
| 213 | - send_line: "echo $LINES" |
| 214 | expect_output: "50" |
| 215 | match_type: "contains" |
| 216 | |
| 217 | - name: "Prompt redraws after resize" |
| 218 | steps: |
| 219 | - send: "partial" |
| 220 | - resize: |
| 221 | rows: 30 |
| 222 | cols: 100 |
| 223 | - send_key: "C-u" |
| 224 | - send_line: "echo redraw" |
| 225 | expect_output: "redraw" |
| 226 | match_type: "contains" |
| 227 | |
| 228 | - name: "Small terminal size" |
| 229 | steps: |
| 230 | - resize: |
| 231 | rows: 10 |
| 232 | cols: 40 |
| 233 | - send_line: "echo small" |
| 234 | expect_output: "small" |
| 235 | match_type: "contains" |
| 236 | |
| 237 | - name: "Large terminal size" |
| 238 | steps: |
| 239 | - resize: |
| 240 | rows: 100 |
| 241 | cols: 200 |
| 242 | - send_line: "echo large" |
| 243 | expect_output: "large" |
| 244 | match_type: "contains" |
| 245 | |
| 246 | # ============================================================= |
| 247 | # LINE WRAPPING |
| 248 | # ============================================================= |
| 249 | - name: "Long command wraps correctly" |
| 250 | steps: |
| 251 | - send_line: "echo this is a very long command that should wrap around the terminal edge properly" |
| 252 | expect_output: "wrap around" |
| 253 | match_type: "contains" |
| 254 | |
| 255 | - name: "Editing wrapped line" |
| 256 | steps: |
| 257 | - send: "echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 258 | - send_key: "C-a" |
| 259 | - send_key: "M-f" |
| 260 | - send_key: "C-k" |
| 261 | - send: " wrapped" |
| 262 | - send_key: "Enter" |
| 263 | expect_output: "wrapped" |
| 264 | match_type: "contains" |
| 265 | |
| 266 | - name: "Cursor position on wrapped line" |
| 267 | steps: |
| 268 | - send: "echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 269 | - send_key: "Home" |
| 270 | - send_key: "End" |
| 271 | - send_key: "C-u" |
| 272 | - send_line: "echo cursor" |
| 273 | expect_output: "cursor" |
| 274 | match_type: "contains" |
| 275 | |
| 276 | # ============================================================= |
| 277 | # CLEAR SCREEN |
| 278 | # ============================================================= |
| 279 | - name: "Ctrl+L clears screen" |
| 280 | steps: |
| 281 | - send_line: "echo before" |
| 282 | - send_key: "C-l" |
| 283 | - send_line: "echo after" |
| 284 | expect_output: "after" |
| 285 | match_type: "contains" |
| 286 | |
| 287 | - name: "clear command clears screen" |
| 288 | steps: |
| 289 | - send_line: "echo before" |
| 290 | - send_line: "clear" |
| 291 | - send_line: "echo after" |
| 292 | expect_output: "after" |
| 293 | match_type: "contains" |
| 294 | |
| 295 | # ============================================================= |
| 296 | # MULTILINE OUTPUT |
| 297 | # ============================================================= |
| 298 | - name: "Multiple lines of output" |
| 299 | steps: |
| 300 | - send_line: "echo line1; echo line2; echo line3" |
| 301 | expect_output: "line2" |
| 302 | match_type: "contains" |
| 303 | |
| 304 | - name: "Output with blank lines" |
| 305 | steps: |
| 306 | - send_line: "echo first; echo; echo last" |
| 307 | expect_output: "last" |
| 308 | match_type: "contains" |
| 309 | |
| 310 | - name: "Long output scrolling" |
| 311 | steps: |
| 312 | - send_line: "for i in $(seq 1 20); do echo line$i; done" |
| 313 | expect_output: "line20" |
| 314 | match_type: "contains" |
| 315 | |
| 316 | # ============================================================= |
| 317 | # TERMINAL TITLE |
| 318 | # ============================================================= |
| 319 | - name: "Set terminal title with printf" |
| 320 | steps: |
| 321 | - send_line: "printf '\\033]0;Test Title\\007'" |
| 322 | - send_line: "echo titleset" |
| 323 | expect_output: "titleset" |
| 324 | match_type: "contains" |
| 325 | |
| 326 |