@@ -25,11 +25,11 @@ interface ProxyInstance {
25
25
}
26
26
27
27
let proxyPort = 9100 ;
28
- function createProxy ( target : string , secure : boolean ) : ProxyInstance {
28
+ function createProxy ( target : string , secure : boolean , ws = true ) : ProxyInstance {
29
29
proxyPort ++ ;
30
30
31
31
const server = createProxyServer ( {
32
- ws : true ,
32
+ ws,
33
33
target,
34
34
secure,
35
35
ssl : secure && {
@@ -107,7 +107,9 @@ async function goToPageAndWaitForSockJs(page: Page, url: string): Promise<void>
107
107
108
108
describe ( 'Dev Server Builder live-reload' , ( ) => {
109
109
const target = { project : 'app' , target : 'serve' } ;
110
- const overrides = { hmr : false , watch : true , port : 0 , liveReload : true } ;
110
+ // Avoid using port `0` as these tests will behave differrently and tests will pass when they shouldn't.
111
+ // Port 0 and host 0.0.0.0 have special meaning in dev-server.
112
+ const overrides = { hmr : false , watch : true , port : 4202 , liveReload : true } ;
111
113
let architect : Architect ;
112
114
let browser : Browser ;
113
115
let page : Page ;
@@ -120,12 +122,11 @@ describe('Dev Server Builder live-reload', () => {
120
122
// spaces in them which Bazel does not support in runfiles
121
123
// See: https://github.com/angular/angular-cli/pull/17624
122
124
// tslint:disable-next-line: max-line-length
123
- // executablePath: '/Users/<USERNAME>/git/angular-cli/node_modules/puppeteer/.local-chromium/mac-809590/chrome-mac/Chromium.app/Contents/MacOS/Chromium',
125
+ // executablePath: '/Users/<USERNAME>/git/angular-cli/node_modules/puppeteer/.local-chromium/mac-818858/chrome-mac/Chromium.app/Contents/MacOS/Chromium',
126
+ ignoreHTTPSErrors : true ,
124
127
args : [
125
128
'--no-sandbox' ,
126
129
'--disable-gpu' ,
127
- '--ignore-certificate-errors' ,
128
- '--ignore-urlfetcher-cert-requests' ,
129
130
] ,
130
131
} ) ;
131
132
} ) ;
@@ -246,4 +247,37 @@ describe('Dev Server Builder live-reload', () => {
246
247
)
247
248
. toPromise ( ) ;
248
249
} , 30000 ) ;
250
+
251
+ it ( 'works without https -> http proxy without websockets (dotnet emulation)' , async ( ) => {
252
+ const run = await architect . scheduleTarget ( target , overrides ) ;
253
+ runs . push ( run ) ;
254
+
255
+ let proxy : ProxyInstance | undefined ;
256
+ let buildCount = 0 ;
257
+
258
+ await run . output
259
+ . pipe (
260
+ debounceTime ( 1000 ) ,
261
+ switchMap ( async buildEvent => {
262
+ expect ( buildEvent . success ) . toBe ( true ) ;
263
+ const url = buildEvent . baseUrl as string ;
264
+ switch ( buildCount ) {
265
+ case 0 :
266
+ proxy = createProxy ( url , true , false ) ;
267
+ await goToPageAndWaitForSockJs ( page , proxy . url ) ;
268
+ await page . waitForResponse ( ( response : HTTPResponse ) => response . url ( ) . includes ( 'xhr_streaming' ) && response . status ( ) === 200 ) ;
269
+ host . replaceInFile ( 'src/app/app.component.ts' , `'app'` , `'app-live-reload'` ) ;
270
+ break ;
271
+ case 1 :
272
+ const innerText = await page . evaluate ( ( ) => document . querySelector ( 'p' ) . innerText ) ;
273
+ expect ( innerText ) . toBe ( 'app-live-reload' ) ;
274
+ break ;
275
+ }
276
+
277
+ buildCount ++ ;
278
+ } ) ,
279
+ take ( 2 ) ,
280
+ )
281
+ . toPromise ( ) ;
282
+ } , 30000 ) ;
249
283
} ) ;
0 commit comments