-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwms-130.spec.js
More file actions
225 lines (202 loc) · 8.53 KB
/
Copy pathwms-130.spec.js
File metadata and controls
225 lines (202 loc) · 8.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
import { test, expect } from '@playwright/test';
import {
routeFixture,
interceptTileRequests,
loadService,
getLayerElements,
activateLayer,
getViewer,
viewerLocator,
} from './helpers.js';
const SERVICE_URL =
'https://test.example.com/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities';
test.beforeEach(async ({ page }) => {
await interceptTileRequests(page);
await routeFixture(page, '**/test.example.com/**', 'wms-130.xml');
await page.goto('/index.html');
});
test.describe('WMS 1.3.0 — Service Info', () => {
test('displays service title and version', async ({ page }) => {
await loadService(page, SERVICE_URL);
const details = page.locator('#service-details');
await expect(details).toContainText('Test WMS 1.3.0 Service');
await expect(details).toContainText('1.3.0');
});
test('shows WMS badge', async ({ page }) => {
await loadService(page, SERVICE_URL);
await expect(page.locator('.service-type-badge')).toContainText('WMS');
});
test('lists correct number of layers', async ({ page }) => {
await loadService(page, SERVICE_URL);
await expect(getLayerElements(page)).toHaveCount(2);
});
test('displays layer titles', async ({ page }) => {
await loadService(page, SERVICE_URL);
const layers = getLayerElements(page);
await expect(layers.nth(0)).toContainText('Temperature Layer');
await expect(layers.nth(1)).toContainText('Administrative Boundaries');
});
});
test.describe('WMS 1.3.0 — Viewer Generation', () => {
test('creates mapml-viewer with correct projection', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const viewer = getViewer(page, 0);
await expect(viewer).toHaveAttribute('projection', 'OSMTILE');
await expect(viewer).toHaveAttribute('controls', '');
});
test('creates map-layer with correct label', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const mapLayer = viewerLocator(page, 0, 'map-layer[data-wms-layer]');
await expect(mapLayer).toHaveAttribute('label', 'Temperature Layer');
await expect(mapLayer).toHaveAttribute('checked', '');
});
test('creates map-extent with correct units', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const mapLayer = viewerLocator(page, 0, 'map-layer[data-wms-layer]');
const extent = mapLayer.locator('map-extent');
await expect(extent).toHaveAttribute('units', 'OSMTILE');
});
test('creates map-input elements for location and size', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const extent = viewerLocator(page, 0, 'map-extent');
// Location inputs
for (const name of ['xmin', 'ymin', 'xmax', 'ymax']) {
await expect(extent.locator(`map-input[name="${name}"]`)).toHaveCount(1);
await expect(extent.locator(`map-input[name="${name}"]`)).toHaveAttribute(
'type',
'location'
);
}
// Size inputs
await expect(extent.locator('map-input[name="w"]')).toHaveAttribute(
'type',
'width'
);
await expect(extent.locator('map-input[name="h"]')).toHaveAttribute(
'type',
'height'
);
// Click coordinate inputs
await expect(extent.locator('map-input[name="i"]')).toHaveCount(1);
await expect(extent.locator('map-input[name="j"]')).toHaveCount(1);
});
});
test.describe('WMS 1.3.0 — Image Link', () => {
test('image tref contains correct WMS 1.3.0 params', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const imageLink = viewerLocator(page, 0, 'map-link[rel="image"]');
const tref = await imageLink.getAttribute('tref');
expect(tref).toContain('SERVICE=WMS');
expect(tref).toContain('VERSION=1.3.0');
expect(tref).toContain('REQUEST=GetMap');
expect(tref).toContain('LAYERS=temperature');
expect(tref).toContain('CRS=EPSG');
expect(tref).toContain('{xmin}');
expect(tref).toContain('{ymin}');
expect(tref).toContain('{xmax}');
expect(tref).toContain('{ymax}');
expect(tref).toContain('{w}');
expect(tref).toContain('{h}');
});
test('style selector is present with correct options', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const selector = viewerLocator(page, 0, 'map-select[name="style"]');
await expect(selector).toHaveCount(1);
const options = selector.locator('map-option');
await expect(options).toHaveCount(2);
await expect(options.nth(0)).toHaveAttribute('value', 'default');
await expect(options.nth(1)).toHaveAttribute('value', 'contour');
});
});
test.describe('WMS 1.3.0 — Query Link', () => {
test('queryable layer has query link by default', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
// Query is enabled by default for queryable layers
const queryLinks = viewerLocator(page, 0, 'map-link[rel="query"]');
await expect(queryLinks).toHaveCount(1);
});
test('query link uses I/J params for WMS 1.3.0', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
// Query is enabled by default
const queryLink = viewerLocator(page, 0, 'map-link[rel="query"]');
await expect(queryLink).toHaveCount(1);
const tref = await queryLink.getAttribute('tref');
expect(tref).toContain('REQUEST=GetFeatureInfo');
// WMS 1.3.0 uses I/J (not X/Y)
expect(tref).toContain('I={i}');
expect(tref).toContain('J={j}');
expect(tref).not.toContain('X={i}');
expect(tref).not.toContain('Y={j}');
});
test('non-queryable layer has no query toggle', async ({ page }) => {
await loadService(page, SERVICE_URL);
// Layer index 1 = "boundaries" (queryable="0")
const layer = page.locator('mapmlify-layer').nth(1);
await expect(layer.locator('.query-format-selector')).toHaveCount(0);
});
});
test.describe('WMS 1.3.0 — License & Legend', () => {
test('license link is present', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const license = viewerLocator(page, 0, 'map-link[rel="license"]');
// At least one license link (basemap + data layer)
expect(await license.count()).toBeGreaterThanOrEqual(1);
});
test('legend link is present for styled layer', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const legend = viewerLocator(page, 0, 'map-link[rel="legend"]');
await expect(legend).toHaveCount(1);
await expect(legend).toHaveAttribute('href', /legend\/temperature/);
});
});
test.describe('WMS 1.3.0 — BBOX Ordering', () => {
test('EPSG:4326 uses lat/lon BBOX order in WMS 1.3.0', async ({ page }) => {
await loadService(page, SERVICE_URL);
// Change projection to WGS84
const layer = page.locator('mapmlify-layer').nth(0);
await layer.locator('select').first().selectOption('WGS84');
// Activate the layer (will rebuild with new projection)
await activateLayer(page, 0);
const imageLink = viewerLocator(page, 0, 'map-link[rel="image"]');
const tref = await imageLink.getAttribute('tref');
expect(tref).toContain('CRS=EPSG:4326');
// 1.3.0 + EPSG:4326 = lat/lon order: BBOX={ymin},{xmin},{ymax},{xmax}
expect(tref).toMatch(/BBOX=\{ymin\},\{xmin\},\{ymax\},\{xmax\}/);
});
test('EPSG:3857 uses standard BBOX order', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const imageLink = viewerLocator(page, 0, 'map-link[rel="image"]');
const tref = await imageLink.getAttribute('tref');
// Standard order: BBOX={xmin},{ymin},{xmax},{ymax}
expect(tref).toMatch(/BBOX=\{xmin\},\{ymin\},\{xmax\},\{ymax\}/);
});
});
test.describe('WMS 1.3.0 — Dimensions', () => {
test('time dimension selector is present', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const extent = viewerLocator(page, 0, 'map-extent');
const timeSelect = extent.locator('map-select[name="time"]');
await expect(timeSelect).toHaveCount(1);
const options = timeSelect.locator('map-option');
await expect(options).toHaveCount(3);
});
test('time dimension appears in image tref', async ({ page }) => {
await loadService(page, SERVICE_URL);
await activateLayer(page, 0);
const imageLink = viewerLocator(page, 0, 'map-link[rel="image"]');
const tref = await imageLink.getAttribute('tref');
expect(tref).toContain('TIME={time}');
});
});