77 assertContains ,
88 loginAsCustomer ,
99 assertNotContains ,
10+ getSessionCookie ,
1011} from '../test/helpers.ts'
1112
1213describe ( 'cart handlers' , ( ) => {
@@ -36,7 +37,7 @@ describe('cart handlers', () => {
3637 assertNotContains ( html , 'Heavy Metal Guitar Riffs' )
3738
3839 // First, add item to cart to get a session
39- await router . fetch ( 'http://localhost:3000/cart/api/add' , {
40+ response = await router . fetch ( 'http://localhost:3000/cart/api/add' , {
4041 method : 'POST' ,
4142 body : new URLSearchParams ( {
4243 bookId : '002' ,
@@ -47,6 +48,7 @@ describe('cart handlers', () => {
4748 } ,
4849 redirect : 'manual' ,
4950 } )
51+ sessionCookie = getSessionCookie ( response ) !
5052
5153 // Now view cart with session
5254 request = requestWithSession ( 'http://localhost:3000/cart' , sessionCookie )
@@ -62,7 +64,7 @@ describe('cart handlers', () => {
6264 let sessionCookie = await loginAsCustomer ( router )
6365
6466 // Add first item
65- await router . fetch ( 'http://localhost:3000/cart/api/add' , {
67+ let response = await router . fetch ( 'http://localhost:3000/cart/api/add' , {
6668 method : 'POST' ,
6769 body : new URLSearchParams ( {
6870 bookId : '001' ,
@@ -73,6 +75,7 @@ describe('cart handlers', () => {
7375 } ,
7476 redirect : 'manual' ,
7577 } )
78+ sessionCookie = getSessionCookie ( response ) !
7679
7780 // Add second item with same session
7881 let addRequest2 = requestWithSession ( 'http://localhost:3000/cart/api/add' , sessionCookie , {
0 commit comments