Skip to content

Commit

Permalink
Tests e2e playwright Print in project projection - mocking GetPrint
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont authored and github-actions[bot] committed Feb 3, 2025
1 parent 8b83cde commit 03edeab
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
33 changes: 33 additions & 0 deletions tests/end2end/playwright/print_in_project_projection.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-check
import * as path from 'path';
import { test, expect } from '@playwright/test';
import { gotoMap, expectParametersToContain } from './globals';

Expand All @@ -15,6 +16,22 @@ test.describe('Print in project projection', () => {
await page.locator('#switcher-baselayer').getByRole('combobox').selectOption('empty');
await page.locator('#print-scale').selectOption('1000');

// Mock file
await page.route('**/service*', async route => {
const request = await route.request();
if (request.postData()?.includes('GetPrint')) {
await route.fulfill({
headers: {
"Content-Description": "File Transfert",
"Content-Disposition": "attachment; filename=\"print_in_project_projection_Paysage_A4.pdf\"",
"Content-Transfer-Encoding": "binary",
"Content-Type": "application/pdf",
},
path: path.join(__dirname, 'mock/print_in_project_projection/empty/Paysage_A4.pdf')
})
}
});

const getPrintPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetPrint') === true);
await page.locator('#print-launch').click();

Expand Down Expand Up @@ -45,6 +62,22 @@ test.describe('Print in project projection', () => {
test('Print external baselayer', async ({ page }) => {
await page.locator('#print-scale').selectOption('1000');

// Mock file
await page.route('**/service*', async route => {
const request = await route.request();
if (request.postData()?.includes('GetPrint')) {
await route.fulfill({
headers: {
"Content-Description": "File Transfert",
"Content-Disposition": "attachment; filename=\"print_in_project_projection_Paysage_A4.pdf\"",
"Content-Transfer-Encoding": "binary",
"Content-Type": "application/pdf",
},
path:path.join(__dirname, 'mock/print_in_project_projection/baselayer/Paysage_A4.pdf')
})
}
});

const getPrintPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetPrint') === true);
await page.locator('#print-launch').click();

Expand Down

0 comments on commit 03edeab

Please sign in to comment.