From 8f176c1cd54a2e141c5d9c85b6cb665ef2d69385 Mon Sep 17 00:00:00 2001 From: Kimura Yoichi <100304422+yckimura@users.noreply.github.com> Date: Wed, 18 Feb 2026 19:52:59 +0900 Subject: [PATCH] test(cookies): add test case for useCookie during SSR redirect --- playground/pages/cookie-with-redirect.vue | 14 ++++++++++++++ test/bridge.test.ts | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 playground/pages/cookie-with-redirect.vue diff --git a/playground/pages/cookie-with-redirect.vue b/playground/pages/cookie-with-redirect.vue new file mode 100644 index 000000000..7b1f02a05 --- /dev/null +++ b/playground/pages/cookie-with-redirect.vue @@ -0,0 +1,14 @@ + + + diff --git a/test/bridge.test.ts b/test/bridge.test.ts index 29ad94b6b..ad1e12094 100644 --- a/test/bridge.test.ts +++ b/test/bridge.test.ts @@ -54,6 +54,20 @@ describe('nuxt composables', () => { expect(await extractCookie()).toEqual({ foo: 'baz' }) await page.close() }) + + it('should respond with set-cookie header even when SSR redirect occurs', async () => { + const res = await fetch('/cookie-with-redirect', { redirect: 'manual' }) + + // Verify redirect occurred + expect(res.status).toBe(302) + expect(res.headers.get('location')).toEqual('/') + + // Verify cookies were set + const cookies = res.headers.get('set-cookie') + expect(cookies).toBeTruthy() + expect(cookies).toContain('redirect-test=foo') + }) + it('error should be render', async () => { const html = await $fetch('/async-data')