@@ -25,11 +25,11 @@ interface ProxyInstance {
2525}
2626
2727let proxyPort = 9100 ;
28- function createProxy ( target : string , secure : boolean ) : ProxyInstance {
28+ function createProxy ( target : string , secure : boolean , ws = true ) : ProxyInstance {
2929 proxyPort ++ ;
3030
3131 const server = createProxyServer ( {
32- ws : true ,
32+ ws,
3333 target,
3434 secure,
3535 ssl : secure && {
@@ -107,7 +107,9 @@ async function goToPageAndWaitForSockJs(page: Page, url: string): Promise<void>
107107
108108describe ( 'Dev Server Builder live-reload' , ( ) => {
109109 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 } ;
111113 let architect : Architect ;
112114 let browser : Browser ;
113115 let page : Page ;
@@ -120,12 +122,11 @@ describe('Dev Server Builder live-reload', () => {
120122 // spaces in them which Bazel does not support in runfiles
121123 // See: https://github.com/angular/angular-cli/pull/17624
122124 // 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 ,
124127 args : [
125128 '--no-sandbox' ,
126129 '--disable-gpu' ,
127- '--ignore-certificate-errors' ,
128- '--ignore-urlfetcher-cert-requests' ,
129130 ] ,
130131 } ) ;
131132 } ) ;
@@ -246,4 +247,37 @@ describe('Dev Server Builder live-reload', () => {
246247 )
247248 . toPromise ( ) ;
248249 } , 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 ) ;
249283} ) ;
0 commit comments