|
| 1 | +// @ts-check |
| 2 | +const { test, expect } = require('@playwright/test'); |
| 3 | + |
| 4 | +test.describe('Axis Orientation', () => { |
| 5 | + |
| 6 | + test('Axis Orientation NEU for EPSG:3044', async ({ page }) => { |
| 7 | + const url = '/index.php/view/map/?repository=testsrepository&project=axis_orientation_neu_3044'; |
| 8 | + await page.goto(url, { waitUntil: 'networkidle' }); |
| 9 | + |
| 10 | + const getMapPromise = page.waitForRequest(/GetMap/); |
| 11 | + await page.getByLabel('Bundesländer').check(); |
| 12 | + const getMapRequest = await getMapPromise; |
| 13 | + const getMapUrl = getMapRequest.url(); |
| 14 | + expect(getMapUrl).toContain('SERVICE=WMS'); |
| 15 | + expect(getMapUrl).toContain('VERSION=1.3.0'); |
| 16 | + expect(getMapUrl).toContain('REQUEST=GetMap'); |
| 17 | + expect(getMapUrl).toContain('FORMAT=image%2Fpng'); |
| 18 | + expect(getMapUrl).toContain('TRANSPARENT=true'); |
| 19 | + expect(getMapUrl).toContain('LAYERS=Bundeslander'); |
| 20 | + expect(getMapUrl).toContain('CRS=EPSG%3A3044'); |
| 21 | + expect(getMapUrl).toContain('STYLES=default'); |
| 22 | + expect(getMapUrl).toContain('WIDTH=958'); |
| 23 | + expect(getMapUrl).toContain('HEIGHT=633'); |
| 24 | + expect(getMapUrl).toMatch(/BBOX=5276843.28\d+%2C-14455.54\d+%2C6114251.21\d+%2C1252901.15\d+/); |
| 25 | + |
| 26 | + const getMapResponse = await getMapRequest.response(); |
| 27 | + expect(getMapResponse).not.toBeNull(); |
| 28 | + expect(getMapResponse?.ok()).toBe(true); |
| 29 | + expect(await getMapResponse?.headerValue('Content-Type')).toBe('image/png'); |
| 30 | + // image size greater than transparent |
| 31 | + const contentLength = await getMapResponse?.headerValue('Content-Length'); |
| 32 | + expect(parseInt(contentLength ? contentLength : '0')).toBeGreaterThan(5552); |
| 33 | + |
| 34 | + |
| 35 | + // Catch GetTile request; |
| 36 | + let GetTiles = []; |
| 37 | + await page.route('https://tile.openstreetmap.org/*/*/*.png', (route) => { |
| 38 | + const request = route.request(); |
| 39 | + GetTiles.push(request.url()); |
| 40 | + }, {times: 6}); |
| 41 | + |
| 42 | + await page.locator('#switcher-baselayer').getByRole('combobox').selectOption('OpenStreetMap'); |
| 43 | + await page.waitForTimeout(1000); |
| 44 | + expect(GetTiles).toHaveLength(6); |
| 45 | + expect(GetTiles[0]).toContain('6/33/20.png') |
| 46 | + expect(GetTiles[1]).toContain('6/33/21.png') |
| 47 | + expect(GetTiles[2]).toContain('6/34/20.png') |
| 48 | + expect(GetTiles[3]).toContain('6/34/21.png') |
| 49 | + expect(GetTiles[4]).toContain('6/33/22.png') |
| 50 | + expect(GetTiles[5]).toContain('6/34/22.png') |
| 51 | + await page.unroute('https://tile.openstreetmap.org/*/*/*.png') |
| 52 | + }); |
| 53 | + |
| 54 | + test('Axis Orientation NEU for EPSG:3844', async ({ page }) => { |
| 55 | + const url = '/index.php/view/map/?repository=testsrepository&project=axis_orientation_neu_3844'; |
| 56 | + await page.goto(url, { waitUntil: 'networkidle' }); |
| 57 | + |
| 58 | + const getMapPromise = page.waitForRequest(/GetMap/); |
| 59 | + await page.getByLabel('județ').check(); |
| 60 | + const getMapRequest = await getMapPromise; |
| 61 | + const getMapUrl = getMapRequest.url(); |
| 62 | + expect(getMapUrl).toContain('SERVICE=WMS'); |
| 63 | + expect(getMapUrl).toContain('VERSION=1.3.0'); |
| 64 | + expect(getMapUrl).toContain('REQUEST=GetMap'); |
| 65 | + expect(getMapUrl).toContain('FORMAT=image%2Fpng'); |
| 66 | + expect(getMapUrl).toContain('TRANSPARENT=true'); |
| 67 | + expect(getMapUrl).toContain('LAYERS=judet'); |
| 68 | + expect(getMapUrl).toContain('CRS=EPSG%3A3844'); |
| 69 | + expect(getMapUrl).toContain('STYLES=default'); |
| 70 | + expect(getMapUrl).toContain('WIDTH=958'); |
| 71 | + expect(getMapUrl).toContain('HEIGHT=633'); |
| 72 | + expect(getMapUrl).toMatch(/BBOX=72126.00\d+%2C-122200.57\d+%2C909533.92\d+%2C1145156.12\d+/); |
| 73 | + |
| 74 | + const getMapResponse = await getMapRequest.response(); |
| 75 | + expect(getMapResponse).not.toBeNull(); |
| 76 | + expect(getMapResponse?.ok()).toBe(true); |
| 77 | + expect(await getMapResponse?.headerValue('Content-Type')).toBe('image/png'); |
| 78 | + // image size greater than transparent |
| 79 | + const contentLength = await getMapResponse?.headerValue('Content-Length'); |
| 80 | + expect(parseInt(contentLength ? contentLength : '0')).toBeGreaterThan(5552); |
| 81 | + // image size lesser than disorder axis |
| 82 | + expect(parseInt(contentLength ? contentLength : '0')).toBeLessThan(240115); |
| 83 | + |
| 84 | + // Catch GetTile request; |
| 85 | + let GetTiles = []; |
| 86 | + await page.route('https://tile.openstreetmap.org/*/*/*.png', (route) => { |
| 87 | + const request = route.request(); |
| 88 | + GetTiles.push(request.url()); |
| 89 | + }, {times: 6}); |
| 90 | + await page.locator('#switcher-baselayer').getByRole('combobox').selectOption('OpenStreetMap'); |
| 91 | + await page.waitForTimeout(1000); |
| 92 | + expect(GetTiles).toHaveLength(6); |
| 93 | + expect(GetTiles[0]).toContain('6/35/22.png') |
| 94 | + expect(GetTiles[1]).toContain('6/35/23.png') |
| 95 | + expect(GetTiles[2]).toContain('6/36/22.png') |
| 96 | + expect(GetTiles[3]).toContain('6/36/23.png') |
| 97 | + expect(GetTiles[4]).toContain('6/37/22.png') |
| 98 | + expect(GetTiles[5]).toContain('6/37/23.png') |
| 99 | + await page.unroute('https://tile.openstreetmap.org/*/*/*.png') |
| 100 | + }); |
| 101 | +}); |
0 commit comments