-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathnavigation.client.test.ts
More file actions
157 lines (141 loc) · 5.37 KB
/
navigation.client.test.ts
File metadata and controls
157 lines (141 loc) · 5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';
import { APP_NAME } from '../constants';
test.describe('client - navigation performance', () => {
test('should create navigation transaction', async ({ page }) => {
const navigationPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance/ssr';
});
await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await page.getByRole('link', { name: 'SSR Page' }).click(); // navigation
const transaction = await navigationPromise;
expect(transaction).toMatchObject({
contexts: {
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
data: {
'sentry.origin': 'auto.navigation.react_router',
'sentry.op': 'navigation',
'sentry.source': 'route',
},
op: 'navigation',
origin: 'auto.navigation.react_router',
},
},
spans: expect.any(Array),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
transaction: '/performance/ssr',
type: 'transaction',
transaction_info: { source: 'route' },
platform: 'javascript',
request: {
url: expect.stringContaining('/performance/ssr'),
headers: expect.any(Object),
},
event_id: expect.any(String),
environment: 'qa',
sdk: {
integrations: expect.arrayContaining([expect.any(String)]),
name: 'sentry.javascript.react-router',
version: expect.any(String),
packages: [
{ name: 'npm:@sentry/react-router', version: expect.any(String) },
{ name: 'npm:@sentry/browser', version: expect.any(String) },
],
},
tags: { runtime: 'browser' },
});
});
test('should create navigation transaction when navigating with object `to` prop', async ({ page }) => {
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance/with/:param';
});
await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await page.getByRole('link', { name: 'Object Navigate' }).click(); // navigation with object to
const transaction = await txPromise;
expect(transaction).toMatchObject({
contexts: {
trace: {
op: 'navigation',
origin: 'auto.navigation.react_router',
data: {
'sentry.source': 'route',
},
},
},
transaction: '/performance/with/:param',
type: 'transaction',
transaction_info: { source: 'route' },
});
});
test('should create navigation transaction when navigating with search-only object `to` prop', async ({ page }) => {
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'navigation';
});
await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await page.getByRole('link', { name: 'Search Only Navigate' }).click(); // navigation with search-only object to
const transaction = await txPromise;
expect(transaction).toMatchObject({
contexts: {
trace: {
op: 'navigation',
origin: 'auto.navigation.react_router',
},
},
transaction: '/performance',
type: 'transaction',
});
});
test('should update navigation transaction for dynamic routes', async ({ page }) => {
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance/with/:param';
});
await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await page.getByRole('link', { name: 'With Param Page' }).click(); // navigation
const transaction = await txPromise;
expect(transaction).toMatchObject({
contexts: {
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
data: {
'sentry.origin': 'auto.navigation.react_router',
'sentry.op': 'navigation',
'sentry.source': 'route',
},
op: 'navigation',
origin: 'auto.navigation.react_router',
},
},
spans: expect.any(Array),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
transaction: '/performance/with/:param',
type: 'transaction',
transaction_info: { source: 'route' },
platform: 'javascript',
request: {
url: expect.stringContaining('/performance/with/sentry'),
headers: expect.any(Object),
},
event_id: expect.any(String),
environment: 'qa',
sdk: {
integrations: expect.arrayContaining([expect.any(String)]),
name: 'sentry.javascript.react-router',
version: expect.any(String),
packages: [
{ name: 'npm:@sentry/react-router', version: expect.any(String) },
{ name: 'npm:@sentry/browser', version: expect.any(String) },
],
},
tags: { runtime: 'browser' },
});
});
});