Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for multiple cookies coming from middleware #34465

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,6 +32,15 @@ export async function middleware(request, ev) {
return next
}

if (url.pathname === '/responses/two-cookies') {
const headers = new Headers()
headers.append('set-cookie', 'foo=chocochip')
headers.append('set-cookie', 'bar=chocochip')
return new Response('cookies set', {
headers,
})
}

// Streams a basic response
if (url.pathname === '/responses/stream-a-response') {
ev.waitUntil(
Expand Down
12 changes: 12 additions & 0 deletions test/integration/middleware/core/test/index.test.js
Expand Up @@ -428,6 +428,18 @@ function redirectTests(locale = '') {
}

function responseTests(locale = '') {
it(`${locale} responds with multiple cookies`, async () => {
const res = await fetchViaHTTP(
context.appPort,
`${locale}/responses/two-cookies`
)

expect(res.headers.raw()['set-cookie']).toEqual([
'foo=chocochip',
'bar=chocochip',
])
})

it(`${locale} should stream a response`, async () => {
const res = await fetchViaHTTP(
context.appPort,
Expand Down