@@ -1158,7 +1158,7 @@ describe("watch mode", () => {
11581158 describe . each ( [ { cmd : "wrangler dev" } ] ) (
11591159 "Workers + Assets watch mode: $cmd" ,
11601160 ( { cmd } ) => {
1161- it ( `supports modifying existing assets during dev session and errors when invalid routes are added ` , async ( ) => {
1161+ it ( `supports modifying existing assets during dev session` , async ( ) => {
11621162 const helper = new WranglerE2ETestHelper ( ) ;
11631163 await helper . seed ( {
11641164 "wrangler.toml" : dedent `
@@ -1199,19 +1199,6 @@ describe("watch mode", () => {
11991199 ) ;
12001200 // expect a new eTag back because the content for this path has changed
12011201 expect ( response . headers . get ( "etag" ) ) . not . toBe ( originalETag ) ;
1202-
1203- // changes to routes should error while in watch mode
1204- await helper . seed ( {
1205- "wrangler.toml" : dedent `
1206- name = "${ workerName } "
1207- compatibility_date = "2023-01-01"
1208- route = "example.com/path/*"
1209-
1210- [assets]
1211- directory = "./public"
1212- ` ,
1213- } ) ;
1214- await worker . readUntil ( / I n v a l i d R o u t e s : / ) ;
12151202 } ) ;
12161203
12171204 it ( `supports adding new assets during dev session` , async ( ) => {
@@ -1662,13 +1649,48 @@ describe("watch mode", () => {
16621649 // now check assets are still fetchable
16631650 await expect ( fetchText ( url ) ) . resolves . toBe ( "Hello from Assets" ) ;
16641651 } ) ;
1652+
1653+ it ( `warns on mounted paths when routes are configured in the configuration file` , async ( ) => {
1654+ const helper = new WranglerE2ETestHelper ( ) ;
1655+ await helper . seed ( {
1656+ "wrangler.toml" : dedent `
1657+ name = "${ workerName } "
1658+ compatibility_date = "2023-01-01"
1659+
1660+ [assets]
1661+ directory = "./public"
1662+ ` ,
1663+ "public/index.html" : dedent `
1664+ <h1>Hello Workers + Assets</h1>` ,
1665+ } ) ;
1666+
1667+ const worker = helper . runLongLived ( cmd ) ;
1668+ const { url } = await worker . waitForReady ( ) ;
1669+
1670+ const { response } = await fetchWithETag ( `${ url } /index.html` , { } ) ;
1671+ expect ( await response . text ( ) ) . toBe ( "<h1>Hello Workers + Assets</h1>" ) ;
1672+
1673+ await helper . seed ( {
1674+ "wrangler.toml" : dedent `
1675+ name = "${ workerName } "
1676+ compatibility_date = "2023-01-01"
1677+ route = "example.com/path/*"
1678+
1679+ [assets]
1680+ directory = "./public"
1681+ ` ,
1682+ } ) ;
1683+ await worker . readUntil (
1684+ / W a r n i n g : T h e f o l l o w i n g r o u t e s w i l l a t t e m p t t o s e r v e A s s e t s o n a c o n f i g u r e d p a t h : /
1685+ ) ;
1686+ } ) ;
16651687 }
16661688 ) ;
16671689
16681690 describe . each ( [ { cmd : "wrangler dev --assets=dist" } ] ) (
16691691 "Workers + Assets watch mode: $cmd" ,
16701692 ( { cmd } ) => {
1671- it ( `supports modifying assets during dev session and errors when invalid routes are added ` , async ( ) => {
1693+ it ( `supports modifying assets during dev session` , async ( ) => {
16721694 const helper = new WranglerE2ETestHelper ( ) ;
16731695 await helper . seed ( {
16741696 "wrangler.toml" : dedent `
@@ -1749,16 +1771,6 @@ describe("watch mode", () => {
17491771 }
17501772 ) ) ;
17511773 expect ( response . status ) . toBe ( 404 ) ;
1752-
1753- // changes to routes should error while in watch mode
1754- await helper . seed ( {
1755- "wrangler.toml" : dedent `
1756- name = "${ workerName } "
1757- compatibility_date = "2023-01-01"
1758- route = "example.com/path/*"
1759- ` ,
1760- } ) ;
1761- await worker . readUntil ( / I n v a l i d R o u t e s : / ) ;
17621774 } ) ;
17631775
17641776 it ( `supports switching from assets-only Workers to Workers with assets during the current dev session` , async ( ) => {
@@ -1859,6 +1871,35 @@ describe("watch mode", () => {
18591871 response = await fetch ( `${ url } /hey` ) ;
18601872 expect ( response . status ) . toBe ( 404 ) ;
18611873 } ) ;
1874+
1875+ it ( `warns on mounted paths when routes are configured in the configuration file` , async ( ) => {
1876+ const helper = new WranglerE2ETestHelper ( ) ;
1877+ await helper . seed ( {
1878+ "wrangler.toml" : dedent `
1879+ name = "${ workerName } "
1880+ compatibility_date = "2023-01-01"
1881+ ` ,
1882+ "dist/index.html" : dedent `
1883+ <h1>Hello Workers + Assets</h1>` ,
1884+ } ) ;
1885+
1886+ const worker = helper . runLongLived ( cmd ) ;
1887+ const { url } = await worker . waitForReady ( ) ;
1888+
1889+ const { response } = await fetchWithETag ( `${ url } /index.html` , { } ) ;
1890+ expect ( await response . text ( ) ) . toBe ( "<h1>Hello Workers + Assets</h1>" ) ;
1891+
1892+ await helper . seed ( {
1893+ "wrangler.toml" : dedent `
1894+ name = "${ workerName } "
1895+ compatibility_date = "2023-01-01"
1896+ route = "example.com/path/*"
1897+ ` ,
1898+ } ) ;
1899+ await worker . readUntil (
1900+ / W a r n i n g : T h e f o l l o w i n g r o u t e s w i l l a t t e m p t t o s e r v e A s s e t s o n a c o n f i g u r e d p a t h : /
1901+ ) ;
1902+ } ) ;
18621903 }
18631904 ) ;
18641905} ) ;
0 commit comments