From 9628d67aacb9818f07876534354858c50bd3c6b3 Mon Sep 17 00:00:00 2001 From: Carmen Popoviciu Date: Thu, 19 Sep 2024 17:11:05 +0200 Subject: [PATCH] fix: PR feedback --- packages/wrangler/e2e/dev.test.ts | 62 ++++++++++++++++++------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/packages/wrangler/e2e/dev.test.ts b/packages/wrangler/e2e/dev.test.ts index aa5e11da812f..17548fd056c3 100644 --- a/packages/wrangler/e2e/dev.test.ts +++ b/packages/wrangler/e2e/dev.test.ts @@ -1105,13 +1105,14 @@ describe("watch mode", () => { const { url } = await worker.waitForReady(); // verify response from Asset Worker - let { response } = await fetchWithETag(`${url}/index.html`, {}); + let response = await fetch(`${url}/index.html`); + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); // verify no response from route that will be handled by the // User Worker in the future - ({ response } = await fetchWithETag(`${url}/hey`, {})); - expect(await response.status).toBe(404); + response = await fetch(`${url}/hey`); + expect(response.status).toBe(404); await helper.seed({ "wrangler.toml": dedent` @@ -1132,10 +1133,14 @@ describe("watch mode", () => { await worker.waitForReload(); - ({ response } = await fetchWithETag(`${url}/index.html`, {})); + // verify we still get the correct response for the Asset Worker + response = await fetch(`${url}/index.html`); + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); - ({ response } = await fetchWithETag(`${url}/hey`, {})); + // verify response from User Worker + response = await fetch(`${url}/hey`); + expect(response.status).toBe(200); expect(await response.text()).toBe("Hello from user Worker!"); }); @@ -1164,11 +1169,13 @@ describe("watch mode", () => { const { url } = await worker.waitForReady(); // verify response from Asset Worker - let { response } = await fetchWithETag(`${url}/index.html`, {}); + let response = await fetch(`${url}/index.html`); + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); // verify response from User Worker - ({ response } = await fetchWithETag(`${url}/hey`, {})); + response = await fetch(`${url}/hey`); + expect(response.status).toBe(200); expect(await response.text()).toBe("Hello from user Worker!"); await helper.seed({ @@ -1184,12 +1191,13 @@ describe("watch mode", () => { await worker.waitForReload(); // verify we still get the correct response from Asset Worker - ({ response } = await fetchWithETag(`${url}/index.html`, {})); + response = await fetch(`${url}/index.html`); + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); // verify we no longer get a response from the User Worker - ({ response } = await fetchWithETag(`${url}/hey`, {})); - expect(await response.status).toBe(404); + response = await fetch(`${url}/hey`); + expect(response.status).toBe(404); }); } ); @@ -1301,14 +1309,14 @@ describe("watch mode", () => { const { url } = await worker.waitForReady(); // verify response from Asset Worker - let { response } = await fetchWithETag(`${url}/index.html`, {}); + let response = await fetch(`${url}/index.html`); + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); - expect(await response.status).toBe(200); // verify no response from route that will be handled by the // User Worker in the future - ({ response } = await fetchWithETag(`${url}/hey`, {})); - expect(await response.status).toBe(404); + response = await fetch(`${url}/hey`); + expect(response.status).toBe(404); await helper.seed({ "wrangler.toml": dedent` @@ -1320,13 +1328,15 @@ describe("watch mode", () => { await worker.waitForReload(); - ({ response } = await fetchWithETag(`${url}/index.html`, {})); + // verify response from Asset Worker + response = await fetch(`${url}/index.html`); + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); - expect(await response.status).toBe(200); - ({ response } = await fetchWithETag(`${url}/hey`, {})); + // verify response from User Worker + response = await fetch(`${url}/hey`); + expect(response.status).toBe(200); expect(await response.text()).toBe("Hello from user Worker!"); - expect(await response.status).toBe(200); }); it(`supports switching from Workers with assets to assets-only Workers during the current dev session`, async () => { @@ -1350,14 +1360,14 @@ describe("watch mode", () => { const { url } = await worker.waitForReady(); // verify response from Asset Worker - let { response } = await fetchWithETag(`${url}/index.html`, {}); + let response = await fetch(`${url}/index.html`); + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); - expect(await response.status).toBe(200); // verify response from User Worker - ({ response } = await fetchWithETag(`${url}/hey`, {})); + response = await fetch(`${url}/hey`); + expect(response.status).toBe(200); expect(await response.text()).toBe("Hello from user Worker!"); - expect(await response.status).toBe(200); await helper.seed({ "wrangler.toml": dedent` @@ -1368,14 +1378,14 @@ describe("watch mode", () => { await worker.waitForReload(); - ({ response } = await fetchWithETag(`${url}/index.html`, {})); + response = await fetch(`${url}/index.html`); // verify response from Asset + expect(response.status).toBe(200); expect(await response.text()).toBe("

Hello Workers + Assets

"); - expect(await response.status).toBe(200); // verify no response from User Worker - ({ response } = await fetchWithETag(`${url}/hey`, {})); - expect(await response.status).toBe(404); + response = await fetch(`${url}/hey`); + expect(response.status).toBe(404); }); }); });