#!/bin/bash # Test Option 2: Interactive Installer # This script tests the interactive installer in automated mode set -e # Source common functions SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/common.sh" log_section "Testing Option 2: Interactive Installer" TEST_NAME="interactive-install" REPO_DIR="$HOME/claude-code-glm-suite" INSTALLER_SCRIPT="$REPO_DIR/interactive-install-claude.sh" # Check if repo is available if [ ! -d "$REPO_DIR" ]; then log_error "Repository not found at $REPO_DIR" exit 1 fi log_info "Repository found: $REPO_DIR" # Check if installer exists if [ ! -f "$INSTALLER_SCRIPT" ]; then log_error "Installer not found: $INSTALLER_SCRIPT" exit 1 fi log_info "Installer found: $INSTALLER_SCRIPT" # Make installer executable chmod +x "$INSTALLER_SCRIPT" # Backup existing Claude directory if it exists BACKUP_DIR="" if [ -d "$HOME/.claude" ]; then BACKUP_DIR="$HOME/.claude.backup.$(date +%Y%m%d-%H%M%S)" log_info "Backing up existing .claude directory to $BACKUP_DIR" mv "$HOME/.claude" "$BACKUP_DIR" fi # Run installer with automatic responses log_section "Running Interactive Installer (Automated Mode)" # Create expect script for automated responses cat > /tmp/installer-answers.exp << 'EXPECT_EOF' #!/usr/bin/expect -f set timeout 300 spawn /home/testuser/claude-code-glm-suite/interactive-install-claude.sh # Model selection expect "Select model provider:" send "1\r" # Agent categories (select all) expect "Select agent categories" expect "Select engineering agents?" send "Y\r" expect "Select marketing agents?" send "Y\r" expect "Select product agents?" send "Y\r" expect "Select studio-operations agents?" send "Y\r" expect "Select project-management agents?" send "Y\r" expect "Select testing agents?" send "Y\r" expect "Select design agents?" send "Y\r" expect "Select bonus agents?" send "Y\r" # MCP tools expect "Install vision tools?" send "Y\r" expect "Install web tools?" send "Y\r" expect "Install GitHub tools?" send "Y\r" expect "Install TLDR?" send "Y\r" # Plugins expect "Install plugins?" send "Y\r" # Hooks expect "Install hooks?" send "Y\r" # Ralph CLI (optional - skip for this test to keep it simple) expect "Install Ralph CLI?" send "N\r" # Prerequisites check expect "Prerequisites check passed" # Installation expect "Installation completed" # Summary expect "Installation Summary" # Don't launch Claude Code expect "Launch Claude Code now?" send "N\r" expect eof EXPECT_EOF chmod +x /tmp/installer-answers.exp # Run the expect script log_info "Starting automated installation..." if expect /tmp/installer-answers.exp >> "$LOG_FILE" 2>&1; then log_success "Installer completed successfully" else log_error "Installer failed with exit code $?" fi # Verify installation log_section "Verifying Installation" run_full_verification # Save results save_results "$TEST_NAME" # Cleanup rm -f /tmp/installer-answers.exp # Restore backup if test failed if [ $TESTS_FAILED -gt 0 ] && [ -n "$BACKUP_DIR" ]; then log_warning "Test failed, restoring backup" rm -rf "$HOME/.claude" mv "$BACKUP_DIR" "$HOME/.claude" fi log_section "Interactive Installer Test Complete" echo ""