@@ -79,6 +79,56 @@ test('should handle the update of workspace with integrated branch gracefully',
7979 await waitForTestIdToNotExist ( page , 'stack' ) ;
8080} ) ;
8181
82+ test ( 'should handle the update of workspace with integrated parent branch in stack gracefully' , async ( {
83+ page,
84+ context
85+ } , testInfo ) => {
86+ const workdir = testInfo . outputPath ( 'workdir' ) ;
87+ const configdir = testInfo . outputPath ( 'config' ) ;
88+ gitbutler = await startGitButler ( workdir , configdir , context ) ;
89+
90+ await gitbutler . runScript ( 'project-with-remote-branches.sh' ) ;
91+ // Apply branch1
92+ await gitbutler . runScript ( 'apply-upstream-branch.sh' , [ 'branch1' , 'local-clone' ] ) ;
93+ await gitbutler . runScript ( 'apply-upstream-branch.sh' , [ 'branch3' , 'local-clone' ] ) ;
94+ await gitbutler . runScript ( 'move-branch.sh' , [ 'branch3' , 'branch1' , 'local-clone' ] ) ;
95+
96+ await page . goto ( '/' ) ;
97+
98+ // Should load the workspace
99+ await waitForTestId ( page , 'workspace-view' ) ;
100+
101+ // There should be one stack applied
102+ let stacks = getByTestId ( page , 'stack' ) ;
103+ await expect ( stacks ) . toHaveCount ( 1 ) ;
104+ let branchCards = getByTestId ( page , 'branch-card' ) ;
105+ await expect ( branchCards ) . toHaveCount ( 2 ) ;
106+
107+ // Branch one was merged in the forge
108+ await gitbutler . runScript ( 'merge-upstream-branch-to-base.sh' , [ 'branch1' ] ) ;
109+
110+ // Click the sync button
111+ await clickByTestId ( page , 'sync-button' ) ;
112+
113+ // Update the workspace
114+ await clickByTestId ( page , 'integrate-upstream-commits-button' ) ;
115+
116+ // The staus of the branch1 should be "Integrated"
117+ const branch1Status = page . locator ( '[data-integration-row-branch-name="branch1"]' ) . first ( ) ;
118+ await branch1Status . waitFor ( ) ;
119+ const statusBadge = branch1Status . getByTestId ( 'integrate-upstream-series-row-status-badge' ) ;
120+ await statusBadge . waitFor ( ) ;
121+ await expect ( statusBadge ) . toHaveText ( 'Integrated' ) ;
122+
123+ await clickByTestId ( page , 'integrate-upstream-action-button' ) ;
124+
125+ // There should be one stack left with one branch
126+ stacks = getByTestId ( page , 'stack' ) ;
127+ await expect ( stacks ) . toHaveCount ( 1 ) ;
128+ branchCards = getByTestId ( page , 'branch-card' ) ;
129+ await expect ( branchCards ) . toHaveCount ( 1 ) ;
130+ } ) ;
131+
82132test ( 'should handle the update of the workspace with multiple stacks gracefully' , async ( {
83133 page,
84134 context
0 commit comments