Skip to content

Commit f80e3e5

Browse files
Phlogistiqueclaude
andauthored
Fix e2e test conflict scenario and add test documentation (#7)
- Fix step 8: Add git pull before modifying main branch to avoid push rejection due to local branch being behind remote after PR1 merge - Add comprehensive documentation header explaining test purpose and both test scenarios (nominal linear stack merge + conflict handling) Co-authored-by: Claude <noreply@anthropic.com>
1 parent e6fa4c9 commit f80e3e5

1 file changed

Lines changed: 73 additions & 1 deletion

File tree

tests/test_e2e.sh

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,79 @@
11
#!/bin/bash
2-
# End-to-End test for the update-pr-stack action.
2+
# =============================================================================
3+
# End-to-End Test for the update-pr-stack Action
4+
# =============================================================================
5+
#
6+
# PURPOSE:
7+
# This test validates the full functionality of the update-pr-stack GitHub
8+
# Action, which automatically updates stacked PRs after a base PR is merged.
9+
#
310
# WARNING: This test creates and deletes a REAL GitHub repository.
411
# It requires a GITHUB_TOKEN environment variable with appropriate permissions:
512
# repo (full control), workflow, pull_request (write).
13+
#
14+
# =============================================================================
15+
# TEST SCENARIOS
16+
# =============================================================================
17+
#
18+
# SCENARIO 1: Nominal Linear Stack with Clean Merges (Steps 1-7)
19+
# --------------------------------------------------------------
20+
# Tests the happy path where PRs are merged without conflicts.
21+
#
22+
# Setup:
23+
# - Create a stack of 3 PRs: main <- feature1 <- feature2 <- feature3
24+
# - Each PR modifies line 2 of file.txt (same line, different content)
25+
#
26+
# Action Trigger:
27+
# - Squash merge PR1 (feature1) into main
28+
#
29+
# Expected Behavior:
30+
# - The action should detect that PR2 (feature2) was based on feature1
31+
# - Update PR2's base branch from feature1 to main
32+
# - Merge main into feature2 to incorporate the squash commit
33+
# - Propagate the merge to feature3 as well
34+
# - Delete the merged branch (feature1)
35+
#
36+
# Verifications:
37+
# - feature1 branch is deleted from remote
38+
# - PR2 base branch is updated from feature1 to main
39+
# - PR3 base branch remains feature2 (only direct children are updated)
40+
# - feature2 and feature3 branches contain the squash merge commit
41+
# - PR diffs show the correct changes relative to their new bases
42+
#
43+
# SCENARIO 2: Conflict Handling (Steps 8-13)
44+
# ------------------------------------------
45+
# Tests the action's behavior when a merge conflict occurs.
46+
#
47+
# Setup:
48+
# - After Scenario 1, modify line 7 on feature3 and push
49+
# - Also modify line 7 on main with different content (creating a conflict)
50+
#
51+
# Action Trigger:
52+
# - Squash merge PR2 (feature2) into main
53+
#
54+
# Expected Behavior:
55+
# - The action attempts to merge main into feature3
56+
# - Detects a merge conflict (both modified line 7 differently)
57+
# - Does NOT push any conflicted state to the remote
58+
# - Posts a comment on PR3 explaining the conflict
59+
# - Adds a label "autorestack-needs-conflict-resolution" to PR3
60+
# - Updates PR3's base branch to main (even though merge failed)
61+
# - Exits with success (conflict is handled gracefully, not a failure)
62+
#
63+
# Verifications:
64+
# - feature2 branch is deleted from remote
65+
# - PR3 base branch is updated to main
66+
# - Conflict comment exists on PR3
67+
# - Conflict label "autorestack-needs-conflict-resolution" exists on PR3
68+
# - feature3 branch was NOT updated (still at pre-conflict SHA)
69+
#
70+
# Manual Conflict Resolution (Steps 12-13):
71+
# - Test simulates user resolving the conflict manually
72+
# - Merge main into feature3, resolve conflict (keep feature3's changes)
73+
# - Push the resolved branch
74+
# - Verify the resolved state is correct
75+
#
76+
# =============================================================================
677
set -e # Exit immediately if a command exits with a non-zero status.
778
# set -x # Debugging: print commands as they are executed
879
# --- Configuration ---
@@ -420,6 +491,7 @@ FEATURE3_CONFLICT_COMMIT_SHA=$(git rev-parse HEAD) # Store this SHA
420491
log_cmd git push origin feature3
421492
# Change line 7 on main differently - this will conflict when rebasing feature3 after PR2 merge
422493
log_cmd git checkout main
494+
log_cmd git pull origin main # Pull latest changes from PR1 merge
423495
sed -i '7s/.*/Main conflicting change line 7/' file.txt
424496
log_cmd git add file.txt
425497
log_cmd git commit -m "Conflict: Modify line 7 on main"

0 commit comments

Comments
 (0)