1
- import { type Page , expect , test } from '@playwright/test' ;
1
+ import { type Page , expect , test , chromium } from '@playwright/test' ;
2
2
3
3
async function getRouteData ( page : Page ) : Promise < any > {
4
4
return page . evaluate ( 'window.__remixContext.state.loaderData' ) . catch ( err => {
@@ -22,7 +22,6 @@ async function extractTraceAndBaggageFromMeta(
22
22
23
23
test ( 'should inject `sentry-trace` and `baggage` into root loader returning an empty object.' , async ( { page } ) => {
24
24
await page . goto ( '/?type=empty' ) ;
25
-
26
25
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
27
26
28
27
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
@@ -38,7 +37,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning an e
38
37
39
38
test ( 'should inject `sentry-trace` and `baggage` into root loader returning a plain object.' , async ( { page } ) => {
40
39
await page . goto ( '/?type=plain' ) ;
41
-
42
40
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
43
41
44
42
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
@@ -56,7 +54,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a pl
56
54
57
55
test ( 'should inject `sentry-trace` and `baggage` into root loader returning a `JSON response`.' , async ( { page } ) => {
58
56
await page . goto ( '/?type=json' ) ;
59
-
60
57
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
61
58
62
59
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
@@ -74,7 +71,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a `J
74
71
75
72
test ( 'should inject `sentry-trace` and `baggage` into root loader returning a deferred response' , async ( { page } ) => {
76
73
await page . goto ( '/?type=defer' ) ;
77
-
78
74
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
79
75
80
76
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
@@ -90,7 +86,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a de
90
86
91
87
test ( 'should inject `sentry-trace` and `baggage` into root loader returning `null`.' , async ( { page } ) => {
92
88
await page . goto ( '/?type=null' ) ;
93
-
94
89
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
95
90
96
91
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
@@ -106,7 +101,6 @@ test('should inject `sentry-trace` and `baggage` into root loader returning `nul
106
101
107
102
test ( 'should inject `sentry-trace` and `baggage` into root loader returning `undefined`.' , async ( { page } ) => {
108
103
await page . goto ( '/?type=undefined' ) ;
109
-
110
104
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
111
105
112
106
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
@@ -124,12 +118,11 @@ test('should inject `sentry-trace` and `baggage` into root loader throwing a red
124
118
page,
125
119
} ) => {
126
120
await page . goto ( '/?type=throwRedirect' ) ;
121
+ const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
127
122
128
123
// We should be successfully redirected to the path.
129
124
expect ( page . url ( ) ) . toEqual ( expect . stringContaining ( '/?type=plain' ) ) ;
130
125
131
- const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
132
-
133
126
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
134
127
expect ( sentryBaggage ) . toMatch ( / .+ / ) ;
135
128
@@ -143,14 +136,14 @@ test('should inject `sentry-trace` and `baggage` into root loader throwing a red
143
136
144
137
test ( 'should inject `sentry-trace` and `baggage` into root loader returning a redirection to valid path.' , async ( {
145
138
page,
139
+ baseURL,
146
140
} ) => {
147
- await page . goto ( '/?type=returnRedirect' ) ;
141
+ await page . goto ( `${ baseURL } /?type=returnRedirect` ) ;
142
+ const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
148
143
149
144
// We should be successfully redirected to the path.
150
145
expect ( page . url ( ) ) . toEqual ( expect . stringContaining ( '/?type=plain' ) ) ;
151
146
152
- const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
153
-
154
147
expect ( sentryTrace ) . toMatch ( / .+ / ) ;
155
148
expect ( sentryBaggage ) . toMatch ( / .+ / ) ;
156
149
@@ -162,23 +155,22 @@ test('should inject `sentry-trace` and `baggage` into root loader returning a re
162
155
} ) ;
163
156
} ) ;
164
157
165
- test ( 'should return redirect to an external path with no baggage and trace injected.' , async ( { page } ) => {
166
- await page . goto ( ' /?type=returnRedirectToExternal' ) ;
158
+ test ( 'should return redirect to an external path with no baggage and trace injected.' , async ( { page, baseURL } ) => {
159
+ await page . goto ( ` ${ baseURL } /?type=returnRedirectToExternal` ) ;
167
160
168
- // We should be successfully redirected to the external path.
169
- expect ( page . url ( ) ) . toEqual ( expect . stringContaining ( 'https://example.com' ) ) ;
161
+ expect ( page . url ( ) ) . toEqual ( expect . stringContaining ( 'docs.sentry.io' ) ) ;
170
162
171
163
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
172
164
173
165
expect ( sentryTrace ) . toBeUndefined ( ) ;
174
166
expect ( sentryBaggage ) . toBeUndefined ( ) ;
175
167
} ) ;
176
168
177
- test ( 'should throw redirect to an external path with no baggage and trace injected.' , async ( { page } ) => {
178
- await page . goto ( ' /?type=throwRedirectToExternal' ) ;
169
+ test ( 'should throw redirect to an external path with no baggage and trace injected.' , async ( { page, baseURL } ) => {
170
+ await page . goto ( ` ${ baseURL } /?type=throwRedirectToExternal` ) ;
179
171
180
172
// We should be successfully redirected to the external path.
181
- expect ( page . url ( ) ) . toEqual ( expect . stringContaining ( 'https://example.com ' ) ) ;
173
+ expect ( page . url ( ) ) . toEqual ( expect . stringContaining ( 'docs.sentry.io ' ) ) ;
182
174
183
175
const { sentryTrace, sentryBaggage } = await extractTraceAndBaggageFromMeta ( page ) ;
184
176
0 commit comments