Skip to content

Commit c74195c

Browse files
chore(wrangler): Fix failing e2e tests (#7585)
This commit fixed some e2e tests that started failing after #7476
1 parent fb819f9 commit c74195c

File tree

1 file changed

+66
-25
lines changed

1 file changed

+66
-25
lines changed

packages/wrangler/e2e/dev.test.ts

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/Invalid Routes:/);
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+
/Warning: The following routes will attempt to serve Assets on a configured path:/
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(/Invalid Routes:/);
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+
/Warning: The following routes will attempt to serve Assets on a configured path:/
1901+
);
1902+
});
18621903
}
18631904
);
18641905
});

0 commit comments

Comments
 (0)