Skip to content

Commit 975c487

Browse files
committed
Tests e2e: move WMTS Requests from Cypress to Playwright
1 parent cac957a commit 975c487

File tree

2 files changed

+143
-115
lines changed

2 files changed

+143
-115
lines changed

tests/end2end/cypress/integration/requests-service-ghaction.js

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -232,121 +232,6 @@ describe('Request service', function () {
232232
})
233233
})
234234

235-
it('WMTS GetCapabilities', function () {
236-
cy.request('/index.php/lizmap/service/?repository=testsrepository&project=cache&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities')
237-
.then((resp) => {
238-
expect(resp.status).to.eq(200)
239-
expect(resp.headers['content-type']).to.eq('text/xml; charset=utf-8')
240-
expect(resp.headers['cache-control']).to.eq('no-cache')
241-
expect(resp.headers['etag']).to.not.eq(undefined)
242-
243-
expect(resp.body).to.contain('version="1.0.0"')
244-
expect(resp.body).to.contain('<ows:Identifier>Quartiers</ows:Identifier>')
245-
expect(resp.body).to.contain('<TileMatrixSet>EPSG:3857</TileMatrixSet>')
246-
247-
const etag = resp.headers['etag']
248-
cy.request({
249-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities',
250-
headers: {
251-
'If-None-Match': etag,
252-
},
253-
failOnStatusCode: false,
254-
}).then((resp) => {
255-
expect(resp.status).to.eq(304)
256-
expect(resp.body).to.have.length(0)
257-
})
258-
})
259-
})
260-
261-
it('WMTS GetTile', function () {
262-
// Get full transparent tile TILEMATRIX=13&TILEROW=2989&TILECOL=4185
263-
cy.request({
264-
method: 'GET',
265-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache',
266-
qs: {
267-
'SERVICE': 'WMTS',
268-
'VERSION': '1.0.0',
269-
'REQUEST': 'GetTile',
270-
'LAYER': 'Quartiers',
271-
'STYLE': 'default',
272-
'TILEMATRIXSET': 'EPSG:3857',
273-
'TILEMATRIX': '13',
274-
'TILEROW': '2989',
275-
'TILECOL': '4185',
276-
'FORMAT': 'image/png',
277-
},
278-
}).then((resp) => {
279-
expect(resp.status).to.eq(200)
280-
expect(resp.headers['content-type']).to.contain('image/png')
281-
expect(resp.headers).to.have.property('content-length', '355') // Transparent
282-
expect(resp.headers).to.have.property('date')
283-
const tileDate = new Date(resp.headers['date'])
284-
expect(resp.headers).to.have.property('expires')
285-
const tileExpires = new Date(resp.headers['expires'])
286-
expect(tileExpires).to.be.greaterThan(tileDate)
287-
/*expect(resp.body).to.contain('version="1.0.0"')*/
288-
})
289-
290-
// Get not full transparent tile TILEMATRIX=13&TILEROW=2991&TILECOL=4184
291-
cy.request({
292-
method: 'GET',
293-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache',
294-
qs: {
295-
'SERVICE': 'WMTS',
296-
'VERSION': '1.0.0',
297-
'REQUEST': 'GetTile',
298-
'LAYER': 'Quartiers',
299-
'STYLE': 'default',
300-
'TILEMATRIXSET': 'EPSG:3857',
301-
'TILEMATRIX': '13',
302-
'TILEROW': '2991',
303-
'TILECOL': '4184',
304-
'FORMAT': 'image/png',
305-
},
306-
}).then((resp) => {
307-
expect(resp.status).to.eq(200)
308-
expect(resp.headers['content-type']).to.contain('image/png')
309-
expect(resp.headers).to.have.property('content-length')
310-
expect(parseInt(resp.headers['content-length'])).to.be.greaterThan(355) // Not transparent
311-
expect(parseInt(resp.headers['content-length'])).to.be.within(11020, 11030 ) // Monochrome
312-
expect(resp.headers).to.have.property('date')
313-
const tileDate = new Date(resp.headers['date'])
314-
expect(resp.headers).to.have.property('expires')
315-
const tileExpires = new Date(resp.headers['expires'])
316-
expect(tileExpires).to.be.greaterThan(tileDate)
317-
/*expect(resp.body).to.contain('version="1.0.0"')*/
318-
})
319-
320-
// Get monochrome tile TILEMATRIX=15&TILEROW=11964&TILECOL=16736
321-
cy.request({
322-
method: 'GET',
323-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache',
324-
qs: {
325-
'SERVICE': 'WMTS',
326-
'VERSION': '1.0.0',
327-
'REQUEST': 'GetTile',
328-
'LAYER': 'Quartiers',
329-
'STYLE': 'default',
330-
'TILEMATRIXSET': 'EPSG:3857',
331-
'TILEMATRIX': '15',
332-
'TILEROW': '11964',
333-
'TILECOL': '16736',
334-
'FORMAT': 'image/png',
335-
},
336-
}).then((resp) => {
337-
expect(resp.status).to.eq(200)
338-
expect(resp.headers['content-type']).to.contain('image/png')
339-
expect(resp.headers).to.have.property('content-length')
340-
expect(parseInt(resp.headers['content-length'])).to.be.greaterThan(355) // Not transparent
341-
expect(resp.headers).to.have.property('date')
342-
const tileDate = new Date(resp.headers['date'])
343-
expect(resp.headers).to.have.property('expires')
344-
const tileExpires = new Date(resp.headers['expires'])
345-
expect(tileExpires).to.be.greaterThan(tileDate)
346-
/*expect(resp.body).to.contain('version="1.0.0"')*/
347-
})
348-
})
349-
350235
it('Project parameter is mandatory', function () {
351236
cy.request({
352237
url: '/index.php/lizmap/service/?repository=testsrepository&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities',
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// @ts-check
2+
import { test, expect } from '@playwright/test';
3+
4+
test.describe('WMTS Requests @requests @readonly', () => {
5+
test('WMTS Getcapabilities', async({ request }) => {
6+
let params = new URLSearchParams({
7+
repository: 'testsrepository',
8+
project: 'cache',
9+
SERVICE: 'WMTS',
10+
VERSION: '1.0.0',
11+
REQUEST: 'GetCapabilities',
12+
});
13+
let url = `/index.php/lizmap/service?${params}`;
14+
let response = await request.get(url, {});
15+
// check response
16+
expect(response.ok()).toBeTruthy();
17+
expect(response.status()).toBe(200);
18+
// check content-type header
19+
expect(response.headers()['content-type']).toBe('text/xml; charset=utf-8');
20+
// check headers
21+
expect(response.headers()).toHaveProperty('cache-control');
22+
expect(response.headers()['cache-control']).toBe('no-cache');
23+
expect(response.headers()).toHaveProperty('etag');
24+
const etag = response.headers()['etag'];
25+
expect(etag).not.toBe('');
26+
expect(etag).toHaveLength(43);
27+
28+
// check body
29+
let body = await response.text();
30+
expect(body).toContain('Capabilities');
31+
expect(body).toContain('version="1.0.0"');
32+
expect(body).toContain('xmlns="http://www.opengis.net/wmts/1.0"');
33+
expect(body).toContain('<ows:Identifier>Quartiers</ows:Identifier>');
34+
expect(body).toContain('<TileMatrixSet>EPSG:3857</TileMatrixSet>');
35+
36+
// GET request with the etag
37+
response = await request.get(url, {
38+
headers: {
39+
'If-None-Match': etag
40+
}
41+
});
42+
await expect(response).not.toBeOK();
43+
expect(response.status()).toBe(304);
44+
})
45+
46+
test('WMTS GetTile', async({ request }) => {
47+
let params = new URLSearchParams({
48+
repository: 'testsrepository',
49+
project: 'cache',
50+
SERVICE: 'WMTS',
51+
VERSION: '1.0.0',
52+
REQUEST: 'GetTile',
53+
LAYER: 'Quartiers',
54+
STYLE: 'default',
55+
TILEMATRIXSET: 'EPSG:3857',
56+
TILEMATRIX: '13',
57+
TILEROW: '2989',
58+
TILECOL: '4185',
59+
FORMAT: 'image/png',
60+
});
61+
let url = `/index.php/lizmap/service?${params}`;
62+
let response = await request.get(url, {});
63+
// check response
64+
await expect(response).toBeOK();
65+
expect(response.status()).toBe(200);
66+
// check content-type header
67+
expect(response.headers()['content-type']).toBe('image/png');
68+
// check headers
69+
expect(response.headers()).toHaveProperty('content-length');
70+
expect(response.headers()['content-length']).toBe('355'); // Transparent
71+
expect(response.headers()).toHaveProperty('date');
72+
expect(response.headers()).toHaveProperty('expires');
73+
let tileDate = new Date(response.headers()['date'])
74+
let tileExpires = new Date(response.headers()['expires'])
75+
expect(tileExpires > tileDate).toBeTruthy();
76+
77+
params = new URLSearchParams({
78+
repository: 'testsrepository',
79+
project: 'cache',
80+
SERVICE: 'WMTS',
81+
VERSION: '1.0.0',
82+
REQUEST: 'GetTile',
83+
LAYER: 'Quartiers',
84+
STYLE: 'default',
85+
TILEMATRIXSET: 'EPSG:3857',
86+
TILEMATRIX: '13',
87+
TILEROW: '2991',
88+
TILECOL: '4184',
89+
FORMAT: 'image/png',
90+
});
91+
url = `/index.php/lizmap/service?${params}`;
92+
response = await request.get(url, {});
93+
// check response
94+
await expect(response).toBeOK();
95+
expect(response.status()).toBe(200);
96+
// check content-type header
97+
expect(response.headers()['content-type']).toBe('image/png');
98+
// check headers
99+
expect(response.headers()).toHaveProperty('content-length');
100+
let contentLength = Number(response.headers()['content-length']);
101+
expect(contentLength).toBeGreaterThan(355); // Not transparent
102+
expect(contentLength).toBeGreaterThan(11000); // 11019
103+
expect(contentLength).toBeLessThan(11100); // 11019
104+
expect(response.headers()).toHaveProperty('date');
105+
expect(response.headers()).toHaveProperty('expires');
106+
tileDate = new Date(response.headers()['date'])
107+
tileExpires = new Date(response.headers()['expires'])
108+
expect(tileExpires > tileDate).toBeTruthy();
109+
110+
params = new URLSearchParams({
111+
repository: 'testsrepository',
112+
project: 'cache',
113+
SERVICE: 'WMTS',
114+
VERSION: '1.0.0',
115+
REQUEST: 'GetTile',
116+
LAYER: 'Quartiers',
117+
STYLE: 'default',
118+
TILEMATRIXSET: 'EPSG:3857',
119+
TILEMATRIX: '15',
120+
TILEROW: '11964',
121+
TILECOL: '16736',
122+
FORMAT: 'image/png',
123+
});
124+
url = `/index.php/lizmap/service?${params}`;
125+
response = await request.get(url, {});
126+
// check response
127+
await expect(response).toBeOK();
128+
expect(response.status()).toBe(200);
129+
// check content-type header
130+
expect(response.headers()['content-type']).toBe('image/png');
131+
// check headers
132+
expect(response.headers()).toHaveProperty('content-length');
133+
contentLength = Number(response.headers()['content-length']);
134+
expect(contentLength).toBeGreaterThan(355); // Not transparent
135+
expect(contentLength).toBeGreaterThan(650); // 687
136+
expect(contentLength).toBeLessThan(700); // 687
137+
expect(response.headers()).toHaveProperty('date');
138+
expect(response.headers()).toHaveProperty('expires');
139+
tileDate = new Date(response.headers()['date'])
140+
tileExpires = new Date(response.headers()['expires'])
141+
expect(tileExpires > tileDate).toBeTruthy();
142+
})
143+
})

0 commit comments

Comments
 (0)