@@ -165,6 +165,17 @@ const connectByotWithSingleRepo = async (page: Page) => {
165165 } )
166166 } )
167167
168+ await page . route (
169+ 'https://api.github.com/repos/knightedcodemonkey/develop/branches**' ,
170+ async route => {
171+ await route . fulfill ( {
172+ status : 200 ,
173+ contentType : 'application/json' ,
174+ body : JSON . stringify ( [ { name : 'main' } , { name : 'release' } ] ) ,
175+ } )
176+ } ,
177+ )
178+
168179 await page . locator ( '#github-token-input' ) . fill ( 'github_pat_fake_chat_1234567890' )
169180 await page . locator ( '#github-token-add' ) . click ( )
170181 await expect ( page . locator ( '#status' ) ) . toHaveText ( 'Loaded 1 writable repositories' )
@@ -717,6 +728,82 @@ test('Open PR drawer confirms and submits component/styles filepaths', async ({
717728 )
718729} )
719730
731+ test ( 'Open PR drawer base dropdown updates from mocked repo branches' , async ( {
732+ page,
733+ } ) => {
734+ const branchRequestUrls : string [ ] = [ ]
735+
736+ await page . route ( 'https://api.github.com/user/repos**' , async route => {
737+ await route . fulfill ( {
738+ status : 200 ,
739+ contentType : 'application/json' ,
740+ body : JSON . stringify ( [
741+ {
742+ id : 2 ,
743+ owner : { login : 'knightedcodemonkey' } ,
744+ name : 'develop' ,
745+ full_name : 'knightedcodemonkey/develop' ,
746+ default_branch : 'main' ,
747+ permissions : { push : true } ,
748+ } ,
749+ {
750+ id : 1 ,
751+ owner : { login : 'knightedcodemonkey' } ,
752+ name : 'css' ,
753+ full_name : 'knightedcodemonkey/css' ,
754+ default_branch : 'stable' ,
755+ permissions : { push : true } ,
756+ } ,
757+ ] ) ,
758+ } )
759+ } )
760+
761+ await page . route ( 'https://api.github.com/repos/**/branches**' , async route => {
762+ const url = route . request ( ) . url ( )
763+ branchRequestUrls . push ( url )
764+
765+ const branchNames = url . includes ( '/repos/knightedcodemonkey/css/branches' )
766+ ? [ 'stable' , 'release/1.x' ]
767+ : [ 'main' , 'develop-next' ]
768+
769+ await route . fulfill ( {
770+ status : 200 ,
771+ contentType : 'application/json' ,
772+ body : JSON . stringify ( branchNames . map ( name => ( { name } ) ) ) ,
773+ } )
774+ } )
775+
776+ await waitForAppReady ( page , `${ appEntryPath } ?feature-ai=true` )
777+
778+ await page . locator ( '#github-token-input' ) . fill ( 'github_pat_fake_1234567890' )
779+ await page . locator ( '#github-token-add' ) . click ( )
780+ await expect ( page . locator ( '#status' ) ) . toHaveText ( 'Loaded 2 writable repositories' )
781+
782+ await ensureOpenPrDrawerOpen ( page )
783+
784+ const repoSelect = page . locator ( '#github-pr-repo-select' )
785+ const baseSelect = page . locator ( '#github-pr-base-branch' )
786+
787+ await repoSelect . selectOption ( 'knightedcodemonkey/develop' )
788+ await expect ( baseSelect ) . toHaveValue ( 'main' )
789+ await expect ( baseSelect . locator ( 'option' ) ) . toHaveText ( [ 'main' , 'develop-next' ] )
790+
791+ await repoSelect . selectOption ( 'knightedcodemonkey/css' )
792+ await expect ( baseSelect ) . toHaveValue ( 'stable' )
793+ await expect ( baseSelect . locator ( 'option' ) ) . toHaveText ( [ 'stable' , 'release/1.x' ] )
794+
795+ expect (
796+ branchRequestUrls . some ( url =>
797+ url . includes ( 'https://api.github.com/repos/knightedcodemonkey/develop/branches' ) ,
798+ ) ,
799+ ) . toBe ( true )
800+ expect (
801+ branchRequestUrls . some ( url =>
802+ url . includes ( 'https://api.github.com/repos/knightedcodemonkey/css/branches' ) ,
803+ ) ,
804+ ) . toBe ( true )
805+ } )
806+
720807test ( 'Open PR drawer validates unsafe filepaths' , async ( { page } ) => {
721808 await waitForAppReady ( page , `${ appEntryPath } ?feature-ai=true` )
722809 await connectByotWithSingleRepo ( page )
0 commit comments