# VHS E2E test for lazygitclj - Commit workflow with git verification
# Tests the full commit workflow: stage files, open commit modal, type message, commit
# Verifies the commit was actually made using git CLI

Output test/e2e/output/commit-verify.gif
Output test/e2e/output/commit-verify.ascii

Require bb

Set Shell "bash"
Set FontSize 14
Set Width 1000
Set Height 600
Set Framerate 10

# Setup: Create a fresh test repo
Type "rm -rf /tmp/lazygitclj-e2e-commit-verify && mkdir -p /tmp/lazygitclj-e2e-commit-verify && cd /tmp/lazygitclj-e2e-commit-verify"
Enter
Sleep 500ms

# Initialize git repo
Type "git init -b main && git config user.email 'test@example.com' && git config user.name 'Test User'"
Enter
Sleep 500ms

# Create initial commit
Type "echo 'initial' > README.md && git add . && git commit -m 'Initial commit'"
Enter
Sleep 500ms

# Create a new file to commit with lazygitclj
Type "echo 'test content for commit' > test-file.txt"
Enter
Sleep 500ms

# Show the file exists
Type "ls -la"
Enter
Sleep 500ms

# Run lazygitclj
Type "bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s

# Stage the file with 'a' (stage all)
Type "a"
Sleep 500ms

# Press 'c' to open commit modal
Type "c"
Sleep 1s

# Type commit message
Set TypingSpeed 50ms
Type "Add test file via lazygitclj"
Sleep 500ms

# Press Enter to commit
Enter
Sleep 1s

# Should see "Committed!" message
# Navigate to commits panel to see the new commit
Type "4"
Sleep 500ms

# Quit lazygitclj
Type "q"
Sleep 1s

# Verify the commit was made using git CLI
Type "git log --oneline -2"
Enter
Sleep 500ms

# Show that the file is tracked
Type "git status"
Enter
Sleep 500ms

# Show commit details
Type "git show --stat HEAD"
Enter
Sleep 1s
