diff --git a/tests/specs/cleanup-on-halt.e2e.js b/tests/specs/cleanup-on-halt.e2e.js index e079de03b..bc7ff08eb 100644 --- a/tests/specs/cleanup-on-halt.e2e.js +++ b/tests/specs/cleanup-on-halt.e2e.js @@ -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. diff --git a/tests/specs/harvesting/disable-harvesting.e2e.js b/tests/specs/harvesting/disable-harvesting.e2e.js index 1d90a66b3..b628548d0 100644 --- a/tests/specs/harvesting/disable-harvesting.e2e.js +++ b/tests/specs/harvesting/disable-harvesting.e2e.js @@ -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 () => { @@ -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([ @@ -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 @@ -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([ @@ -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([ diff --git a/tests/specs/session-replay/initialization.e2e.js b/tests/specs/session-replay/initialization.e2e.js index fea418730..e0409267a 100644 --- a/tests/specs/session-replay/initialization.e2e.js +++ b/tests/specs/session-replay/initialization.e2e.js @@ -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' @@ -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 })) }) } diff --git a/tests/specs/session-trace/modes.e2e.js b/tests/specs/session-trace/modes.e2e.js index bfad7e1c6..bd19a78d0 100644 --- a/tests/specs/session-trace/modes.e2e.js +++ b/tests/specs/session-trace/modes.e2e.js @@ -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' @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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()) @@ -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()) @@ -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([ @@ -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([ diff --git a/tests/specs/session-trace/session-pages.e2e.js b/tests/specs/session-trace/session-pages.e2e.js index 540545395..4ecb3cdfa 100644 --- a/tests/specs/session-trace/session-pages.e2e.js +++ b/tests/specs/session-trace/session-pages.e2e.js @@ -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] @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ @@ -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([ diff --git a/tests/specs/session-trace/trace-nodes.e2e.js b/tests/specs/session-trace/trace-nodes.e2e.js index c929a3ebe..0f6aa5492 100644 --- a/tests/specs/session-trace/trace-nodes.e2e.js +++ b/tests/specs/session-trace/trace-nodes.e2e.js @@ -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' @@ -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 })) }) }) @@ -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()) diff --git a/tests/specs/soft_navigations/integration.e2e.js b/tests/specs/soft_navigations/integration.e2e.js index ff7eddf86..d645e2085 100644 --- a/tests/specs/soft_navigations/integration.e2e.js +++ b/tests/specs/soft_navigations/integration.e2e.js @@ -1,6 +1,7 @@ import { JSONPath } from 'jsonpath-plus' import { testAjaxEventsRequest, testErrorsRequest, testInteractionEventsRequest, testRumRequest } from '../../../tools/testing-server/utils/expect-tests.js' import { notSafari, onlyChromium } from '../../../tools/browser-matcher/common-matchers.mjs' +import { rumFlags } from '../../../tools/testing-server/constants.js' // test: does not disrupt old spa when not enabled -- this is tested via old spa tests passing by default! describe('Soft navigations', () => { @@ -44,7 +45,7 @@ describe('Soft navigations', () => { it('does not harvest when spa is blocked by rum response', async () => { 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 })) }) const [interactionsHarvests] = await Promise.all([