# Miku UNO Bot - Testing Checklist

## Pre-Testing Setup

### 1. Install Playwright Browsers ✅
```bash
cd /home/koko210Serve/docker/miku-discord/bot
bash setup_uno_playwright.sh
```

**Expected Output**: 
```
✅ Playwright browsers installed successfully!
```

### 2. Verify UNO Servers Running ✅
```bash
# Terminal 1 - Backend
cd /home/koko210Serve/docker/uno-online
node server.js
# Should show: Server listening on port 5000

# Terminal 2 - Frontend  
cd /home/koko210Serve/docker/uno-online/client
npm start
# Should show: webpack compiled successfully
# Available at: http://192.168.1.2:3002
```

### 3. Start Miku Bot ✅
```bash
cd /home/koko210Serve/docker/miku-discord/bot
python bot.py
```

**Look for**: 
```
🎤 MikuBot connected as <bot name>
```

## Testing Scenarios

### Test 1: Help Command
**Discord Command**: `!uno help`

**Expected Response**: 
```
🎮 Miku UNO Commands

!uno create
Create a new UNO game room and join as Player 2

!uno join <room_code>
Join an existing UNO game room
Example: !uno join ABC123

!uno list
Show all active UNO games

!uno quit <room_code>
Leave an active UNO game
Example: !uno quit ABC123

!uno help
Show this help message
```

**Status**: [ ] Pass [ ] Fail

---

### Test 2: Create Game
**Discord Command**: `!uno create`

**Expected Response**:
```
🎮 Created UNO room: <6-char code>
Join at: http://192.168.1.2:3002
I'm joining now as Player 2! ✨
```

**Verification Steps**:
1. Copy the room code from response
2. Open http://192.168.1.2:3002 in browser
3. Click "Join Room"
4. Enter the room code
5. You should see "Player 1" (you) and "Player 2" (Miku) in the room

**Bot Logs Should Show**:
```
[UNO] Creating new game room...
[MikuUnoPlayer] Browser launched
[MikuUnoPlayer] Navigating to UNO game...
[MikuUnoPlayer] Joining room: <code>
[MikuUnoPlayer] Waiting for game to start...
```

**Status**: [ ] Pass [ ] Fail

---

### Test 3: Game Starts (2 Players)
**Action**: After joining the room in browser (Test 2), game should auto-start

**Expected Behavior**:
- Game initializes with 7 cards each
- A top card appears in the center
- Turn indicator shows whose turn it is

**Bot Logs Should Show**:
```
[MikuUnoPlayer] Game started! Players: 2
[MikuUnoPlayer] Polling game state...
[MikuUnoPlayer] Current turn: Player 1 (or Player 2)
```

**Status**: [ ] Pass [ ] Fail

---

### Test 4: Miku's First Turn
**Action**: Let the game proceed until it's Miku's turn (Player 2)

**Expected Behavior**:
1. Bot detects it's Player 2's turn
2. Bot analyzes game state
3. Bot prompts LLM for strategy
4. Bot makes a valid move (play or draw)
5. Bot sends trash talk to Discord

**Bot Logs Should Show**:
```
[MikuUnoPlayer] It's my turn! Analyzing game state...
[MikuUnoPlayer] Hand: ['R5', 'G2', 'B7', ...] (7 cards)
[MikuUnoPlayer] Top card: Y3
[MikuUnoPlayer] Getting Miku's strategic decision...
[MikuUnoPlayer] LLM Response: {"action": "play", "card": "Y5"}
[MikuUnoPlayer] Action executed successfully!
```

**Discord Should Show**:
```
(One of the trash talk messages based on card played)
```

**Status**: [ ] Pass [ ] Fail

---

### Test 5: LLM Strategy Quality
**Action**: Observe several of Miku's turns

**Expected Behavior**:
- Miku plays matching cards when available
- Miku uses special cards strategically (Draw 2, Skip, etc.)
- Miku draws when no valid plays
- Miku calls UNO when down to 1 card

**Quality Checks**:
- [ ] Plays valid cards only
- [ ] Matches color or number correctly
- [ ] Uses Wild cards when necessary
- [ ] Strategic use of action cards
- [ ] Calls UNO at right time

**Status**: [ ] Pass [ ] Fail

---

### Test 6: Trash Talk Personality
**Action**: Check Discord messages during gameplay

**Expected Messages** (examples):
- Draw 4: "Take four cards! 💙✨ I hope you're ready for a comeback~"
- Draw 2: "Draw two cards! Don't worry, I still believe in you~ ✨"
- Skip: "Sorry~ Skipping your turn! Maybe next time? 🎶"
- Wild: "I'm changing the color! Let's see how you handle this~ 💫"
- Regular: "Playing my card~ Let's keep this fun! 🎵"

**Personality Checks**:
- [ ] Messages are cheerful
- [ ] Uses emojis appropriately
- [ ] Sounds like Miku (idol personality)
- [ ] Varies based on card type

**Status**: [ ] Pass [ ] Fail

---

### Test 7: Game Completion
**Action**: Play until game ends (someone wins)

**Expected Behavior**:
1. Winner is determined
2. Bot detects game end
3. Bot stops polling
4. Bot sends final message to Discord
5. Bot cleans up resources

**Bot Logs Should Show**:
```
[MikuUnoPlayer] Game ended! Winner: <Player 1 or Player 2>
[MikuUnoPlayer] Stopping game loop...
[MikuUnoPlayer] Browser closed
```

**Discord Should Show**:
```
🎮 Game <code> has ended!
(Winner message)
```

**Status**: [ ] Pass [ ] Fail

---

### Test 8: Join Existing Game
**Setup**: Create a game manually at http://192.168.1.2:3002, get room code

**Discord Command**: `!uno join ABC123` (use actual code)

**Expected Response**:
```
🎮 Joining UNO room: ABC123
I'll be Player 2! ✨
```

**Verification**: Same as Test 2 & 3

**Status**: [ ] Pass [ ] Fail

---

### Test 9: List Active Games
**Setup**: Have 1-2 active games running

**Discord Command**: `!uno list`

**Expected Response**:
```
🎮 Active UNO Games:

Room: ABC123
Players: 2/2
Status: Playing
Started: 2 minutes ago

Room: XYZ789
Players: 2/2
Status: Playing
Started: 5 minutes ago
```

**Status**: [ ] Pass [ ] Fail

---

### Test 10: Quit Game
**Setup**: Have an active game running

**Discord Command**: `!uno quit ABC123`

**Expected Response**:
```
👋 Left UNO room: ABC123
See you next game! ✨
```

**Verification**:
- Bot stops polling
- Browser closes
- Game removed from active games list

**Status**: [ ] Pass [ ] Fail

---

## Error Scenarios

### Test E1: Invalid Room Code
**Discord Command**: `!uno join INVALID`

**Expected Response**:
```
❌ Couldn't join room INVALID
The room might not exist or is full.
```

**Status**: [ ] Pass [ ] Fail

---

### Test E2: Room Already Full
**Setup**: Create a game, have 2 players join via browser

**Discord Command**: `!uno join <code>`

**Expected Response**:
```
❌ Room <code> is full (2/2 players)
```

**Status**: [ ] Pass [ ] Fail

---

### Test E3: Servers Not Running
**Setup**: Stop UNO server (port 5000)

**Discord Command**: `!uno create`

**Expected Response**:
```
❌ Failed to create game room
Make sure the UNO server is running.
```

**Status**: [ ] Pass [ ] Fail

---

### Test E4: Invalid JSON from LLM
**Action**: This should be caught and handled gracefully

**Expected Behavior**:
- Bot logs error
- Bot attempts to draw card as fallback
- Game continues without crashing

**Bot Logs Should Show**:
```
[MikuUnoPlayer] Error: Invalid LLM response format
[MikuUnoPlayer] Falling back to draw action
```

**Status**: [ ] Pass [ ] Fail

---

## Performance Tests

### Test P1: Response Time
**Metric**: Time from "It's Miku's turn" to action executed

**Target**: < 5 seconds

**Measured**: _______ seconds

**Status**: [ ] Pass [ ] Fail

---

### Test P2: Multiple Concurrent Games
**Action**: Start 2-3 games simultaneously

**Expected Behavior**:
- All games run independently
- No cross-contamination of game state
- Each game has own polling loop

**Status**: [ ] Pass [ ] Fail

---

### Test P3: Long Game (20+ turns)
**Action**: Play a full game with many turns

**Expected Behavior**:
- Bot maintains performance throughout
- No memory leaks
- No degradation in response time

**Status**: [ ] Pass [ ] Fail

---

## Test Results Summary

**Total Tests**: 17 (10 main + 4 error + 3 performance)

**Passed**: _____
**Failed**: _____
**Percentage**: _____%

## Issues Found

### Issue 1
**Description**: 
**Severity**: [ ] Critical [ ] Major [ ] Minor
**Status**: [ ] Open [ ] Fixed

### Issue 2
**Description**: 
**Severity**: [ ] Critical [ ] Major [ ] Minor
**Status**: [ ] Open [ ] Fixed

### Issue 3
**Description**: 
**Severity**: [ ] Critical [ ] Major [ ] Minor
**Status**: [ ] Open [ ] Fixed

---

## Next Steps

### If All Tests Pass ✅
1. Document any quirks or limitations
2. Create user-facing documentation
3. Consider Discord Activity conversion (Phase 2)
4. Implement enhancement features

### If Tests Fail ❌
1. Document failures in detail
2. Prioritize by severity
3. Debug and fix critical issues first
4. Re-test after fixes

---

## Notes

**Date Tested**: __________
**Tester**: __________
**Bot Version**: __________
**Environment**: __________

**Additional Observations**:
