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

fix(cookies): maxAge param #1319

Merged
merged 7 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ Changelog

_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.?? (2024-07-??)

#### :bug: Bug Fix

* Corrected the improper conversion of cookie attributes that are passed in camelCase format:
now all are forcibly converted to dash-style `core/cookies`

## v4.0.0-beta.106 (2024-06-25)

#### :bug: Bug Fix
Expand Down
7 changes: 7 additions & 0 deletions src/core/cookies/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]

## v4.0.0-beta.?? (2024-07-??)

#### :bug: Bug Fix

* Corrected the improper conversion of cookie attributes that are passed in camelCase format:
now all are forcibly converted to dash-style

## v4.0.0-beta.62 (2024-02-19)

#### :bug: Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion src/core/cookies/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class Cookies {
cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;

Object.entries(opts).forEach(([key, val]) => {
cookie += `; ${key}`;
cookie += `; ${key.dasherize()}`;

if (val !== true) {
cookie += `=${val}`;
Expand Down
22 changes: 22 additions & 0 deletions src/core/cookies/test/unit/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,28 @@ test.describe('core/cookies', () => {
const cookies = await context.cookies(page.url());
test.expect(cookies.filter((el) => el.name === 'testCookie')).toEqual([resolveCookieParams({expires})]);
});

test('with the `maxAge` option provided', async () => {
await cookiesAPI.evaluate(
(cookies) => cookies.set('testCookie', 'testCookieVal', {maxAge: 10})
);

const res1 = await cookiesAPI.evaluate(
(cookies) => cookies.store.cookie
);

test.expect(res1.includes('testCookie=testCookieVal')).toBe(true);

await cookiesAPI.evaluate(
(cookies) => cookies.set('testCookie', 'testCookieVal', {maxAge: 0})
);

const res2 = await cookiesAPI.evaluate(
(cookies) => cookies.store.cookie
);

test.expect(res2.includes('testCookie=testCookieVal')).toBe(false);
});
});

test.describe('`remove`', () => {
Expand Down
Loading