1
+ // @ts -check
1
2
import { test , expect } from '@playwright/test' ;
2
3
3
4
test . describe ( 'Viewport devicePixelRatio 1' , ( ) => {
@@ -34,9 +35,9 @@ test.describe('Viewport devicePixelRatio 1', () => {
34
35
await page . waitForTimeout ( 1000 ) ;
35
36
36
37
// 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 ) ;
38
39
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 ] ) ;
40
41
await page . unroute ( '**/service/getProjectConfig*' )
41
42
42
43
// Catch GetMaps request;
@@ -67,6 +68,7 @@ test.describe('Viewport devicePixelRatio 1', () => {
67
68
} )
68
69
69
70
test . describe ( 'Viewport devicePixelRatio 2' , ( ) => {
71
+ // Force device pixel ratio to 2
70
72
test . use ( {
71
73
deviceScaleFactor : 2 ,
72
74
} ) ;
@@ -103,19 +105,20 @@ test.describe('Viewport devicePixelRatio 2', () => {
103
105
await page . waitForTimeout ( 1000 ) ;
104
106
105
107
// 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 ) ;
107
109
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 ] ) ;
109
111
await page . unroute ( '**/service/getProjectConfig*' )
110
112
111
113
// 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
112
115
let GetMaps = [ ] ;
113
116
await page . route ( '**/service*' , async route => {
114
117
const request = route . request ( ) ;
115
118
if ( request . url ( ) . includes ( 'GetMap' ) ) {
116
119
GetMaps . push ( request . url ( ) ) ;
117
120
}
118
- } , { times : 4 } ) ;
121
+ } , { times : 1 } ) ; // No tiles, if High DPI is enabled we got 4 tiles
119
122
120
123
// Activate world layer
121
124
await page . getByLabel ( 'world' ) . check ( ) ;
@@ -124,11 +127,11 @@ test.describe('Viewport devicePixelRatio 2', () => {
124
127
await page . waitForTimeout ( 1000 ) ;
125
128
126
129
// 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 &' )
132
135
}
133
136
await page . unroute ( '**/service*' )
134
137
} )
@@ -164,11 +167,11 @@ test.describe('Viewport mobile', () => {
164
167
await expect ( await page . locator ( '#right-dock' ) ) . toBeInViewport ( ) ;
165
168
166
169
// 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' ) ) ;
168
171
await page . locator ( '#liz-atlas-select' ) . selectOption ( '2' ) ;
169
172
let getFeatureInfoRequest = await getFeatureInfoRequestPromise ;
170
173
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' ) ;
172
175
await expect ( await page . locator ( '#liz-atlas-item-detail .lizmapPopupContent' ) ) . toBeInViewport ( ) ;
173
176
await expect ( await page . locator ( '#liz-atlas-item-detail .lizmapPopupContent' ) ) . toContainText ( 'MOSSON' ) ;
174
177
// Close atlas
0 commit comments