# VHS E2E test for lazygitclj - Undo/Redo operations
# Tests undo (z) and redo (Z) via reflog navigation

Output test/e2e/output/undo-redo.gif
Output test/e2e/output/undo-redo.ascii

Require bb

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

# Setup test repo and make some changes
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-undo && cd /tmp/lazygitclj-e2e-undo && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s

# Stage all and commit
Type "a"
Sleep 500ms
Type "c"
Sleep 500ms
Set TypingSpeed 50ms
Type "First commit message"
Enter
Sleep 1s

# Create another change
# Exit and modify file
Type "q"
Sleep 500ms
Type "echo 'more changes' >> file1.txt && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s

# Stage and commit again
Type "a"
Sleep 500ms
Type "c"
Sleep 500ms
Type "Second commit"
Enter
Sleep 1s

# Now undo with 'z' - should reset to previous state
Type "z"
Sleep 1s

# Status bar should show undo message
# Redo with 'Z'
Type "Z"
Sleep 1s

# Should be back to latest state
# Quit
Type "q"
Sleep 1s
