@@ -4,7 +4,7 @@ import { UNSAFE_ServerMode as ServerMode } from "react-router";
4
4
import { createFixture , js } from "./helpers/create-fixture.js" ;
5
5
import type { Fixture } from "./helpers/create-fixture.js" ;
6
6
7
- test . describe . skip ( "headers export" , ( ) => {
7
+ test . describe ( "headers export" , ( ) => {
8
8
let ROOT_HEADER_KEY = "X-Test" ;
9
9
let ROOT_HEADER_VALUE = "SUCCESS" ;
10
10
let ACTION_HKEY = "X-Test-Action" ;
@@ -416,4 +416,57 @@ test.describe.skip("headers export", () => {
416
416
] )
417
417
) ;
418
418
} ) ;
419
+
420
+ test ( "does not duplicate set-cookie headers also returned via headers() function" , async ( ) => {
421
+ let fixture = await createFixture (
422
+ {
423
+ files : {
424
+ "app/root.tsx" : js `
425
+ import { Links, Meta, Outlet, Scripts } from "react-router";
426
+
427
+ export default function Root() {
428
+ return (
429
+ <html lang="en">
430
+ <head>
431
+ <Meta />
432
+ <Links />
433
+ </head>
434
+ <body>
435
+ <Outlet />
436
+ <Scripts />
437
+ </body>
438
+ </html>
439
+ );
440
+ }
441
+ ` ,
442
+
443
+ "app/routes/_index.tsx" : js `
444
+ export function headers({ loaderHeaders }) {
445
+ return loaderHeaders;
446
+ }
447
+
448
+ export function loader() {
449
+ return new Response(null, {
450
+ headers: {
451
+ "X-Test": "value",
452
+ "Set-Cookie": "cookie=yum"
453
+ }
454
+ })
455
+ }
456
+
457
+ export default function Index() {
458
+ return <div>Heyo!</div>
459
+ }
460
+ ` ,
461
+ } ,
462
+ } ,
463
+ ServerMode . Test
464
+ ) ;
465
+ let response = await fixture . requestDocument ( "/" ) ;
466
+ expect ( [ ...response . headers . entries ( ) ] ) . toEqual ( [
467
+ [ "content-type" , "text/html" ] ,
468
+ [ "set-cookie" , "cookie=yum" ] ,
469
+ [ "x-test" , "value" ] ,
470
+ ] ) ;
471
+ } ) ;
419
472
} ) ;
0 commit comments