Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release_3_8] Tests e2e Playwright: Defined global getEchoRequestParams #5236

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/end2end/playwright/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,21 @@ export async function reloadMap(page, check = true) {
await CatchErrors(page);
}
}

/**
* Re-send the request with additional "__echo__" param to retrieve the OGC Request search params
* @param {Page} page The page object
* @param {string} url The URL to re-send
*
* @return {Promise<URLSearchParams>}
*/
export async function getEchoRequestParams(page, url) {
// Re-send the request with additionnal echo param to retrieve the OGC Request
let echoResponse = await page.request.get(url + '&__echo__');
const originalUrl = decodeURIComponent(await echoResponse.text());
// When the request has not been logged by echo proxy
await expect(URL.canParse(originalUrl), originalUrl+' is not an URL!').toBeTruthy();
await expect(originalUrl).not.toContain('unfound')

return new URLSearchParams((new URL(originalUrl).search));
}
11 changes: 3 additions & 8 deletions tests/end2end/playwright/timemanage.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';
import { gotoMap, getEchoRequestParams } from './globals';

test.describe('Time Manager', () => {

Expand Down Expand Up @@ -49,12 +49,8 @@ test.describe('Time Manager', () => {
await expect(urlMapRequest).toMatch(/FILTERTOKEN/);
await expect(urlMapRequest).toContain('FILTERTOKEN='+jsonFiltertokenResponse.token);

// Re-send the request with additionnal echo param to retrieve the WMS Request
let echoGetMap = await page.request.get(urlMapRequest + '&__echo__');
const originalUrl = decodeURIComponent(await echoGetMap.text());
// When the request has not been logged by echo proxy
await expect(URL.canParse(originalUrl), originalUrl+' is not an URL!').toBeTruthy();
await expect(originalUrl).not.toContain('unfound')
// Re-send the request with additional echo param to retrieve the WMS Request search params
const urlObj = await getEchoRequestParams(page, urlMapRequest)

// expected request params
const expectedParamValue = [
Expand All @@ -65,7 +61,6 @@ test.describe('Time Manager', () => {
{ 'param': 'filter', 'expectedvalue': 'time_manager_layer: ( ( "test_date" >= \'' + timeObj.start + '\' ) AND ( "test_date" <= \'' + timeObj.end + '\' ) ) ' },
];
// Check if WMS Request params are as expected
const urlObj = new URLSearchParams((new URL(originalUrl).search));
for (let obj of expectedParamValue) {
await expect(urlObj.has(obj.param), obj.param+' not in ['+Array.from(urlObj.keys()).join(', ')+']').toBeTruthy();
await expect(urlObj.get(obj.param), obj.param+'='+obj.expectedvalue+' not in ['+urlObj.toString().split('&').join(', ')+']').toBe(obj.expectedvalue);
Expand Down
Loading