Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silver-camels-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@scaleway/cookie-consent': patch
---

Pass cookie options when removing consent for a specific category
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const CookieConsentProvider = ({
if (!consentValue) {
// If consent is set to false we have to delete the cookie
document.cookie = cookie.serialize(cookieName, '', {
...cookiesOptions,
expires: new Date(0),
})
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,16 @@ describe('CookieConsent - CookieConsentProvider', () => {
})
})

const cookieOptions = { sameSite: 'strict', secure: true }
const cookieOptions = { sameSite: 'strict', secure: true, path: '/' }

expect(spy).toHaveBeenCalledTimes(3)
expect(spy).toHaveBeenNthCalledWith(2, '_scw_rgpd_marketing', 'true', {
...cookieOptions,
maxAge: 33696000,
path: '/',
})
expect(spy).toHaveBeenNthCalledWith(3, '_scw_rgpd_hash', '913003917', {
...cookieOptions,
maxAge: 15552000,
path: '/',
})

act(() => {
Expand All @@ -172,12 +170,12 @@ describe('CookieConsent - CookieConsentProvider', () => {

expect(spy).toHaveBeenCalledTimes(6)
expect(spy).toHaveBeenNthCalledWith(5, '_scw_rgpd_marketing', '', {
...cookieOptions,
expires: new Date(0),
})
expect(spy).toHaveBeenNthCalledWith(6, '_scw_rgpd_hash', '913003917', {
...cookieOptions,
maxAge: 15552000,
path: '/',
})
})

Expand Down