@@ -574,3 +574,70 @@ test('should handle gracefully applying two conflicting branches', async ({
574574 // The modal explaining this should be visible
575575 await waitForTestId ( page , 'stacks-unapplied-toast' ) ;
576576} ) ;
577+
578+ test ( 'should update the stale selection of an unexisting branch' , async ( {
579+ page,
580+ context
581+ } , testInfo ) => {
582+ const workdir = testInfo . outputPath ( 'workdir' ) ;
583+ const configdir = testInfo . outputPath ( 'config' ) ;
584+ gitbutler = await startGitButler ( workdir , configdir , context ) ;
585+
586+ await gitbutler . runScript ( 'project-with-remote-branches.sh' ) ;
587+ // Apply branch1
588+ await gitbutler . runScript ( 'apply-upstream-branch.sh' , [ 'branch1' , 'local-clone' ] ) ;
589+
590+ await page . goto ( '/' ) ;
591+
592+ // Should load the workspace
593+ await waitForTestId ( page , 'workspace-view' ) ;
594+
595+ // Navigate to branches page
596+ await clickByTestId ( page , 'navigation-branches-button' ) ;
597+ let header = await waitForTestId ( page , 'target-commit-list-header' ) ;
598+
599+ await expect ( header ) . toContainText ( 'origin/master' ) ;
600+
601+ let branchListCards = getByTestId ( page , 'branch-list-card' ) ;
602+ await expect ( branchListCards ) . toHaveCount ( 3 ) ;
603+
604+ // Select the branch1
605+ let firstBranchCard = branchListCards . filter ( { hasText : 'branch1' } ) ;
606+ await expect ( firstBranchCard ) . toBeVisible ( ) ;
607+ await firstBranchCard . click ( ) ;
608+
609+ // Go back to the workspace
610+ await clickByTestId ( page , 'navigation-workspace-button' ) ;
611+ await waitForTestId ( page , 'workspace-view' ) ;
612+
613+ // There should be one stack applied
614+ const stacks = getByTestId ( page , 'stack' ) ;
615+ await expect ( stacks ) . toHaveCount ( 1 ) ;
616+
617+ // Branch one was merged in the forge
618+ await gitbutler . runScript ( 'merge-upstream-branch-to-base.sh' , [ 'branch1' ] ) ;
619+
620+ // Click the sync button
621+ await clickByTestId ( page , 'sync-button' ) ;
622+
623+ // Update the workspace
624+ await clickByTestId ( page , 'integrate-upstream-commits-button' ) ;
625+ await clickByTestId ( page , 'integrate-upstream-action-button' ) ;
626+ await waitForTestIdToNotExist ( page , 'integrate-upstream-action-button' ) ;
627+
628+ // There should be no stacks
629+ await waitForTestIdToNotExist ( page , 'stack' ) ;
630+
631+ // Navigate to branches page
632+ await clickByTestId ( page , 'navigation-branches-button' ) ;
633+ await waitForTestId ( page , 'branches-view' ) ;
634+
635+ header = await waitForTestId ( page , 'target-commit-list-header' ) ;
636+
637+ await expect ( header ) . toContainText ( 'origin/master' ) ;
638+ // The previously selected branch1 should not be selected anymore
639+ branchListCards = getByTestId ( page , 'branch-list-card' ) ;
640+ await expect ( branchListCards ) . toHaveCount ( 2 ) ;
641+ firstBranchCard = branchListCards . filter ( { hasText : 'branch1' } ) ;
642+ await expect ( firstBranchCard ) . not . toBeVisible ( ) ;
643+ } ) ;
0 commit comments