@@ -4444,6 +4444,143 @@ addEventListener('fetch', event => {});`
44444444 ` ) ;
44454445 } ) ;
44464446
4447+ it ( "should warn when using smart placement with assets-first" , async ( ) => {
4448+ const assets = [
4449+ { filePath : ".assetsignore" , content : "*.bak\nsub-dir" } ,
4450+ { filePath : "file-1.txt" , content : "Content of file-1" } ,
4451+ { filePath : "file-2.bak" , content : "Content of file-2" } ,
4452+ { filePath : "file-3.txt" , content : "Content of file-3" } ,
4453+ { filePath : "sub-dir/file-4.bak" , content : "Content of file-4" } ,
4454+ { filePath : "sub-dir/file-5.txt" , content : "Content of file-5" } ,
4455+ ] ;
4456+ writeAssets ( assets , "assets" ) ;
4457+ writeWranglerConfig ( {
4458+ assets : {
4459+ directory : "assets" ,
4460+ experimental_serve_directly : true ,
4461+ } ,
4462+ placement : {
4463+ mode : "smart" ,
4464+ } ,
4465+ } ) ;
4466+ const bodies : AssetManifest [ ] = [ ] ;
4467+ await mockAUSRequest ( bodies ) ;
4468+ mockSubDomainRequest ( ) ;
4469+ mockUploadWorkerRequest ( {
4470+ expectedAssets : {
4471+ jwt : "<<aus-completion-token>>" ,
4472+ config : {
4473+ serve_directly : true ,
4474+ } ,
4475+ } ,
4476+ expectedType : "none" ,
4477+ } ) ;
4478+
4479+ await runWrangler ( "deploy" ) ;
4480+
4481+ expect ( std . warn ) . toMatchInlineSnapshot ( `
4482+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mUsing assets with smart placement turned on may result in poor performance.[0m
4483+
4484+ "
4485+ ` ) ;
4486+ } ) ;
4487+
4488+ it ( "should warn when using smart placement with assets-first" , async ( ) => {
4489+ const assets = [
4490+ { filePath : ".assetsignore" , content : "*.bak\nsub-dir" } ,
4491+ { filePath : "file-1.txt" , content : "Content of file-1" } ,
4492+ { filePath : "file-2.bak" , content : "Content of file-2" } ,
4493+ { filePath : "file-3.txt" , content : "Content of file-3" } ,
4494+ { filePath : "sub-dir/file-4.bak" , content : "Content of file-4" } ,
4495+ { filePath : "sub-dir/file-5.txt" , content : "Content of file-5" } ,
4496+ ] ;
4497+ writeAssets ( assets , "assets" ) ;
4498+ writeWranglerConfig ( {
4499+ assets : {
4500+ directory : "assets" ,
4501+ experimental_serve_directly : true ,
4502+ } ,
4503+ placement : {
4504+ mode : "smart" ,
4505+ } ,
4506+ } ) ;
4507+ const bodies : AssetManifest [ ] = [ ] ;
4508+ await mockAUSRequest ( bodies ) ;
4509+ mockSubDomainRequest ( ) ;
4510+ mockUploadWorkerRequest ( {
4511+ expectedAssets : {
4512+ jwt : "<<aus-completion-token>>" ,
4513+ config : {
4514+ serve_directly : true ,
4515+ } ,
4516+ } ,
4517+ expectedType : "none" ,
4518+ } ) ;
4519+
4520+ await runWrangler ( "deploy" ) ;
4521+
4522+ expect ( std . warn ) . toMatchInlineSnapshot ( `
4523+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mUsing assets with smart placement turned on may result in poor performance.[0m
4524+
4525+ "
4526+ ` ) ;
4527+ } ) ;
4528+
4529+ it ( "should warn if experimental_serve_directly=false but no binding is provided" , async ( ) => {
4530+ const assets = [
4531+ { filePath : ".assetsignore" , content : "*.bak\nsub-dir" } ,
4532+ { filePath : "file-1.txt" , content : "Content of file-1" } ,
4533+ { filePath : "file-2.bak" , content : "Content of file-2" } ,
4534+ { filePath : "file-3.txt" , content : "Content of file-3" } ,
4535+ { filePath : "sub-dir/file-4.bak" , content : "Content of file-4" } ,
4536+ { filePath : "sub-dir/file-5.txt" , content : "Content of file-5" } ,
4537+ ] ;
4538+ writeAssets ( assets , "assets" ) ;
4539+ writeWorkerSource ( { format : "js" } ) ;
4540+ writeWranglerConfig ( {
4541+ main : "index.js" ,
4542+ assets : {
4543+ directory : "assets" ,
4544+ experimental_serve_directly : false ,
4545+ } ,
4546+ } ) ;
4547+ const bodies : AssetManifest [ ] = [ ] ;
4548+ await mockAUSRequest ( bodies ) ;
4549+ mockSubDomainRequest ( ) ;
4550+ mockUploadWorkerRequest ( {
4551+ expectedAssets : {
4552+ jwt : "<<aus-completion-token>>" ,
4553+ config : {
4554+ serve_directly : false ,
4555+ } ,
4556+ } ,
4557+ expectedMainModule : "index.js" ,
4558+ } ) ;
4559+
4560+ await runWrangler ( "deploy" ) ;
4561+
4562+ expect ( std . warn ) . toMatchInlineSnapshot ( `
4563+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mexperimental_serve_directly=false but no assets.binding provided.[0m
4564+
4565+ "
4566+ ` ) ;
4567+ } ) ;
4568+
4569+ it ( "should error if an experimental_serve_directly is false without providing a user Worker" , async ( ) => {
4570+ writeWranglerConfig ( {
4571+ assets : {
4572+ directory : "xyz" ,
4573+ experimental_serve_directly : false ,
4574+ } ,
4575+ } ) ;
4576+
4577+ await expect ( runWrangler ( "deploy" ) ) . rejects
4578+ . toThrowErrorMatchingInlineSnapshot ( `
4579+ [Error: Cannot set experimental_serve_directly=false without a Worker script.
4580+ Please remove experimental_serve_directly from your configuration file, or provide a Worker script in your configuration file (\`main\`).]
4581+ ` ) ;
4582+ } ) ;
4583+
44474584 it ( "should be able to upload files with special characters in filepaths" , async ( ) => {
44484585 // NB windows will disallow these characters in file paths anyway < > : " / \ | ? *
44494586 const assets = [
0 commit comments