Skip to content

Commit

Permalink
test the non-injected case
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed May 15, 2024
1 parent 4311c48 commit 2b3412e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nextTestSetup } from 'e2e-utils'

describe('clientTraceMetadata (ppr=%p)', () => {
describe('clientTraceMetadata', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
dependencies: require('./package.json').dependencies,
Expand All @@ -12,12 +12,13 @@ describe('clientTraceMetadata (ppr=%p)', () => {
expect(headHtml).toContain(
'<meta name="my-test-key-1" content="my-test-value-1">'
)
expect($.html('head')).toContain(
expect(headHtml).toContain(
'<meta name="my-test-key-2" content="my-test-value-2">'
)
expect($.html('head')).toMatch(
expect(headHtml).toMatch(
/<meta name="my-parent-span-id" content="[a-f0-9]{16}">/
)
expect(headHtml).not.toContain('non-metadata-key-3')
})

it('hard loading a dynamic page twice should yield different dynamic trace data', async () => {
Expand All @@ -44,12 +45,13 @@ describe('clientTraceMetadata (ppr=%p)', () => {
expect(headHtml).toContain(
'<meta name="my-test-key-1" content="my-test-value-1">'
)
expect($.html('head')).toContain(
expect(headHtml).toContain(
'<meta name="my-test-key-2" content="my-test-value-2">'
)
expect($.html('head')).toMatch(
expect(headHtml).toMatch(
/<meta name="my-parent-span-id" content="[a-f0-9]{16}">/
)
expect(headHtml).not.toContain('non-metadata-key-3')
})

it('soft navigating to a dynamic page should not transform previous propagation data', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export async function register() {
inject(context, carrier, setter) {
setter.set(carrier, 'my-test-key-1', 'my-test-value-1')
setter.set(carrier, 'my-test-key-2', 'my-test-value-2')
// This non-metadata-key-3 is not going to be injected into the page
setter.set(carrier, 'non-metadata-key-3', 'non-metadata-key-3')
setter.set(
carrier,
'my-parent-span-id',
Expand All @@ -20,7 +22,12 @@ export async function register() {
return context
},
fields() {
return ['my-parent-span-id', 'my-test-key-1', 'my-test-key-2']
return [
'my-parent-span-id',
'my-test-key-1',
'my-test-key-2',
'non-metadata-key-3',
]
},
},
})
Expand Down

0 comments on commit 2b3412e

Please sign in to comment.