1+ // @ts -check
12import { test , expect } from '@playwright/test' ;
23
34test . describe ( 'Viewport devicePixelRatio 1' , ( ) => {
@@ -34,9 +35,9 @@ test.describe('Viewport devicePixelRatio 1', () => {
3435 await page . waitForTimeout ( 1000 ) ;
3536
3637 // Check that the WMS Max Size has been well overwrite
37- expect ( await page . evaluate ( ( ) => lizMap . mainLizmap . initialConfig . options . wmsMaxHeight ) ) . toBe ( 950 ) ;
38+ expect ( await page . evaluate ( ( ) => globalThis . lizMap . mainLizmap . initialConfig . options . wmsMaxHeight ) ) . toBe ( 950 ) ;
3839 expect ( await page . evaluate ( ( ) => window . devicePixelRatio ) ) . toBe ( 1 ) ;
39- expect ( await page . evaluate ( ( ) => lizMap . mainLizmap . map . getSize ( ) ) ) . toStrictEqual ( [ 870 , 575 ] ) ;
40+ expect ( await page . evaluate ( ( ) => globalThis . lizMap . mainLizmap . map . getSize ( ) ) ) . toStrictEqual ( [ 870 , 575 ] ) ;
4041 await page . unroute ( '**/service/getProjectConfig*' )
4142
4243 // Catch GetMaps request;
@@ -67,6 +68,7 @@ test.describe('Viewport devicePixelRatio 1', () => {
6768} )
6869
6970test . describe ( 'Viewport devicePixelRatio 2' , ( ) => {
71+ // Force device pixel ratio to 2
7072 test . use ( {
7173 deviceScaleFactor : 2 ,
7274 } ) ;
@@ -103,19 +105,20 @@ test.describe('Viewport devicePixelRatio 2', () => {
103105 await page . waitForTimeout ( 1000 ) ;
104106
105107 // Check that the WMS Max Size has been well overwrite
106- expect ( await page . evaluate ( ( ) => lizMap . mainLizmap . initialConfig . options . wmsMaxHeight ) ) . toBe ( 1900 ) ;
108+ expect ( await page . evaluate ( ( ) => globalThis . lizMap . mainLizmap . initialConfig . options . wmsMaxHeight ) ) . toBe ( 1900 ) ;
107109 expect ( await page . evaluate ( ( ) => window . devicePixelRatio ) ) . toBe ( 2 ) ;
108- expect ( await page . evaluate ( ( ) => lizMap . mainLizmap . map . getSize ( ) ) ) . toStrictEqual ( [ 870 , 620 ] ) ;
110+ expect ( await page . evaluate ( ( ) => globalThis . lizMap . mainLizmap . map . getSize ( ) ) ) . toStrictEqual ( [ 870 , 620 ] ) ;
109111 await page . unroute ( '**/service/getProjectConfig*' )
110112
111113 // Catch GetMaps request;
114+ // Because we disable High DPI, the OL pixel ratio is forced to 1 even if the device pixel ratio is 2
112115 let GetMaps = [ ] ;
113116 await page . route ( '**/service*' , async route => {
114117 const request = route . request ( ) ;
115118 if ( request . url ( ) . includes ( 'GetMap' ) ) {
116119 GetMaps . push ( request . url ( ) ) ;
117120 }
118- } , { times : 4 } ) ;
121+ } , { times : 1 } ) ; // No tiles, if High DPI is enabled we got 4 tiles
119122
120123 // Activate world layer
121124 await page . getByLabel ( 'world' ) . check ( ) ;
@@ -124,11 +127,11 @@ test.describe('Viewport devicePixelRatio 2', () => {
124127 await page . waitForTimeout ( 1000 ) ;
125128
126129 // Check GetMap requests
127- expect ( GetMaps ) . toHaveLength ( 4 ) ;
128- for ( const GetMap of GetMaps ) {
129- expect ( GetMap ) . toContain ( '&WIDTH=870 &' )
130- expect ( GetMap ) . toContain ( '&HEIGHT=620 &' )
131- expect ( GetMap ) . toContain ( '&DPI=180 &' )
130+ expect ( GetMaps ) . toHaveLength ( 1 ) ; // No tiles, if High DPI is enabled we got 4 tiles
131+ for ( const GetMap of GetMaps ) {
132+ expect ( GetMap ) . toContain ( '&WIDTH=957 &' )
133+ expect ( GetMap ) . toContain ( '&HEIGHT=682 &' )
134+ expect ( GetMap ) . toContain ( '&DPI=96 &' )
132135 }
133136 await page . unroute ( '**/service*' )
134137 } )
@@ -164,11 +167,11 @@ test.describe('Viewport mobile', () => {
164167 await expect ( await page . locator ( '#right-dock' ) ) . toBeInViewport ( ) ;
165168
166169 // Choose a feature and check getFeatureInfo
167- let getFeatureInfoRequestPromise = page . waitForRequest ( request => request . method ( ) === 'POST' && request ? .postData ( ) . includes ( 'GetFeatureInfo' ) ) ;
170+ let getFeatureInfoRequestPromise = page . waitForRequest ( request => request . method ( ) === 'POST' && request . postData ( ) . includes ( 'GetFeatureInfo' ) ) ;
168171 await page . locator ( '#liz-atlas-select' ) . selectOption ( '2' ) ;
169172 let getFeatureInfoRequest = await getFeatureInfoRequestPromise ;
170173 let getFeatureInfoResponse = await getFeatureInfoRequest . response ( ) ;
171- await expect ( await getFeatureInfoResponse . headerValue ( 'content-type' ) ) . toContain ( 'text/html' ) ;
174+ await expect ( await getFeatureInfoResponse ? .headerValue ( 'content-type' ) ) . toContain ( 'text/html' ) ;
172175 await expect ( await page . locator ( '#liz-atlas-item-detail .lizmapPopupContent' ) ) . toBeInViewport ( ) ;
173176 await expect ( await page . locator ( '#liz-atlas-item-detail .lizmapPopupContent' ) ) . toContainText ( 'MOSSON' ) ;
174177 // Close atlas
0 commit comments