Skip to content

Commit 13a3501

Browse files
authored
chore(remix-node): bump @remix-run/web-fetch to latest (#6120)
Signed-off-by: Logan McAnsh <[email protected]>
1 parent 8f4a161 commit 13a3501

File tree

3 files changed

+37
-119
lines changed

3 files changed

+37
-119
lines changed

integration/error-data-request-test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,13 @@ test.describe("ErrorBoundary", () => {
129129
});
130130

131131
test("returns a 405 x-remix-error on a data fetch with a bad method", async () => {
132-
let response = await fixture.requestData(
133-
`/loader-return-json`,
134-
"routes/loader-return-json",
135-
{
132+
expect(() =>
133+
fixture.requestData("/loader-return-json", "routes/loader-return-json", {
136134
method: "TRACE",
137-
}
135+
})
136+
).rejects.toThrowError(
137+
`Failed to construct 'Request': 'TRACE' HTTP method is unsupported.`
138138
);
139-
expect(response.status).toBe(405);
140-
expect(response.headers.get("X-Remix-Error")).toBe("yes");
141-
expect(await response.text()).toMatch("Unexpected Server Error");
142-
assertConsoleError('Error: Invalid request method "TRACE"');
143139
});
144140

145141
test("returns a 403 x-remix-error on a data fetch GET to a bad path", async () => {

packages/remix-express/__tests__/server-test.ts

Lines changed: 31 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ describe("express createRequestHandler", () => {
107107
});
108108

109109
let request = supertest(createApp());
110-
// note: vercel's createServerWithHelpers requires a x-now-bridge-request-id
111-
let res = await request.get("/").set({ "x-now-bridge-request-id": "2" });
112-
110+
let res = await request.get("/");
113111
expect(res.status).toBe(200);
114112
expect(res.text).toBe("hello world");
115113
});
@@ -159,88 +157,41 @@ describe("express createRequestHandler", () => {
159157
describe("express createRemixHeaders", () => {
160158
describe("creates fetch headers from express headers", () => {
161159
it("handles empty headers", () => {
162-
expect(createRemixHeaders({})).toMatchInlineSnapshot(`
163-
Headers {
164-
Symbol(query): Array [],
165-
Symbol(context): null,
166-
}
167-
`);
160+
let headers = createRemixHeaders({});
161+
expect(headers.raw()).toMatchInlineSnapshot(`Object {}`);
168162
});
169163

170164
it("handles simple headers", () => {
171-
expect(createRemixHeaders({ "x-foo": "bar" })).toMatchInlineSnapshot(`
172-
Headers {
173-
Symbol(query): Array [
174-
"x-foo",
175-
"bar",
176-
],
177-
Symbol(context): null,
178-
}
179-
`);
165+
let headers = createRemixHeaders({ "x-foo": "bar" });
166+
expect(headers.get("x-foo")).toBe("bar");
180167
});
181168

182169
it("handles multiple headers", () => {
183-
expect(createRemixHeaders({ "x-foo": "bar", "x-bar": "baz" }))
184-
.toMatchInlineSnapshot(`
185-
Headers {
186-
Symbol(query): Array [
187-
"x-foo",
188-
"bar",
189-
"x-bar",
190-
"baz",
191-
],
192-
Symbol(context): null,
193-
}
194-
`);
170+
let headers = createRemixHeaders({ "x-foo": "bar", "x-bar": "baz" });
171+
expect(headers.get("x-foo")).toBe("bar");
172+
expect(headers.get("x-bar")).toBe("baz");
195173
});
196174

197175
it("handles headers with multiple values", () => {
198-
expect(createRemixHeaders({ "x-foo": "bar, baz" }))
199-
.toMatchInlineSnapshot(`
200-
Headers {
201-
Symbol(query): Array [
202-
"x-foo",
203-
"bar, baz",
204-
],
205-
Symbol(context): null,
206-
}
207-
`);
208-
});
209-
210-
it("handles headers with multiple values and multiple headers", () => {
211-
expect(createRemixHeaders({ "x-foo": "bar, baz", "x-bar": "baz" }))
212-
.toMatchInlineSnapshot(`
213-
Headers {
214-
Symbol(query): Array [
215-
"x-foo",
216-
"bar, baz",
217-
"x-bar",
218-
"baz",
219-
],
220-
Symbol(context): null,
221-
}
222-
`);
176+
let headers = createRemixHeaders({
177+
"x-foo": ["bar", "baz"],
178+
"x-bar": "baz",
179+
});
180+
expect(headers.getAll("x-foo")).toEqual(["bar", "baz"]);
181+
expect(headers.get("x-bar")).toBe("baz");
223182
});
224183

225184
it("handles multiple set-cookie headers", () => {
226-
expect(
227-
createRemixHeaders({
228-
"set-cookie": [
229-
"__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax",
230-
"__other=some_other_value; Path=/; Secure; HttpOnly; MaxAge=3600; SameSite=Lax",
231-
],
232-
})
233-
).toMatchInlineSnapshot(`
234-
Headers {
235-
Symbol(query): Array [
236-
"set-cookie",
237-
"__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax",
238-
"set-cookie",
239-
"__other=some_other_value; Path=/; Secure; HttpOnly; MaxAge=3600; SameSite=Lax",
240-
],
241-
Symbol(context): null,
242-
}
243-
`);
185+
let headers = createRemixHeaders({
186+
"set-cookie": [
187+
"__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax",
188+
"__other=some_other_value; Path=/; Secure; HttpOnly; Expires=Wed, 21 Oct 2015 07:28:00 GMT; SameSite=Lax",
189+
],
190+
});
191+
expect(headers.getAll("set-cookie")).toEqual([
192+
"__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax",
193+
"__other=some_other_value; Path=/; Secure; HttpOnly; Expires=Wed, 21 Oct 2015 07:28:00 GMT; SameSite=Lax",
194+
]);
244195
});
245196
});
246197
});
@@ -259,41 +210,12 @@ describe("express createRemixRequest", () => {
259210
});
260211
let expressResponse = createResponse();
261212

262-
expect(createRemixRequest(expressRequest, expressResponse))
263-
.toMatchInlineSnapshot(`
264-
NodeRequest {
265-
"agent": undefined,
266-
"compress": true,
267-
"counter": 0,
268-
"follow": 20,
269-
"highWaterMark": 16384,
270-
"insecureHTTPParser": false,
271-
"size": 0,
272-
Symbol(Body internals): Object {
273-
"body": null,
274-
"boundary": null,
275-
"disturbed": false,
276-
"error": null,
277-
"size": 0,
278-
"type": null,
279-
},
280-
Symbol(Request internals): Object {
281-
"credentials": "same-origin",
282-
"headers": Headers {
283-
Symbol(query): Array [
284-
"cache-control",
285-
"max-age=300, s-maxage=3600",
286-
"host",
287-
"localhost:3000",
288-
],
289-
Symbol(context): null,
290-
},
291-
"method": "GET",
292-
"parsedURL": "http://localhost:3000/foo/bar",
293-
"redirect": "follow",
294-
"signal": AbortSignal {},
295-
},
296-
}
297-
`);
213+
let remixRequest = createRemixRequest(expressRequest, expressResponse);
214+
215+
expect(remixRequest.method).toBe("GET");
216+
expect(remixRequest.headers.get("cache-control")).toBe(
217+
"max-age=300, s-maxage=3600"
218+
);
219+
expect(remixRequest.headers.get("host")).toBe("localhost:3000");
298220
});
299221
});

packages/remix-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"dependencies": {
2020
"@remix-run/server-runtime": "1.15.0",
21-
"@remix-run/web-fetch": "^4.3.2",
21+
"@remix-run/web-fetch": "^4.3.4",
2222
"@remix-run/web-file": "^3.0.2",
2323
"@remix-run/web-stream": "^1.0.3",
2424
"@web3-storage/multipart-parser": "^1.0.0",

0 commit comments

Comments
 (0)