* Test switching between different shells
()
| 281 | * Test switching between different shells |
| 282 | */ |
| 283 | async function testShellSwitching() { |
| 284 | console.log('\nTest 5: Testing shell switching'); |
| 285 | |
| 286 | // Get available shells for switching test |
| 287 | const availableShells = []; |
| 288 | if (await isShellAvailable('/bin/sh')) availableShells.push('/bin/sh'); |
| 289 | if (await isShellAvailable('/bin/bash')) availableShells.push('/bin/bash'); |
| 290 | if (await isShellAvailable('cmd')) availableShells.push('cmd'); |
| 291 | if (await isShellAvailable('pwsh')) availableShells.push('pwsh'); |
| 292 | |
| 293 | if (availableShells.length < 2) { |
| 294 | console.log('⚠️ Skipping shell switching test: need at least 2 available shells'); |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | console.log(`✓ Available shells for switching test: ${availableShells.join(', ')}`); |
| 299 | |
| 300 | // Test switching between first two available shells |
| 301 | const shell1 = availableShells[0]; |
| 302 | const shell2 = availableShells[1]; |
| 303 | |
| 304 | // Switch to first shell |
| 305 | await configManager.setValue('defaultShell', shell1); |
| 306 | let shellOutput = await getShellFromCommand(shell1); |
| 307 | let expectedOutputs = getExpectedShellOutput(shell1); |
| 308 | let isValidOutput = expectedOutputs.includes(shellOutput); |
| 309 | assert(isValidOutput, `Switch to ${shell1} should work, got: ${shellOutput}`); |
| 310 | console.log(`✓ Successfully switched to ${shell1}: ${shellOutput}`); |
| 311 | |
| 312 | // Switch to second shell |
| 313 | await configManager.setValue('defaultShell', shell2); |
| 314 | shellOutput = await getShellFromCommand(shell2); |
| 315 | expectedOutputs = getExpectedShellOutput(shell2); |
| 316 | isValidOutput = expectedOutputs.includes(shellOutput); |
| 317 | assert(isValidOutput, `Switch to ${shell2} should work, got: ${shellOutput}`); |
| 318 | console.log(`✓ Successfully switched to ${shell2}: ${shellOutput}`); |
| 319 | |
| 320 | // Switch back to first shell |
| 321 | await configManager.setValue('defaultShell', shell1); |
| 322 | shellOutput = await getShellFromCommand(shell1); |
| 323 | expectedOutputs = getExpectedShellOutput(shell1); |
| 324 | isValidOutput = expectedOutputs.includes(shellOutput); |
| 325 | assert(isValidOutput, `Switch back to ${shell1} should work, got: ${shellOutput}`); |
| 326 | console.log(`✓ Successfully switched back to ${shell1}: ${shellOutput}`); |
| 327 | |
| 328 | console.log('✓ Test 5 passed: shell switching works correctly'); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Test that configuration changes persist |
no test coverage detected