@@ -14,6 +14,11 @@ import * as path from 'path';
1414 * @typedef {import('@playwright/test').APIResponse } APIResponse
1515 */
1616
17+ /**
18+ * Playwright APIRequestContext
19+ * @typedef {import('@playwright/test').APIRequestContext } APIRequestContext
20+ */
21+
1722/**
1823 * Integer
1924 * @typedef {number } int
@@ -122,7 +127,7 @@ export async function gotoMap(url, page, mapMustLoad = true, layersInTreeView =
122127
123128 await expect ( async ( ) => {
124129 const response = await page . goto ( url ) ;
125- expect ( response . status ( ) ) . toBeLessThan ( 400 ) ;
130+ expect ( response ? .status ( ) ) . toBeLessThan ( 400 ) ;
126131 } ) . toPass ( {
127132 intervals : [ 1_000 , 2_000 , 10_000 ] ,
128133 timeout : 60_000
@@ -134,9 +139,14 @@ export async function gotoMap(url, page, mapMustLoad = true, layersInTreeView =
134139 if ( waitForGetLegendGraphic ) {
135140 // Wait for WMS GetLegendGraphic promise
136141 const getLegendGraphicPromise = page . waitForRequest (
137- request => request . method ( ) === 'POST' &&
142+ request => (
143+ request . method ( ) === 'POST' &&
138144 request . postData ( ) != null &&
139145 request . postData ( ) ?. includes ( 'GetLegendGraphic' ) === true
146+ ) || (
147+ request . method ( ) === 'GET' &&
148+ request . url ( ) . includes ( 'GetLegendGraphic' ) === true
149+ )
140150 ) ;
141151 // Normal check about the map
142152 // Wait for WMS GetLegendGraphic
@@ -167,7 +177,7 @@ export async function reloadMap(page, check = true) {
167177
168178 await expect ( async ( ) => {
169179 const response = await page . reload ( ) ;
170- expect ( response . status ( ) ) . toBeLessThan ( 400 ) ;
180+ expect ( response ? .status ( ) ) . toBeLessThan ( 400 ) ;
171181 } ) . toPass ( {
172182 intervals : [ 1_000 , 2_000 , 10_000 ] ,
173183 timeout : 60_000
@@ -178,10 +188,14 @@ export async function reloadMap(page, check = true) {
178188 if ( check ) {
179189 // Wait for WMS GetLegendGraphic promise
180190 const getLegendGraphicPromise = page . waitForRequest (
181- request =>
191+ request => (
182192 request . method ( ) === 'POST' &&
183193 request . postData ( ) != null &&
184194 request . postData ( ) ?. includes ( 'GetLegendGraphic' ) === true
195+ ) || (
196+ request . method ( ) === 'GET' &&
197+ request . url ( ) . includes ( 'GetLegendGraphic' ) === true
198+ )
185199 ) ;
186200 // Normal check about the map
187201 // Wait for WMS GetLegendGraphic
@@ -245,7 +259,7 @@ export async function expectToHaveLengthCompare(title, parameters, expectedLengt
245259
246260/**
247261 * Get the JSON for the given project using the API
248- * @param {import("playwright-core/types/types.js"). APIRequestContext } request Request to use
262+ * @param {APIRequestContext } request Request to use
249263 * @param {string } project The project name
250264 * @param {string } repository The repository name, default to "testsrepository".
251265 * @returns {Promise<any> } The JSON response
@@ -259,9 +273,9 @@ export async function jsonFromProjectApi(request, project, repository = 'testsre
259273
260274/**
261275 * Get the version of QGIS written in the project
262- * @param {import("playwright-core/types/types.js"). APIRequestContext } request Request to use
276+ * @param {APIRequestContext } request Request to use
263277 * @param {string } project The project name
264- * @returns {int } The QGIS version, written as "34004" for QGIS 3.40.4, to be easily sortable.
278+ * @returns {Promise< int> } The QGIS version, written as "34004" for QGIS 3.40.4, to be easily sortable.
265279 */
266280export async function qgisVersionFromProjectApi ( request , project ) {
267281 const response = await jsonFromProjectApi ( request , project ) ;
@@ -284,12 +298,11 @@ export async function checkJson(response, status = 200) {
284298 return await response . json ( ) ;
285299}
286300
287- /* eslint-disable jsdoc/check-types */
288301/**
289302 * Check parameters against an object containing expected parameters
290303 * @param {string } title Check title, for testing and debug
291304 * @param {string } parameters List of parameters to check
292- * @param {Object< string, string|RegExp> } expectedParameters List of expected parameters
305+ * @param {{[key: string]: string|RegExp} } expectedParameters List of expected parameters
293306 * @returns {Promise<URLSearchParams> } List of promise with parameters
294307 */
295308export async function expectParametersToContain ( title , parameters , expectedParameters ) {
@@ -332,9 +345,9 @@ const adminPassword = "Basic " + btoa("admin:admin");
332345
333346/**
334347 * Create a GET request on a given URL with Basic authentication admin:admin
335- * @param {import("playwright-core/types/types.js"). APIRequestContext } request Request to use
348+ * @param {APIRequestContext } request Request to use
336349 * @param {string } url URL to do a GET request on
337- * @returns {Promise<import("playwright-core/types/types.js"). APIResponse> } Response
350+ * @returns {Promise<APIResponse> } Response
338351 */
339352export async function requestGETWithAdminBasicAuth ( request , url ) {
340353 return await request . get ( url ,
@@ -347,10 +360,10 @@ export async function requestGETWithAdminBasicAuth(request, url) {
347360
348361/**
349362 * Create a POST request on a given URL with Basic authentication admin:admin
350- * @param {import("playwright-core/types/types.js"). APIRequestContext } request Request to use
363+ * @param {APIRequestContext } request Request to use
351364 * @param {string } url URL to do a POST request on
352365 * @param {object } data parameters for the request
353- * @returns {Promise<import("playwright-core/types/types.js"). APIResponse> } Response
366+ * @returns {Promise<APIResponse> } Response
354367 */
355368export async function requestPOSTWithAdminBasicAuth ( request , url , data ) {
356369 return await request . post ( url ,
@@ -364,10 +377,10 @@ export async function requestPOSTWithAdminBasicAuth(request, url, data) {
364377
365378/**
366379 * Create a DELETE request on a given URL with Basic authentication admin:admin
367- * @param {import("playwright-core/types/types.js"). APIRequestContext } request Request to use
380+ * @param {APIRequestContext } request Request to use
368381 * @param {string } url URL to do a DELETE request on
369382 * @param {object } data parameters for the request
370- * @returns {Promise<import("playwright-core/types/types.js"). APIResponse> } Response
383+ * @returns {Promise<APIResponse> } Response
371384 */
372385export async function requestDELETEWithAdminBasicAuth ( request , url , data ) {
373386 return await request . delete ( url ,
@@ -378,4 +391,3 @@ export async function requestDELETEWithAdminBasicAuth(request, url, data) {
378391 data : data
379392 } ) ;
380393}
381- /* eslint-enable jsdoc/check-types */
0 commit comments