Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: add test for cookies with expiration (#12304)
Max Schmitte035ed488cf7
diff --git a/tests/browsercontext-cookies.spec.ts b/tests/browsercontext-cookies.spec.tsindex 8f1f2d87a2..0671e08ac7 100644--- a/tests/browsercontext-cookies.spec.ts+++ b/tests/browsercontext-cookies.spec.ts@@ -265,3 +265,31 @@ it('should return secure cookies based on HTTP(S) protocol', async ({ context, bsameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax',}]);});++it('should add cookies with an expiration', async ({ context, browserName, platform }) => {+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/12226' });+ it.fixme(browserName === 'webkit' && platform === 'linux', 'Protocol error');+ const expires = Date.now() + 3600;+ await context.addCookies([{+ url: 'https://foo.com',+ name: 'doggo',+ value: 'woofs',+ sameSite: 'None',+ expires,+ }]);+ const cookies = await context.cookies(['https://foo.com']);+ expect(cookies.length).toBe(1);+ if (browserName === 'chromium')+ // Chromium returns them sometimes as floats: https://crbug.com/1300178+ cookies[0].expires = Math.round(cookies[0].expires);+ expect(cookies).toEqual([{+ name: 'doggo',+ value: 'woofs',+ domain: 'foo.com',+ path: '/',+ expires,+ httpOnly: false,+ secure: true,+ sameSite: 'None',+ }]);+});