@@ -12,6 +12,7 @@ const { beforeBrowserCloseDelay } = require('../helpers/puppeteer-constants');
12
12
describe ( 'sockjs client proxy' , ( ) => {
13
13
function startProxy ( port , cb ) {
14
14
const proxy = express ( ) ;
15
+
15
16
proxy . use (
16
17
'/' ,
17
18
createProxyMiddleware ( {
@@ -21,6 +22,7 @@ describe('sockjs client proxy', () => {
21
22
logLevel : 'warn' ,
22
23
} )
23
24
) ;
25
+
24
26
return proxy . listen ( port , cb ) ;
25
27
}
26
28
@@ -33,6 +35,7 @@ describe('sockjs client proxy', () => {
33
35
firewall : false ,
34
36
hot : true ,
35
37
} ;
38
+
36
39
testServer . startAwaitingCompilation ( config , options , done ) ;
37
40
} ) ;
38
41
@@ -54,11 +57,13 @@ describe('sockjs client proxy', () => {
54
57
55
58
it ( 'responds with a 200 on proxy port' , ( done ) => {
56
59
const req = request ( `http://localhost:${ port2 } ` ) ;
60
+
57
61
req . get ( '/ws' ) . expect ( 200 , 'Welcome to SockJS!\n' , done ) ;
58
62
} ) ;
59
63
60
64
it ( 'responds with a 200 on non-proxy port' , ( done ) => {
61
65
const req = request ( `http://localhost:${ port1 } ` ) ;
66
+
62
67
req . get ( '/ws' ) . expect ( 200 , 'Welcome to SockJS!\n' , done ) ;
63
68
} ) ;
64
69
@@ -70,12 +75,14 @@ describe('sockjs client proxy', () => {
70
75
page . waitForTimeout ( beforeBrowserCloseDelay ) . then ( ( ) => {
71
76
browser . close ( ) . then ( ( ) => {
72
77
expect ( requestObj . url ( ) ) . toContain (
73
- `http://localhost:${ port2 } /ws`
78
+ `http://localhost:${ port1 } /ws`
74
79
) ;
80
+
75
81
done ( ) ;
76
82
} ) ;
77
83
} ) ;
78
84
} ) ;
85
+
79
86
page . goto ( `http://localhost:${ port2 } /main` ) ;
80
87
} ) ;
81
88
} ) ;
@@ -85,6 +92,7 @@ describe('sockjs client proxy', () => {
85
92
describe ( 'ws client proxy' , ( ) => {
86
93
function startProxy ( port , cb ) {
87
94
const proxy = express ( ) ;
95
+
88
96
proxy . use (
89
97
'/' ,
90
98
createProxyMiddleware ( {
@@ -93,6 +101,7 @@ describe('ws client proxy', () => {
93
101
changeOrigin : true ,
94
102
} )
95
103
) ;
104
+
96
105
return proxy . listen ( port , cb ) ;
97
106
}
98
107
@@ -106,6 +115,7 @@ describe('ws client proxy', () => {
106
115
hot : true ,
107
116
public : 'myhost' ,
108
117
} ;
118
+
109
119
testServer . startAwaitingCompilation ( config , options , done ) ;
110
120
} ) ;
111
121
@@ -132,14 +142,17 @@ describe('ws client proxy', () => {
132
142
it ( 'requests websocket through the proxy with proper port number' , ( done ) => {
133
143
runBrowser ( ) . then ( ( { page, browser } ) => {
134
144
const client = page . _client ;
145
+
135
146
client . on ( 'Network.webSocketCreated' , ( evt ) => {
136
147
page . waitForTimeout ( beforeBrowserCloseDelay ) . then ( ( ) => {
137
148
browser . close ( ) . then ( ( ) => {
138
- expect ( evt . url ) . toContain ( `ws://myhost:${ port2 } /ws` ) ;
149
+ expect ( evt . url ) . toContain ( `ws://myhost:${ port1 } /ws` ) ;
150
+
139
151
done ( ) ;
140
152
} ) ;
141
153
} ) ;
142
154
} ) ;
155
+
143
156
page . goto ( `http://localhost:${ port2 } /main` ) ;
144
157
} ) ;
145
158
} ) ;
@@ -157,6 +170,7 @@ describe('sockjs public and client path', () => {
157
170
path : '/foo/test/bar/' ,
158
171
} ,
159
172
} ;
173
+
160
174
testServer . startAwaitingCompilation ( config , options , done ) ;
161
175
} ) ;
162
176
@@ -175,10 +189,12 @@ describe('sockjs public and client path', () => {
175
189
expect ( requestObj . url ( ) ) . toContain (
176
190
`http://myhost.test:${ port2 } /foo/test/bar`
177
191
) ;
192
+
178
193
done ( ) ;
179
194
} ) ;
180
195
} ) ;
181
196
} ) ;
197
+
182
198
page . goto ( `http://localhost:${ port2 } /main` ) ;
183
199
} ) ;
184
200
} ) ;
@@ -196,6 +212,7 @@ describe('sockjs client path and port', () => {
196
212
port : port3 ,
197
213
} ,
198
214
} ;
215
+
199
216
testServer . startAwaitingCompilation ( config , options , done ) ;
200
217
} ) ;
201
218
@@ -214,6 +231,7 @@ describe('sockjs client path and port', () => {
214
231
expect ( requestObj . url ( ) ) . toContain (
215
232
`http://localhost:${ port3 } /foo/test/bar`
216
233
) ;
234
+
217
235
done ( ) ;
218
236
} ) ;
219
237
} ) ;
@@ -238,6 +256,7 @@ describe('sockjs client port, no path', () => {
238
256
port : port3 ,
239
257
} ,
240
258
} ;
259
+
241
260
testServer . startAwaitingCompilation ( config , options , done ) ;
242
261
} ) ;
243
262
@@ -254,10 +273,12 @@ describe('sockjs client port, no path', () => {
254
273
expect ( requestObj . url ( ) ) . toContain (
255
274
`http://localhost:${ port3 } /ws`
256
275
) ;
276
+
257
277
done ( ) ;
258
278
} ) ;
259
279
} ) ;
260
280
} ) ;
281
+
261
282
page . goto ( `http://localhost:${ port2 } /main` ) ;
262
283
} ) ;
263
284
} ) ;
@@ -290,10 +311,12 @@ describe('sockjs client host', () => {
290
311
expect ( requestObj . url ( ) ) . toContain (
291
312
`http://myhost.test:${ port2 } /ws`
292
313
) ;
314
+
293
315
done ( ) ;
294
316
} ) ;
295
317
} ) ;
296
318
} ) ;
319
+
297
320
page . goto ( `http://localhost:${ port2 } /main` ) ;
298
321
} ) ;
299
322
} ) ;
@@ -312,6 +335,7 @@ describe('ws client host, port, and path', () => {
312
335
path : '/foo/test/bar/' ,
313
336
} ,
314
337
} ;
338
+
315
339
testServer . startAwaitingCompilation ( config , options , done ) ;
316
340
} ) ;
317
341
@@ -325,10 +349,12 @@ describe('ws client host, port, and path', () => {
325
349
it ( 'uses correct host, port, and path' , ( done ) => {
326
350
runBrowser ( ) . then ( ( { page, browser } ) => {
327
351
const client = page . _client ;
352
+
328
353
client . on ( 'Network.webSocketCreated' , ( evt ) => {
329
354
page . waitForTimeout ( beforeBrowserCloseDelay ) . then ( ( ) => {
330
355
browser . close ( ) . then ( ( ) => {
331
356
expect ( evt . url ) . toContain ( `ws://myhost:${ port3 } /foo/test/bar` ) ;
357
+
332
358
done ( ) ;
333
359
} ) ;
334
360
} ) ;
0 commit comments