Skip to content

Commit

Permalink
fix: cookies().has() breaks in app-route (#54112)
Browse files Browse the repository at this point in the history
- Added `has` to ResponseCookies in [edge-runtime/cookies#533](vercel/edge-runtime#533)
- Upgraded edge-runtime/cookies to 3.3.0 #54117 
- Added a test case


Fixes #54005 #54111
  • Loading branch information
devjiwonchoi authored Aug 17, 2023
1 parent bd5b715 commit 0431147
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/e2e/app-dir/app-routes/app-custom-routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,16 @@ createNextDescribe(
})
})

describe('cookies().has()', () => {
it('gets the correct values', async () => {
const res = await next.fetch(bathPath + '/hooks/cookies/has')

expect(res.status).toEqual(200)

expect(await res.json()).toEqual({ hasCookie: true })
})
})

describe('redirect', () => {
it('can respond correctly', async () => {
const res = await next.fetch(bathPath + '/hooks/redirect', {
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/app-dir/app-routes/app/hooks/cookies/has/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NextResponse } from 'next/server'
import { cookies } from 'next/headers'

export async function GET() {
const c = cookies()
c.set('a', 'a')
const hasCookie = c.has('a')

return NextResponse.json({ hasCookie }) // expect { hasCookie: true }
}

0 comments on commit 0431147

Please sign in to comment.