-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
119 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
85 changes: 85 additions & 0 deletions
85
packages/integration-tests/src/tests/cookies/cookies.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* | ||
* Copyright 2024 Splunk Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
import { expect } from '@playwright/test' | ||
import { test } from '../../utils/test' | ||
|
||
test.describe('cookies', () => { | ||
test('Connectivity events are captured', async ({ recordPage }) => { | ||
await recordPage.goTo('/cookies/cookies.ejs') | ||
|
||
// This should create two streams of documentLoad sequences, all with the same sessionId but having | ||
// two scriptInstances (one from parent, one from iframe) | ||
await recordPage.waitForSpans((spans) => spans.filter((s) => s.name === 'documentFetch').length === 2) | ||
const documentFetchSpans = recordPage.receivedSpans.filter((span) => span.name === 'documentFetch') | ||
expect(documentFetchSpans).toHaveLength(2) | ||
|
||
expect(documentFetchSpans[0].tags['location.href']).toBe('http://localhost:3000/cookies/iframe.ejs') | ||
expect(documentFetchSpans[1].tags['location.href']).toBe('http://localhost:3000/cookies/cookies.ejs') | ||
|
||
// same sessionId& instanceId | ||
expect(documentFetchSpans[0].tags['splunk.rumSessionId']).toBe( | ||
documentFetchSpans[1].tags['splunk.rumSessionId'], | ||
) | ||
expect(documentFetchSpans[0].tags['browser.instance.id']).toBe( | ||
documentFetchSpans[1].tags['browser.instance.id'], | ||
) | ||
|
||
// different scriptInstance | ||
expect(documentFetchSpans[0].tags['splunk.scriptInstance']).not.toBe( | ||
documentFetchSpans[1].tags['splunk.scriptInstance'], | ||
) | ||
|
||
const cookie = await recordPage.getCookie('_splunk_rum_sid') | ||
expect(cookie).toBeTruthy() | ||
|
||
expect(recordPage.receivedErrorSpans).toHaveLength(0) | ||
}) | ||
|
||
test('setting session cookie in iframe should work', async ({ recordPage }) => { | ||
await recordPage.goTo('/cookies/cookies.iframe.ejs') | ||
|
||
await recordPage.waitForSpans((spans) => | ||
spans.some((s) => s.name === 'documentFetch' && s.tags.app === 'iframe'), | ||
) | ||
const documentFetchSpans = recordPage.receivedSpans.filter((span) => span.name === 'documentFetch') | ||
expect(documentFetchSpans).toHaveLength(1) | ||
expect(documentFetchSpans[0].tags['splunk.rumSessionId']).toBeTruthy() | ||
|
||
const cookie = await recordPage.getCookie('_splunk_rum_sid') | ||
|
||
expect(cookie).toBeTruthy() | ||
expect(cookie.secure).toBe(true) | ||
expect(cookie.sameSite).toBe('None') | ||
}) | ||
|
||
test('setting cookieDomain via config sets it on subdomains also', async ({ recordPage }) => { | ||
await recordPage.goTo(`http://127.0.0.1.nip.io:3000/cookies/cookies-domain.ejs`) | ||
const cookie1 = await recordPage.getCookie('_splunk_rum_sid') | ||
|
||
expect(cookie1).toBeTruthy() | ||
|
||
await recordPage.goTo(`http://test.127.0.0.1.nip.io:3000/cookies/cookies-domain.ejs`) | ||
const cookie2 = await recordPage.getCookie('_splunk_rum_sid') | ||
|
||
expect(cookie2).toBeTruthy() | ||
expect(cookie1.value).toBe(cookie2.value) | ||
expect(cookie1.domain).toBe(cookie2.domain) | ||
|
||
expect(recordPage.receivedErrorSpans).toHaveLength(0) | ||
}) | ||
}) |
File renamed without changes.
File renamed without changes.
102 changes: 0 additions & 102 deletions
102
packages/web/integration-tests/tests/cookies/cookies.spec.js
This file was deleted.
Oops, something went wrong.