@@ -5649,6 +5649,84 @@ Failed to publish your Function. Got error: Uncaught TypeError: a is not a funct
56495649 expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
56505650 } ) ;
56515651 } ) ;
5652+
5653+ describe ( "deploys using redirected configs" , ( ) => {
5654+ let fooProjectDetailsChecked = false ;
5655+
5656+ beforeEach ( ( ) => {
5657+ fooProjectDetailsChecked = false ;
5658+ mkdirSync ( "public" ) ;
5659+ mkdirSync ( "dist" ) ;
5660+ mkdirSync ( ".wrangler/deploy" , { recursive : true } ) ;
5661+ writeFileSync (
5662+ ".wrangler/deploy/config.json" ,
5663+ JSON . stringify ( { configPath : "../../dist/wrangler.json" } )
5664+ ) ;
5665+ writeFileSync (
5666+ "dist/wrangler.json" ,
5667+ JSON . stringify ( {
5668+ compatibility_date : "2025-01-01" ,
5669+ name : "foo" ,
5670+ pages_build_output_dir : "../public" ,
5671+ } )
5672+ ) ;
5673+
5674+ simulateServer ( async ( ) => { } ) ;
5675+
5676+ msw . use (
5677+ http . get (
5678+ "*/accounts/:accountId/pages/projects/foo" ,
5679+ async ( { params } ) => {
5680+ expect ( params . accountId ) . toEqual ( "some-account-id" ) ;
5681+
5682+ fooProjectDetailsChecked = true ;
5683+
5684+ return HttpResponse . json (
5685+ {
5686+ success : true ,
5687+ errors : [ ] ,
5688+ messages : [ ] ,
5689+ result : {
5690+ production_branch : "main" ,
5691+ deployment_configs : {
5692+ production : { } ,
5693+ preview : { } ,
5694+ } ,
5695+ } as Partial < Project > ,
5696+ } ,
5697+ { status : 200 }
5698+ ) ;
5699+ }
5700+ )
5701+ ) ;
5702+ } ) ;
5703+
5704+ afterEach ( ( ) => {
5705+ expect ( fooProjectDetailsChecked ) . toBe ( true ) ;
5706+ } ) ;
5707+
5708+ const expectedInfo = dedent `
5709+ Using redirected Wrangler configuration.
5710+ - Configuration being used: "dist/wrangler.json"
5711+ - Original user's configuration: "<no user config found>"
5712+ - Deploy configuration file: ".wrangler/deploy/config.json"
5713+ ` ;
5714+
5715+ it ( "should work without a branch specified (i.e. defaulting to the production environment)" , async ( ) => {
5716+ await runWrangler ( "pages deploy" ) ;
5717+ expect ( std . info ) . toContain ( expectedInfo ) ;
5718+ } ) ;
5719+
5720+ it ( "should work with the main branch (i.e. the production environment)" , async ( ) => {
5721+ await runWrangler ( "pages deploy --branch main" ) ;
5722+ expect ( std . info ) . toContain ( expectedInfo ) ;
5723+ } ) ;
5724+
5725+ it ( "should work with any branch (i.e. the preview environment)" , async ( ) => {
5726+ await runWrangler ( "pages deploy --branch my-branch" ) ;
5727+ expect ( std . info ) . toContain ( expectedInfo ) ;
5728+ } ) ;
5729+ } ) ;
56525730} ) ;
56535731
56545732function mockGetProjectHandler (
0 commit comments