Skip to content

Commit

Permalink
fix other tests affected by body change
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-messiah committed Sep 12, 2024
1 parent 3a17ae5 commit 21dab4a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 70 deletions.
3 changes: 2 additions & 1 deletion tests/specs/cleanup-on-halt.e2e.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { rumFlags } from '../../tools/testing-server/constants'
import { testRumRequest } from '../../tools/testing-server/utils/expect-tests'

describe('Memory leaks', () => {
it('does not occur on ee backlog when RUM flags are 0', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 0, sr: 0, err: 0, ins: 0, spa: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 0, sr: 0, err: 0, ins: 0, spa: 0, loaded: 1 }))
})
// This test relies on features to call deregisterDrain when not enabled by flags which in turn should clear their backlogs.

Expand Down
33 changes: 5 additions & 28 deletions tests/specs/harvesting/disable-harvesting.e2e.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { testBlobTraceRequest, testErrorsRequest, testEventsRequest, testInsRequest, testMetricsRequest, testRumRequest } from '../../../tools/testing-server/utils/expect-tests'
import { rumFlags } from '../../../tools/testing-server/constants'

describe('disable harvesting', () => {
it('should disable harvesting metrics and errors when err entitlement is 0', async () => {
Expand All @@ -8,13 +9,7 @@ describe('disable harvesting', () => {
])
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({
st: 1,
err: 0,
ins: 1,
spa: 1,
loaded: 1
})
body: JSON.stringify(rumFlags({ err: 0 }))
})

const [metricsHarvests, errorsHarvests] = await Promise.all([
Expand All @@ -32,13 +27,7 @@ describe('disable harvesting', () => {
const eventsCapture = await browser.testHandle.createNetworkCaptures('bamServer', { test: testEventsRequest })
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({
st: 1,
err: 1,
ins: 1,
spa: 0,
loaded: 1
})
body: JSON.stringify(rumFlags({ spa: 0 }))
})

// Disable non-spa features that also use the events endpoint
Expand All @@ -59,13 +48,7 @@ describe('disable harvesting', () => {
const insightsCapture = await browser.testHandle.createNetworkCaptures('bamServer', { test: testInsRequest })
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({
st: 1,
err: 1,
ins: 0,
spa: 1,
loaded: 1
})
body: JSON.stringify(rumFlags({ ins: 0 }))
})

const [insightsHarvests] = await Promise.all([
Expand All @@ -81,13 +64,7 @@ describe('disable harvesting', () => {
const traceCapture = await browser.testHandle.createNetworkCaptures('bamServer', { test: testBlobTraceRequest })
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({
st: 0,
err: 1,
ins: 1,
spa: 1,
loaded: 1
})
body: JSON.stringify(rumFlags({ st: 0 }))
})

const [traceHarvests] = await Promise.all([
Expand Down
12 changes: 2 additions & 10 deletions tests/specs/session-replay/initialization.e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { rumFlags } from '../../../tools/testing-server/constants'
import { testBlobReplayRequest, testRumRequest } from '../../../tools/testing-server/utils/expect-tests'
import { srConfig, getSR } from '../util/helpers'

Expand All @@ -6,16 +7,7 @@ async function disqualifySR () {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
permanent: true,
body: JSON.stringify({
st: 1,
sts: 1,
err: 1,
ins: 1,
spa: 1,
loaded: 1,
sr: 0,
srs: 0
})
body: JSON.stringify(rumFlags({ sr: 0, srs: 0 }))
})
}

Expand Down
25 changes: 13 additions & 12 deletions tests/specs/session-trace/modes.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* All behavior and mode transition from error mode of Trace in tandem with the replay feature is tested in here.
* Right now, Trace can only be in error mode when its stn flag is 0 but replay runs in error mode.
*/
import { rumFlags } from '../../../tools/testing-server/constants'
import { testBlobTraceRequest, testRumRequest } from '../../../tools/testing-server/utils/expect-tests'
import { stConfig, testExpectedTrace } from '../util/helpers'

Expand All @@ -20,7 +21,7 @@ describe('respects feature flags', () => {
it('0, 0 == PERMANENTLY OFF', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 0, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 0, sts: 0, sr: 0, srs: 0 }))
})

const [sessionTraceHarvests] = await Promise.all([
Expand All @@ -38,7 +39,7 @@ describe('respects feature flags', () => {
it('0, 1 == PERMANENTLY OFF', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 0, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 0, sts: 1, sr: 0, srs: 0 }))
})

const [sessionTraceHarvests] = await Promise.all([
Expand All @@ -56,7 +57,7 @@ describe('respects feature flags', () => {
it('0, 2 == PERMANENTLY OFF', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 0, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 0, sts: 2, sr: 0, srs: 0 }))
})

const [sessionTraceHarvests] = await Promise.all([
Expand All @@ -75,7 +76,7 @@ describe('respects feature flags', () => {
url = await browser.testHandle.assetURL('instrumented.html', stConfig({ session_replay: { enabled: true } }))
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 1, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 0, sr: 1, srs: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -100,7 +101,7 @@ describe('respects feature flags', () => {
it('1, 1 == STARTS IN FULL', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 1, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 1, sr: 1, srs: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -116,7 +117,7 @@ describe('respects feature flags', () => {
it('1, 2 == STARTS IN ERROR, CHANGES TO FULL (noticeError)', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 2, sr: 0, srs: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand Down Expand Up @@ -152,7 +153,7 @@ describe('respects feature flags', () => {
url = await browser.testHandle.assetURL('js-error-with-error-after-page-load.html', stConfig())
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 2, sr: 0, srs: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand Down Expand Up @@ -186,7 +187,7 @@ describe('respects feature flags', () => {
url = await browser.testHandle.assetURL('js-error-with-error-before-page-load.html', stConfig())
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 2, sr: 0, srs: 0 }))
})

const [sessionTraceHarvests] = await Promise.all([
Expand All @@ -202,7 +203,7 @@ describe('respects feature flags', () => {
it('does not capture more than the last 30 seconds when error happens', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 2, sr: 0, srs: 0 }))
})

await browser.url(url).then(() => browser.waitForAgentLoad())
Expand All @@ -222,7 +223,7 @@ describe('respects feature flags', () => {
it('does not perform final harvest while in error mode', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 2, sr: 0, srs: 0 }))
})

await browser.url(url).then(() => browser.waitForAgentLoad())
Expand All @@ -239,7 +240,7 @@ describe('respects feature flags', () => {
url = await browser.testHandle.assetURL('instrumented.html', stConfig({ privacy: { cookies_enabled: false } }))
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 1, sr: 0, srs: 0 }))
})

const [sessionTraceHarvests] = await Promise.all([
Expand All @@ -254,7 +255,7 @@ describe('respects feature flags', () => {
it('should not trigger session trace when an error is seen and mode is off', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, srs: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 1, sts: 0, sr: 0, srs: 0 }))
})

const [sessionTraceHarvests] = await Promise.all([
Expand Down
33 changes: 17 additions & 16 deletions tests/specs/session-trace/session-pages.e2e.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { testBlobTraceRequest, testRumRequest } from '../../../tools/testing-server/utils/expect-tests.js'
import { supportsMultiTabSessions } from '../../../tools/browser-matcher/common-matchers.mjs'
import { testExpectedTrace, stConfig, MODE, decodeAttributes } from '../util/helpers.js'
import { rumFlags } from '../../../tools/testing-server/constants.js'

const getTraceMode = () => browser.execute(function () {
const agent = Object.values(newrelic.initializedAgents)[0]
Expand All @@ -23,7 +24,7 @@ describe('Session Replay Across Pages', () => {
it('should record across same-tab page refresh when already recording, even if sampling is 0', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -38,7 +39,7 @@ describe('Session Replay Across Pages', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sts: 0, sr: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand All @@ -59,7 +60,7 @@ describe('Session Replay Across Pages', () => {
it('should record across same-tab page navigation when already recording, even if sampling is 0', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -74,7 +75,7 @@ describe('Session Replay Across Pages', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sts: 0, sr: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand All @@ -95,7 +96,7 @@ describe('Session Replay Across Pages', () => {
it.withBrowsersMatching(supportsMultiTabSessions)('should record across new-tab page navigation once recording, even if sampled as 0', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -110,7 +111,7 @@ describe('Session Replay Across Pages', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0, sts: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand All @@ -136,7 +137,7 @@ describe('Session Replay Across Pages', () => {
it('should not record across navigations if not active', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -154,7 +155,7 @@ describe('Session Replay Across Pages', () => {
})
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0, sts: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand All @@ -171,7 +172,7 @@ describe('Session Replay Across Pages', () => {
it('should not report harvest if sessionId changes', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -185,7 +186,7 @@ describe('Session Replay Across Pages', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0, sts: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand All @@ -203,7 +204,7 @@ describe('Session Replay Across Pages', () => {
it('should not report harvest if session resets', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -217,7 +218,7 @@ describe('Session Replay Across Pages', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 0, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0, sts: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand All @@ -235,7 +236,7 @@ describe('Session Replay Across Pages', () => {
it.withBrowsersMatching(supportsMultiTabSessions)('should not report harvest if session resets on another page', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -249,7 +250,7 @@ describe('Session Replay Across Pages', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand Down Expand Up @@ -281,7 +282,7 @@ describe('Session Replay Across Pages', () => {
it.withBrowsersMatching(supportsMultiTabSessions)('catches mode transition from other pages in the session', async () => {
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sts: 2, sr: 0 }))
})

let [sessionTraceHarvests] = await Promise.all([
Expand All @@ -295,7 +296,7 @@ describe('Session Replay Across Pages', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 2, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sts: 2, sr: 0 }))
})

;[sessionTraceHarvests] = await Promise.all([
Expand Down
5 changes: 3 additions & 2 deletions tests/specs/session-trace/trace-nodes.e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { rumFlags } from '../../../tools/testing-server/constants.js'
import { testBlobTraceRequest, testRumRequest } from '../../../tools/testing-server/utils/expect-tests.js'
import { stConfig } from '../util/helpers.js'
import { JSONPath } from 'jsonpath-plus'
Expand All @@ -10,7 +11,7 @@ describe('Trace nodes', () => {

await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 1, sts: 1, err: 1, ins: 1, spa: 1, sr: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ sr: 0 }))
})
})

Expand Down Expand Up @@ -46,7 +47,7 @@ describe('Trace nodes', () => {
await browser.testHandle.clearScheduledReplies('bamServer')
await browser.testHandle.scheduleReply('bamServer', {
test: testRumRequest,
body: JSON.stringify({ st: 0, sts: 0, sr: 0, err: 1, ins: 1, spa: 0, loaded: 1 })
body: JSON.stringify(rumFlags({ st: 0, sts: 0, sr: 0, spa: 0 }))
})

const url = await browser.testHandle.assetURL('pagehide.html', stConfig())
Expand Down
Loading

0 comments on commit 21dab4a

Please sign in to comment.