terra-draw 1.0.0-beta.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.versionrc.cjs +9 -0
- package/README.md +4 -47
- package/dist/common/adapter-listener.spec.d.ts +1 -0
- package/dist/{adapters/common → common}/base.adapter.d.ts +1 -1
- package/dist/common.d.ts +7 -5
- package/dist/extend.d.ts +4 -3
- package/dist/geometry/boolean/is-valid-coordinate.spec.d.ts +1 -0
- package/dist/geometry/boolean/point-in-polygon.spec.d.ts +1 -0
- package/dist/geometry/boolean/self-intersects.spec.d.ts +1 -0
- package/dist/geometry/calculate-relative-angle.d.ts +2 -10
- package/dist/geometry/calculate-relative-angle.spec.d.ts +1 -0
- package/dist/geometry/centroid.spec.d.ts +1 -0
- package/dist/geometry/clockwise.d.ts +2 -10
- package/dist/geometry/clockwise.spec.d.ts +1 -0
- package/dist/geometry/coordinates-identical.spec.d.ts +1 -0
- package/dist/geometry/determine-halfplane.d.ts +2 -10
- package/dist/geometry/determine-halfplane.spec.d.ts +1 -0
- package/dist/geometry/get-coordinates-as-points.spec.d.ts +1 -0
- package/dist/geometry/get-midpoint.spec.d.ts +1 -0
- package/dist/geometry/limit-decimal-precision.spec.d.ts +1 -0
- package/dist/geometry/measure/bearing.d.ts +2 -7
- package/dist/geometry/measure/bearing.spec.d.ts +1 -0
- package/dist/geometry/measure/desination.spec.d.ts +1 -0
- package/dist/geometry/measure/destination.d.ts +2 -7
- package/dist/geometry/measure/haversine-distance.spec.d.ts +1 -0
- package/dist/geometry/measure/pixel-distance-to-line.d.ts +2 -10
- package/dist/geometry/measure/pixel-distance-to-line.spec.d.ts +1 -0
- package/dist/geometry/measure/pixel-distance.d.ts +2 -7
- package/dist/geometry/measure/pixel-distance.spec.d.ts +1 -0
- package/dist/geometry/measure/rhumb-bearing.spec.d.ts +1 -0
- package/dist/geometry/measure/rhumb-destination.spec.d.ts +1 -0
- package/dist/geometry/measure/rhumb-distance.spec.d.ts +1 -0
- package/dist/geometry/point-on-line.d.ts +5 -0
- package/dist/geometry/point-on-line.spec.d.ts +1 -0
- package/dist/geometry/project/web-mercator.d.ts +2 -4
- package/dist/geometry/project/web-mercator.spec.d.ts +1 -0
- package/dist/geometry/shape/create-bbox.spec.d.ts +1 -0
- package/dist/geometry/shape/create-circle.spec.d.ts +1 -0
- package/dist/geometry/shape/great-circle-coordinates.spec.d.ts +1 -0
- package/dist/geometry/shape/web-mercator-distortion.spec.d.ts +1 -0
- package/dist/geometry/transform/rotate.spec.d.ts +1 -0
- package/dist/geometry/transform/scale.spec.d.ts +1 -0
- package/dist/geometry/web-mercator-centroid.d.ts +2 -4
- package/dist/geometry/web-mercator-centroid.spec.d.ts +1 -0
- package/dist/geometry/web-mercator-point-on-line.d.ts +11 -0
- package/dist/geometry/web-mercator-point-on-line.spec.d.ts +1 -0
- package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +0 -1
- package/dist/modes/angled-rectangle/angled-rectangle.mode.spec.d.ts +1 -0
- package/dist/modes/circle/circle.mode.spec.d.ts +1 -0
- package/dist/modes/click-bounding-box.behavior.spec.d.ts +1 -0
- package/dist/modes/coordinate-snapping.behavior.d.ts +16 -0
- package/dist/modes/coordinate-snapping.behavior.spec.d.ts +1 -0
- package/dist/modes/freehand/freehand.mode.spec.d.ts +1 -0
- package/dist/modes/insert-coordinates.behavior.spec.d.ts +1 -0
- package/dist/modes/{snapping.behavior.d.ts → line-snapping.behavior.d.ts} +1 -1
- package/dist/modes/line-snapping.behavior.spec.d.ts +1 -0
- package/dist/modes/linestring/linestring.mode.d.ts +14 -3
- package/dist/modes/linestring/linestring.mode.spec.d.ts +1 -0
- package/dist/modes/pixel-distance.behavior.spec.d.ts +1 -0
- package/dist/modes/point/point.mode.spec.d.ts +1 -0
- package/dist/modes/polygon/behaviors/closing-points.behavior.spec.d.ts +1 -0
- package/dist/modes/polygon/polygon.mode.d.ts +15 -2
- package/dist/modes/polygon/polygon.mode.spec.d.ts +1 -0
- package/dist/modes/rectangle/rectangle.mode.spec.d.ts +1 -0
- package/dist/modes/render/render.mode.spec.d.ts +1 -0
- package/dist/modes/sector/sector.mode.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/drag-coordinate-resize.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/drag-coordinate.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/drag-feature.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/feature-at-pointer-event.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/midpoint.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/rotate-feature.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/scale-feature.behavior.spec.d.ts +1 -0
- package/dist/modes/select/behaviors/selection-point.behavior.spec.d.ts +1 -0
- package/dist/modes/select/select.mode.spec.d.ts +1 -0
- package/dist/modes/sensor/sensor.mode.spec.d.ts +1 -0
- package/dist/modes/static/static.mode.spec.d.ts +1 -0
- package/dist/store/spatial-index/quickselect.spec.d.ts +1 -0
- package/dist/store/spatial-index/rbush.spec.d.ts +1 -0
- package/dist/store/spatial-index/spatial-index.spec.d.ts +1 -0
- package/dist/store/store-validation.spec.d.ts +1 -0
- package/dist/store/store.spec.d.ts +1 -0
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +6 -8
- package/dist/terra-draw.extensions.spec.d.ts +28 -0
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.spec.d.ts +1 -0
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/dist/test/create-store-features.d.ts +6 -0
- package/dist/test/jest.matchers.d.ts +1 -0
- package/dist/test/mock-behavior-config.d.ts +2 -0
- package/dist/test/mock-callbacks.d.ts +2 -0
- package/dist/test/mock-cursor-event.d.ts +6 -0
- package/dist/test/mock-features.d.ts +4 -0
- package/dist/test/mock-keyboard-event.d.ts +5 -0
- package/dist/test/mock-mode-config.d.ts +21 -0
- package/dist/test/mock-pointer-event.d.ts +1 -0
- package/dist/util/geom.spec.d.ts +1 -0
- package/dist/util/id.spec.d.ts +1 -0
- package/dist/util/styling.spec.d.ts +1 -0
- package/dist/validations/linestring.validation.spec.d.ts +1 -0
- package/dist/validations/max-size.validation.spec.d.ts +1 -0
- package/dist/validations/min-size.validation.spec.d.ts +1 -0
- package/dist/validations/not-self-intersecting.validation.spec.d.ts +1 -0
- package/dist/validations/point.validation.spec.d.ts +1 -0
- package/dist/validations/polygon.validation.spec.d.ts +1 -0
- package/jest.nocheck.config.ts +5 -14
- package/package.json +8 -119
- package/tsconfig.json +6 -25
- package/.devcontainer/Dockerfile +0 -8
- package/.devcontainer/devcontainer.json +0 -27
- package/.devcontainer/post-create.sh +0 -16
- package/LICENSE +0 -8
- package/dist/adapters/arcgis-maps-sdk.adapter.d.ts +0 -106
- package/dist/adapters/google-maps.adapter.d.ts +0 -90
- package/dist/adapters/leaflet.adapter.d.ts +0 -99
- package/dist/adapters/mapbox-gl.adapter.d.ts +0 -90
- package/dist/adapters/maplibre-gl.adapter.d.ts +0 -72
- package/dist/adapters/openlayers.adapter.d.ts +0 -121
- package/e2e/README.md +0 -29
- package/e2e/package-lock.json +0 -4275
- package/e2e/package.json +0 -26
- package/e2e/playwright.config.ts +0 -77
- package/e2e/public/favicon.ico +0 -0
- package/e2e/public/index.html +0 -55
- package/e2e/tests/leaflet.spec.ts +0 -1040
- package/e2e/tests/setup.ts +0 -208
- package/e2e/webpack.config.js +0 -36
- package/eslint.config.js +0 -31
- /package/dist/{adapters/common → common}/adapter-listener.d.ts +0 -0
|
@@ -1,1040 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@playwright/test";
|
|
2
|
-
import {
|
|
3
|
-
changeMode,
|
|
4
|
-
drawTwoClickShape,
|
|
5
|
-
drawRectangularPolygon,
|
|
6
|
-
expectGroupPosition,
|
|
7
|
-
expectPathDimensions,
|
|
8
|
-
expectPaths,
|
|
9
|
-
pageUrl,
|
|
10
|
-
setupMap,
|
|
11
|
-
TestConfigOptions,
|
|
12
|
-
} from "./setup";
|
|
13
|
-
|
|
14
|
-
test.describe("page setup", () => {
|
|
15
|
-
test("loads map", async ({ page }) => {
|
|
16
|
-
await page.goto(pageUrl);
|
|
17
|
-
|
|
18
|
-
// Expect map application to exist
|
|
19
|
-
await expect(page.getByRole("application")).toBeVisible();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("loads UI", async ({ page }) => {
|
|
23
|
-
await page.goto(pageUrl);
|
|
24
|
-
|
|
25
|
-
await expect(page.getByText("Point")).toBeVisible();
|
|
26
|
-
await expect(page.getByText("Linestring")).toBeVisible();
|
|
27
|
-
await expect(page.getByText("Polygon")).toBeVisible();
|
|
28
|
-
await expect(page.getByText("Select")).toBeVisible();
|
|
29
|
-
await expect(page.getByText("Clear")).toBeVisible();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("there are no console errors", async ({ page }) => {
|
|
33
|
-
const errors: string[] = [];
|
|
34
|
-
page.on("console", (msg) => {
|
|
35
|
-
if (msg.type() === "error") {
|
|
36
|
-
errors.push(msg.text());
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
await page.goto(pageUrl);
|
|
40
|
-
await expect(page.getByRole("application")).toBeVisible();
|
|
41
|
-
|
|
42
|
-
expect(errors).toEqual([]);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("there are no build issues", async ({ page }) => {
|
|
46
|
-
await page.goto(pageUrl);
|
|
47
|
-
await expect(
|
|
48
|
-
await page.locator("#webpack-dev-server-client-overlay").count(),
|
|
49
|
-
).toBe(0);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test.describe("point mode", () => {
|
|
54
|
-
const mode = "point";
|
|
55
|
-
|
|
56
|
-
test("mode can set and used to create a point", async ({ page }) => {
|
|
57
|
-
const mapDiv = await setupMap({ page });
|
|
58
|
-
await changeMode({ page, mode });
|
|
59
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
60
|
-
|
|
61
|
-
await expectPaths({ page, count: 1 });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test("mode can set and used to create multiple points", async ({ page }) => {
|
|
65
|
-
const mapDiv = await setupMap({ page });
|
|
66
|
-
await changeMode({ page, mode });
|
|
67
|
-
|
|
68
|
-
await page.mouse.click(mapDiv.width / 4, mapDiv.height / 4);
|
|
69
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
70
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
71
|
-
|
|
72
|
-
await expectPaths({ page, count: 3 });
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test.describe("linestring mode", () => {
|
|
77
|
-
const mode = "linestring";
|
|
78
|
-
|
|
79
|
-
const options = [
|
|
80
|
-
{ name: "", config: undefined },
|
|
81
|
-
{
|
|
82
|
-
name: " with insert coordinates for web mercator projection",
|
|
83
|
-
config: ["insertCoordinates"],
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: " with insert coordinates for globe projection",
|
|
87
|
-
config: ["insertCoordinatesGlobe"],
|
|
88
|
-
},
|
|
89
|
-
] as { name: string; config: TestConfigOptions[] }[];
|
|
90
|
-
|
|
91
|
-
for (const { name, config } of options) {
|
|
92
|
-
test(`mode can set and used to create a linestring${name}`, async ({
|
|
93
|
-
page,
|
|
94
|
-
}) => {
|
|
95
|
-
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
96
|
-
await changeMode({ page, mode });
|
|
97
|
-
|
|
98
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2);
|
|
99
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
100
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3);
|
|
101
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
102
|
-
|
|
103
|
-
// Close
|
|
104
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
105
|
-
|
|
106
|
-
await expectPaths({ page, count: 1 });
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test(`mode can set and used to create a linestring with multiple points${name}`, async ({
|
|
110
|
-
page,
|
|
111
|
-
}) => {
|
|
112
|
-
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
113
|
-
await changeMode({ page, mode });
|
|
114
|
-
|
|
115
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2);
|
|
116
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
117
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3);
|
|
118
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
119
|
-
|
|
120
|
-
// Draw coordinate 2
|
|
121
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2);
|
|
122
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
123
|
-
|
|
124
|
-
// Draw coordinate 3
|
|
125
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 3);
|
|
126
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 3);
|
|
127
|
-
|
|
128
|
-
// Close
|
|
129
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 3);
|
|
130
|
-
|
|
131
|
-
await expectPaths({ page, count: 1 });
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test(`mode can set and used to create a linestring with multiple clicked points${name}`, async ({
|
|
135
|
-
page,
|
|
136
|
-
}) => {
|
|
137
|
-
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
138
|
-
await changeMode({ page, mode });
|
|
139
|
-
|
|
140
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2);
|
|
141
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
142
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3);
|
|
143
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
144
|
-
|
|
145
|
-
// Draw coordinate 2
|
|
146
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2);
|
|
147
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
148
|
-
|
|
149
|
-
// Draw coordinate 3
|
|
150
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 3);
|
|
151
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 3);
|
|
152
|
-
|
|
153
|
-
// Close
|
|
154
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 3);
|
|
155
|
-
|
|
156
|
-
await expectPaths({ page, count: 1 });
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test(`mode can set and used to create multiple linestrings${name}`, async ({
|
|
160
|
-
page,
|
|
161
|
-
}) => {
|
|
162
|
-
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
163
|
-
await changeMode({ page, mode });
|
|
164
|
-
|
|
165
|
-
// First line
|
|
166
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2);
|
|
167
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
168
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3);
|
|
169
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
170
|
-
|
|
171
|
-
// One point + one line
|
|
172
|
-
await expectPaths({ page, count: 2 });
|
|
173
|
-
|
|
174
|
-
// Close first line
|
|
175
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
176
|
-
|
|
177
|
-
// One line
|
|
178
|
-
await expectPaths({ page, count: 1 });
|
|
179
|
-
|
|
180
|
-
// Second line
|
|
181
|
-
await page.mouse.move(mapDiv.width / 4, mapDiv.height / 4);
|
|
182
|
-
await page.mouse.click(mapDiv.width / 4, mapDiv.height / 4);
|
|
183
|
-
await page.mouse.move(mapDiv.width / 5, mapDiv.height / 5);
|
|
184
|
-
await page.mouse.click(mapDiv.width / 5, mapDiv.height / 5);
|
|
185
|
-
|
|
186
|
-
// Close second line
|
|
187
|
-
await page.mouse.click(mapDiv.width / 5, mapDiv.height / 5);
|
|
188
|
-
|
|
189
|
-
// Two lines
|
|
190
|
-
await expectPaths({ page, count: 2 });
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test.describe("polygon mode", () => {
|
|
196
|
-
const mode = "polygon";
|
|
197
|
-
|
|
198
|
-
test("mode can set and used to create a polygon", async ({ page }) => {
|
|
199
|
-
const mapDiv = await setupMap({ page });
|
|
200
|
-
await changeMode({ page, mode });
|
|
201
|
-
|
|
202
|
-
// The length of the square sides in pixels
|
|
203
|
-
const sideLength = 100;
|
|
204
|
-
|
|
205
|
-
// Calculating the half of the side length
|
|
206
|
-
const halfLength = sideLength / 2;
|
|
207
|
-
|
|
208
|
-
// Coordinates of the center
|
|
209
|
-
const centerX = mapDiv.width / 2;
|
|
210
|
-
const centerY = mapDiv.height / 2;
|
|
211
|
-
|
|
212
|
-
// Coordinates of the four corners of the square
|
|
213
|
-
const topLeft = { x: centerX - halfLength, y: centerY - halfLength };
|
|
214
|
-
const topRight = { x: centerX + halfLength, y: centerY - halfLength };
|
|
215
|
-
const bottomLeft = { x: centerX - halfLength, y: centerY + halfLength };
|
|
216
|
-
const bottomRight = { x: centerX + halfLength, y: centerY + halfLength };
|
|
217
|
-
|
|
218
|
-
// Perform clicks at each corner
|
|
219
|
-
await page.mouse.click(topLeft.x, topLeft.y);
|
|
220
|
-
await page.mouse.click(topRight.x, topRight.y);
|
|
221
|
-
await page.mouse.click(bottomRight.x, bottomRight.y);
|
|
222
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
223
|
-
|
|
224
|
-
// Close the square
|
|
225
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
226
|
-
|
|
227
|
-
// One point + one line
|
|
228
|
-
await expectPaths({ page, count: 1 });
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
test("can use validation setting to prevent maximum size", async ({
|
|
232
|
-
page,
|
|
233
|
-
}) => {
|
|
234
|
-
const mapDiv = await setupMap({
|
|
235
|
-
page,
|
|
236
|
-
configQueryParam: ["validationFailure"],
|
|
237
|
-
});
|
|
238
|
-
await changeMode({ page, mode });
|
|
239
|
-
|
|
240
|
-
// The length of the square sides in pixels
|
|
241
|
-
const sideLength = 100;
|
|
242
|
-
|
|
243
|
-
// Calculating the half of the side length
|
|
244
|
-
const halfLength = sideLength / 2;
|
|
245
|
-
|
|
246
|
-
// Coordinates of the center
|
|
247
|
-
const centerX = mapDiv.width / 2;
|
|
248
|
-
const centerY = mapDiv.height / 2;
|
|
249
|
-
|
|
250
|
-
// Coordinates of the four corners of the square
|
|
251
|
-
const topLeft = { x: centerX - halfLength, y: centerY - halfLength };
|
|
252
|
-
const topRight = { x: centerX + halfLength, y: centerY - halfLength };
|
|
253
|
-
const bottomLeft = { x: centerX - halfLength, y: centerY + halfLength };
|
|
254
|
-
const bottomRight = { x: centerX + halfLength, y: centerY + halfLength };
|
|
255
|
-
|
|
256
|
-
// Perform clicks at each corner
|
|
257
|
-
await page.mouse.click(topLeft.x, topLeft.y);
|
|
258
|
-
await page.mouse.click(topRight.x, topRight.y);
|
|
259
|
-
await page.mouse.click(bottomRight.x, bottomRight.y);
|
|
260
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
261
|
-
|
|
262
|
-
// Attempt to close the square
|
|
263
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
264
|
-
|
|
265
|
-
// Square will fail, as triangle will be 705665 square meters, but square will be
|
|
266
|
-
// over the limit of 1000000 square meters.
|
|
267
|
-
await expectPaths({ page, count: 3 });
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
test("can use validation setting to draw underneath maximum size ", async ({
|
|
271
|
-
page,
|
|
272
|
-
}) => {
|
|
273
|
-
const mapDiv = await setupMap({
|
|
274
|
-
page,
|
|
275
|
-
configQueryParam: ["validationSuccess"],
|
|
276
|
-
});
|
|
277
|
-
await changeMode({ page, mode });
|
|
278
|
-
|
|
279
|
-
// The length of the square sides in pixels
|
|
280
|
-
const sideLength = 100;
|
|
281
|
-
|
|
282
|
-
// Calculating the half of the side length
|
|
283
|
-
const halfLength = sideLength / 2;
|
|
284
|
-
|
|
285
|
-
// Coordinates of the center
|
|
286
|
-
const centerX = mapDiv.width / 2;
|
|
287
|
-
const centerY = mapDiv.height / 2;
|
|
288
|
-
|
|
289
|
-
// Coordinates of the four corners of the square
|
|
290
|
-
const topLeft = { x: centerX - halfLength, y: centerY - halfLength };
|
|
291
|
-
const topRight = { x: centerX + halfLength, y: centerY - halfLength };
|
|
292
|
-
const bottomLeft = { x: centerX - halfLength, y: centerY + halfLength };
|
|
293
|
-
const bottomRight = { x: centerX + halfLength, y: centerY + halfLength };
|
|
294
|
-
|
|
295
|
-
// Perform clicks at each corner
|
|
296
|
-
await page.mouse.click(topLeft.x, topLeft.y);
|
|
297
|
-
await page.mouse.click(topRight.x, topRight.y);
|
|
298
|
-
await page.mouse.click(bottomRight.x, bottomRight.y);
|
|
299
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
300
|
-
|
|
301
|
-
// Attempt to close the square
|
|
302
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
303
|
-
|
|
304
|
-
// Square will fail, as triangle will be 705665 square meters, but square will be
|
|
305
|
-
// over the limit of 1000000 square meters.
|
|
306
|
-
await expectPaths({ page, count: 1 });
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
test.describe("rectangle mode", () => {
|
|
311
|
-
const mode = "rectangle";
|
|
312
|
-
|
|
313
|
-
test("mode can set and used to create a rectangle", async ({ page }) => {
|
|
314
|
-
const mapDiv = await setupMap({ page });
|
|
315
|
-
await changeMode({ page, mode });
|
|
316
|
-
|
|
317
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
318
|
-
await page.mouse.click(mapDiv.width / 2 + 50, mapDiv.height / 2 + 50);
|
|
319
|
-
|
|
320
|
-
// One point + one line
|
|
321
|
-
await expectPaths({ page, count: 1 });
|
|
322
|
-
|
|
323
|
-
await expectPathDimensions({ page, width: 54, height: 54 }); // Stroke width of 4
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
test.describe("angled rectangle mode", () => {
|
|
328
|
-
const mode = "angled-rectangle";
|
|
329
|
-
|
|
330
|
-
test("mode can set and used to create an angled rectangle (horizontal up)", async ({
|
|
331
|
-
page,
|
|
332
|
-
}) => {
|
|
333
|
-
const mapDiv = await setupMap({ page });
|
|
334
|
-
await changeMode({ page, mode });
|
|
335
|
-
|
|
336
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
337
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
338
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
339
|
-
await page.mouse.move(mapDiv.width / 3 + 50, mapDiv.height / 3 + 50, {
|
|
340
|
-
steps: 30,
|
|
341
|
-
});
|
|
342
|
-
await page.mouse.click(mapDiv.width / 3 + 50, mapDiv.height / 3 + 50);
|
|
343
|
-
|
|
344
|
-
await expectPaths({ page, count: 1 });
|
|
345
|
-
|
|
346
|
-
await expectPathDimensions({ page, width: 217, height: 74 });
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
test("mode can set and used to create an angled rectangle (horizontal down)", async ({
|
|
350
|
-
page,
|
|
351
|
-
}) => {
|
|
352
|
-
const mapDiv = await setupMap({ page });
|
|
353
|
-
await changeMode({ page, mode });
|
|
354
|
-
|
|
355
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
356
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
357
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
358
|
-
await page.mouse.move(mapDiv.width / 3 + 50, mapDiv.height / 3 + 200, {
|
|
359
|
-
steps: 30,
|
|
360
|
-
});
|
|
361
|
-
await page.mouse.click(mapDiv.width / 3 + 50, mapDiv.height / 3 + 200);
|
|
362
|
-
|
|
363
|
-
await expectPaths({ page, count: 1 });
|
|
364
|
-
|
|
365
|
-
await expectPathDimensions({ page, width: 217, height: 84 });
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
test("mode can set and used to create an angled (diagonal)", async ({
|
|
369
|
-
page,
|
|
370
|
-
}) => {
|
|
371
|
-
const mapDiv = await setupMap({ page });
|
|
372
|
-
await changeMode({ page, mode });
|
|
373
|
-
|
|
374
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
375
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, { steps: 30 });
|
|
376
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
377
|
-
await page.mouse.move(mapDiv.width / 3 + 150, mapDiv.height / 3 + 150, {
|
|
378
|
-
steps: 30,
|
|
379
|
-
});
|
|
380
|
-
await page.mouse.click(mapDiv.width / 3 + 150, mapDiv.height / 3 + 150);
|
|
381
|
-
|
|
382
|
-
await expectPaths({ page, count: 1 });
|
|
383
|
-
|
|
384
|
-
await expectPathDimensions({ page, width: 245, height: 174 });
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
test("mode can set and used to create an angled (diagonal 2)", async ({
|
|
388
|
-
page,
|
|
389
|
-
}) => {
|
|
390
|
-
const mapDiv = await setupMap({ page });
|
|
391
|
-
await changeMode({ page, mode });
|
|
392
|
-
|
|
393
|
-
await page.mouse.click(mapDiv.width / 1.8, mapDiv.height / 1.8);
|
|
394
|
-
await page.mouse.move(mapDiv.width / 2.5, mapDiv.height / 1.3, {
|
|
395
|
-
steps: 30,
|
|
396
|
-
});
|
|
397
|
-
await page.mouse.click(mapDiv.width / 2.5, mapDiv.height / 1.3);
|
|
398
|
-
await page.mouse.move(mapDiv.width / 2.5 + 50, mapDiv.height / 1.3 + 50, {
|
|
399
|
-
steps: 30,
|
|
400
|
-
});
|
|
401
|
-
await page.mouse.click(mapDiv.width / 2.5 + 50, mapDiv.height / 1.3 + 50);
|
|
402
|
-
|
|
403
|
-
await expectPaths({ page, count: 1 });
|
|
404
|
-
|
|
405
|
-
await expectPathDimensions({ page, width: 246, height: 213 });
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
test.describe("sector mode", () => {
|
|
410
|
-
const mode = "sector";
|
|
411
|
-
|
|
412
|
-
test("mode can set and used to create a sector less than 90 degrees (clockwise)", async ({
|
|
413
|
-
page,
|
|
414
|
-
}) => {
|
|
415
|
-
const mapDiv = await setupMap({ page });
|
|
416
|
-
await changeMode({ page, mode });
|
|
417
|
-
|
|
418
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
419
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
420
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
421
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, {
|
|
422
|
-
steps: 30,
|
|
423
|
-
});
|
|
424
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
425
|
-
|
|
426
|
-
await expectPaths({ page, count: 1 });
|
|
427
|
-
|
|
428
|
-
await expectPathDimensions({ page, width: 217, height: 109 });
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
test("mode can set and used to create a sector more than 90 degrees (clockwise)", async ({
|
|
432
|
-
page,
|
|
433
|
-
}) => {
|
|
434
|
-
const mapDiv = await setupMap({ page });
|
|
435
|
-
await changeMode({ page, mode });
|
|
436
|
-
|
|
437
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
438
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
439
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
440
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
441
|
-
steps: 30,
|
|
442
|
-
});
|
|
443
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
|
|
444
|
-
|
|
445
|
-
await expectPaths({ page, count: 1 });
|
|
446
|
-
|
|
447
|
-
await expectPathDimensions({ page, width: 417, height: 217 });
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
test("mode can set and used to create a sector more than 180 degrees (clockwise)", async ({
|
|
451
|
-
page,
|
|
452
|
-
}) => {
|
|
453
|
-
const mapDiv = await setupMap({ page });
|
|
454
|
-
await changeMode({ page, mode });
|
|
455
|
-
|
|
456
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
457
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
458
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
459
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
460
|
-
steps: 10,
|
|
461
|
-
});
|
|
462
|
-
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
463
|
-
steps: 10,
|
|
464
|
-
});
|
|
465
|
-
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
466
|
-
|
|
467
|
-
await expectPaths({ page, count: 1 });
|
|
468
|
-
|
|
469
|
-
await expectPathDimensions({ page, width: 430, height: 430 });
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
test("mode can set and used to create a sector less than 90 degrees (anticlockwise)", async ({
|
|
473
|
-
page,
|
|
474
|
-
}) => {
|
|
475
|
-
const mapDiv = await setupMap({ page });
|
|
476
|
-
await changeMode({ page, mode });
|
|
477
|
-
|
|
478
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
479
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
480
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
481
|
-
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
482
|
-
steps: 30,
|
|
483
|
-
});
|
|
484
|
-
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
485
|
-
|
|
486
|
-
await expectPaths({ page, count: 1 });
|
|
487
|
-
|
|
488
|
-
await expectPathDimensions({ page, width: 217, height: 150 });
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
test("mode can set and used to create a sector more than 90 degrees (anticlockwise)", async ({
|
|
492
|
-
page,
|
|
493
|
-
}) => {
|
|
494
|
-
const mapDiv = await setupMap({ page });
|
|
495
|
-
await changeMode({ page, mode });
|
|
496
|
-
|
|
497
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
498
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
499
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
500
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
501
|
-
steps: 30,
|
|
502
|
-
});
|
|
503
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 1.5);
|
|
504
|
-
|
|
505
|
-
await expectPaths({ page, count: 1 });
|
|
506
|
-
|
|
507
|
-
await expectPathDimensions({ page, width: 417, height: 217 });
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
test("mode can set and used to create a sector more than 180 degrees (anticlockwise)", async ({
|
|
511
|
-
page,
|
|
512
|
-
}) => {
|
|
513
|
-
const mapDiv = await setupMap({ page });
|
|
514
|
-
await changeMode({ page, mode });
|
|
515
|
-
|
|
516
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
517
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
518
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
519
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
520
|
-
steps: 30,
|
|
521
|
-
});
|
|
522
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
523
|
-
steps: 30,
|
|
524
|
-
});
|
|
525
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
|
|
526
|
-
|
|
527
|
-
await expectPaths({ page, count: 1 });
|
|
528
|
-
|
|
529
|
-
await expectPathDimensions({ page, width: 430, height: 292 });
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
test.describe("sensor mode", () => {
|
|
534
|
-
const mode = "sensor";
|
|
535
|
-
|
|
536
|
-
test("mode can set and creates center point on first click", async ({
|
|
537
|
-
page,
|
|
538
|
-
}) => {
|
|
539
|
-
const mapDiv = await setupMap({ page });
|
|
540
|
-
await changeMode({ page, mode });
|
|
541
|
-
|
|
542
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
543
|
-
|
|
544
|
-
await expectPaths({ page, count: 1 });
|
|
545
|
-
|
|
546
|
-
await expectPathDimensions({ page, width: 12, height: 12 });
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
test("mode can set and but won't close if the mouse goes behind the initial arc", async ({
|
|
550
|
-
page,
|
|
551
|
-
}) => {
|
|
552
|
-
const mapDiv = await setupMap({ page });
|
|
553
|
-
await changeMode({ page, mode });
|
|
554
|
-
|
|
555
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
556
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
557
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
558
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, { steps: 30 });
|
|
559
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
560
|
-
|
|
561
|
-
// The cursor is now behind the initial arc and so wont close the sensor
|
|
562
|
-
await page.mouse.move(mapDiv.width / 1, mapDiv.height / 3, { steps: 30 });
|
|
563
|
-
await page.mouse.click(mapDiv.width / 1, mapDiv.height / 3);
|
|
564
|
-
|
|
565
|
-
// We expect the count to be 2 because the sensor polygon is not finished
|
|
566
|
-
// and we are left with the center point and the arc line
|
|
567
|
-
await expectPaths({ page, count: 2 });
|
|
568
|
-
|
|
569
|
-
await expectPathDimensions({ page, width: 12, height: 12, item: 0 });
|
|
570
|
-
await expectPathDimensions({ page, width: 31, height: 109, item: 1 });
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
test("mode can set and used to create a sensor less than 90 degrees (clockwise)", async ({
|
|
574
|
-
page,
|
|
575
|
-
}) => {
|
|
576
|
-
const mapDiv = await setupMap({ page });
|
|
577
|
-
await changeMode({ page, mode });
|
|
578
|
-
|
|
579
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
580
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
581
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
582
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, { steps: 30 });
|
|
583
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
584
|
-
|
|
585
|
-
// Finalise the sensor polygon
|
|
586
|
-
await page.mouse.move(mapDiv.width / 5, mapDiv.height / 3, { steps: 30 });
|
|
587
|
-
await page.mouse.click(mapDiv.width / 5, mapDiv.height / 3);
|
|
588
|
-
|
|
589
|
-
await expectPaths({ page, count: 1 });
|
|
590
|
-
|
|
591
|
-
await expectPathDimensions({ page, width: 220, height: 201 });
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
test("mode can set and used to create a sensor more than 90 degrees (clockwise)", async ({
|
|
595
|
-
page,
|
|
596
|
-
}) => {
|
|
597
|
-
const mapDiv = await setupMap({ page });
|
|
598
|
-
await changeMode({ page, mode });
|
|
599
|
-
|
|
600
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
601
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
602
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
603
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 2.5, {
|
|
604
|
-
steps: 30,
|
|
605
|
-
});
|
|
606
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 2.5);
|
|
607
|
-
|
|
608
|
-
// Finalise the sensor polygon
|
|
609
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 5, {
|
|
610
|
-
steps: 30,
|
|
611
|
-
});
|
|
612
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 5);
|
|
613
|
-
|
|
614
|
-
await expectPathDimensions({ page, width: 767, height: 390 });
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
test("mode can set and used to create a sensor more than 180 degrees (clockwise)", async ({
|
|
618
|
-
page,
|
|
619
|
-
}) => {
|
|
620
|
-
const mapDiv = await setupMap({ page });
|
|
621
|
-
await changeMode({ page, mode });
|
|
622
|
-
|
|
623
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
624
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
625
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
626
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
627
|
-
steps: 10,
|
|
628
|
-
});
|
|
629
|
-
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
630
|
-
steps: 10,
|
|
631
|
-
});
|
|
632
|
-
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
633
|
-
|
|
634
|
-
// Finalise the sensor polygon
|
|
635
|
-
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.25);
|
|
636
|
-
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.25);
|
|
637
|
-
|
|
638
|
-
await expectPaths({ page, count: 1 });
|
|
639
|
-
|
|
640
|
-
await expectPathDimensions({ page, width: 506, height: 506 });
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
test("mode can set and used to create a sensor less than 90 degrees (anticlockwise)", async ({
|
|
644
|
-
page,
|
|
645
|
-
}) => {
|
|
646
|
-
const mapDiv = await setupMap({ page });
|
|
647
|
-
await changeMode({ page, mode });
|
|
648
|
-
|
|
649
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
650
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
651
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
652
|
-
await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
|
|
653
|
-
steps: 30,
|
|
654
|
-
});
|
|
655
|
-
await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
|
|
656
|
-
|
|
657
|
-
// Finalise the sensor polygon
|
|
658
|
-
await page.mouse.move(mapDiv.width * 0.3, mapDiv.height / 1.25);
|
|
659
|
-
await page.mouse.click(mapDiv.width * 0.3, mapDiv.height / 1.25);
|
|
660
|
-
|
|
661
|
-
await expectPaths({ page, count: 1 });
|
|
662
|
-
|
|
663
|
-
await expectPathDimensions({ page, width: 183, height: 233 });
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
test("mode can set and used to create a sensor more than 90 degrees (anticlockwise)", async ({
|
|
667
|
-
page,
|
|
668
|
-
}) => {
|
|
669
|
-
const mapDiv = await setupMap({ page });
|
|
670
|
-
await changeMode({ page, mode });
|
|
671
|
-
|
|
672
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
673
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
674
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
675
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
676
|
-
steps: 30,
|
|
677
|
-
});
|
|
678
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 1.5);
|
|
679
|
-
|
|
680
|
-
// Finalise the sensor polygon
|
|
681
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.3);
|
|
682
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 1.3);
|
|
683
|
-
|
|
684
|
-
await expectPathDimensions({ page, width: 728, height: 378 });
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
test("mode can set and used to create a sensor more than 180 degrees (anticlockwise)", async ({
|
|
688
|
-
page,
|
|
689
|
-
}) => {
|
|
690
|
-
const mapDiv = await setupMap({ page });
|
|
691
|
-
await changeMode({ page, mode });
|
|
692
|
-
|
|
693
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
694
|
-
await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
|
|
695
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
|
|
696
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
|
|
697
|
-
steps: 30,
|
|
698
|
-
});
|
|
699
|
-
await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
|
|
700
|
-
steps: 30,
|
|
701
|
-
});
|
|
702
|
-
await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
|
|
703
|
-
|
|
704
|
-
// Finalise the sensor polygon
|
|
705
|
-
await page.mouse.move(mapDiv.width * 0.8, mapDiv.height / 3, { steps: 30 });
|
|
706
|
-
await page.mouse.click(mapDiv.width * 0.8, mapDiv.height / 3);
|
|
707
|
-
|
|
708
|
-
await expectPaths({ page, count: 1 });
|
|
709
|
-
|
|
710
|
-
await expectPathDimensions({ page, width: 808, height: 547 });
|
|
711
|
-
});
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
test.describe("circle mode", () => {
|
|
715
|
-
const mode = "circle";
|
|
716
|
-
|
|
717
|
-
test("mode can set and used to create a web mercator circle", async ({
|
|
718
|
-
page,
|
|
719
|
-
}) => {
|
|
720
|
-
const mapDiv = await setupMap({ page });
|
|
721
|
-
await changeMode({ page, mode });
|
|
722
|
-
|
|
723
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
724
|
-
await page.mouse.click(mapDiv.width / 2 + 50, mapDiv.height / 2 + 50);
|
|
725
|
-
|
|
726
|
-
// One point + one line
|
|
727
|
-
await expectPaths({ page, count: 1 });
|
|
728
|
-
|
|
729
|
-
await expectPathDimensions({ page, width: 146, height: 146 });
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
test("mode can set and used to create a geodesic circle", async ({
|
|
733
|
-
page,
|
|
734
|
-
}) => {
|
|
735
|
-
const mapDiv = await setupMap({ page, configQueryParam: ["globeCircle"] });
|
|
736
|
-
await changeMode({ page, mode });
|
|
737
|
-
|
|
738
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
739
|
-
await page.mouse.click(mapDiv.width / 2 + 50, mapDiv.height / 2 + 50);
|
|
740
|
-
|
|
741
|
-
// One point + one line
|
|
742
|
-
await expectPaths({ page, count: 1 });
|
|
743
|
-
|
|
744
|
-
await expectPathDimensions({ page, width: 146, height: 146 });
|
|
745
|
-
});
|
|
746
|
-
});
|
|
747
|
-
|
|
748
|
-
test.describe("select mode", () => {
|
|
749
|
-
const mode = "select";
|
|
750
|
-
|
|
751
|
-
const options = [
|
|
752
|
-
{ name: "in web mercator projection", config: undefined },
|
|
753
|
-
{
|
|
754
|
-
name: "in globe projection",
|
|
755
|
-
config: ["globeSelect"],
|
|
756
|
-
},
|
|
757
|
-
] as { name: string; config: TestConfigOptions[] }[];
|
|
758
|
-
|
|
759
|
-
for (const { name, config } of options) {
|
|
760
|
-
test(`mode can set and then polygon can be selected and deselected ${name}`, async ({
|
|
761
|
-
page,
|
|
762
|
-
}) => {
|
|
763
|
-
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
764
|
-
|
|
765
|
-
await changeMode({ page, mode: "polygon" });
|
|
766
|
-
const sideLength = 100;
|
|
767
|
-
const halfLength = sideLength / 2;
|
|
768
|
-
const centerX = mapDiv.width / 2;
|
|
769
|
-
const centerY = mapDiv.height / 2;
|
|
770
|
-
const topLeft = { x: centerX - halfLength, y: centerY - halfLength };
|
|
771
|
-
const topRight = { x: centerX + halfLength, y: centerY - halfLength };
|
|
772
|
-
const bottomLeft = { x: centerX - halfLength, y: centerY + halfLength };
|
|
773
|
-
const bottomRight = { x: centerX + halfLength, y: centerY + halfLength };
|
|
774
|
-
await page.mouse.click(topLeft.x, topLeft.y);
|
|
775
|
-
await page.mouse.click(topRight.x, topRight.y);
|
|
776
|
-
await page.mouse.click(bottomRight.x, bottomRight.y);
|
|
777
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y);
|
|
778
|
-
await page.mouse.click(bottomLeft.x, bottomLeft.y); // Closed
|
|
779
|
-
|
|
780
|
-
await changeMode({ page, mode });
|
|
781
|
-
|
|
782
|
-
// Select
|
|
783
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
784
|
-
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square
|
|
785
|
-
|
|
786
|
-
// Deselect
|
|
787
|
-
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2);
|
|
788
|
-
await expectPaths({ page, count: 1 }); // 0 selection points and 1 square
|
|
789
|
-
});
|
|
790
|
-
|
|
791
|
-
test(`selected polygon can be dragged ${name}`, async ({ page }) => {
|
|
792
|
-
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
793
|
-
|
|
794
|
-
await changeMode({ page, mode: "polygon" });
|
|
795
|
-
|
|
796
|
-
// Draw a rectangle
|
|
797
|
-
const { topLeft } = await drawRectangularPolygon({ mapDiv, page });
|
|
798
|
-
|
|
799
|
-
// Change to select mode
|
|
800
|
-
await changeMode({ page, mode });
|
|
801
|
-
|
|
802
|
-
// Before drag
|
|
803
|
-
const x = topLeft.x - 2;
|
|
804
|
-
const y = topLeft.y - 2;
|
|
805
|
-
await expectGroupPosition({ page, x, y });
|
|
806
|
-
|
|
807
|
-
// Select
|
|
808
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
809
|
-
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square
|
|
810
|
-
|
|
811
|
-
// Drag
|
|
812
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2);
|
|
813
|
-
await page.mouse.down();
|
|
814
|
-
await page.mouse.move(mapDiv.width / 2 + 50, mapDiv.height / 2 + 50, {
|
|
815
|
-
steps: 30,
|
|
816
|
-
}); // Steps is required
|
|
817
|
-
await page.mouse.up();
|
|
818
|
-
|
|
819
|
-
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2);
|
|
820
|
-
|
|
821
|
-
await expectGroupPosition({ page, x: x + 48, y: y + 48 });
|
|
822
|
-
});
|
|
823
|
-
|
|
824
|
-
test(`selected polygon can have individual coordinates dragged ${name}`, async ({
|
|
825
|
-
page,
|
|
826
|
-
}) => {
|
|
827
|
-
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
828
|
-
|
|
829
|
-
await changeMode({ page, mode: "polygon" });
|
|
830
|
-
|
|
831
|
-
// Draw a rectangle
|
|
832
|
-
const { topLeft } = await drawRectangularPolygon({ mapDiv, page });
|
|
833
|
-
|
|
834
|
-
// Change to select mode
|
|
835
|
-
await changeMode({ page, mode });
|
|
836
|
-
|
|
837
|
-
// Before drag
|
|
838
|
-
const x = topLeft.x - 2;
|
|
839
|
-
const y = topLeft.y - 2;
|
|
840
|
-
await expectGroupPosition({ page, x, y });
|
|
841
|
-
|
|
842
|
-
// Select
|
|
843
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
844
|
-
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square
|
|
845
|
-
|
|
846
|
-
// Drag
|
|
847
|
-
await page.mouse.move(topLeft.x, topLeft.y);
|
|
848
|
-
await page.mouse.down();
|
|
849
|
-
await page.mouse.move(topLeft.x - 50, topLeft.y + 50, { steps: 30 }); // Steps is required
|
|
850
|
-
await page.mouse.up();
|
|
851
|
-
|
|
852
|
-
// Deselect
|
|
853
|
-
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2);
|
|
854
|
-
|
|
855
|
-
// Dragged the coordinate to the left and down slightly
|
|
856
|
-
await expectGroupPosition({ page, x: 538, y: 308 });
|
|
857
|
-
});
|
|
858
|
-
|
|
859
|
-
test(`selected polygon can have individual coordinates dragged and succeeds when validation succeeds ${name}`, async ({
|
|
860
|
-
page,
|
|
861
|
-
}) => {
|
|
862
|
-
const mapDiv = await setupMap({
|
|
863
|
-
page,
|
|
864
|
-
configQueryParam: config
|
|
865
|
-
? [...config, "validationSuccess"]
|
|
866
|
-
: ["validationSuccess"],
|
|
867
|
-
});
|
|
868
|
-
|
|
869
|
-
await changeMode({ page, mode: "polygon" });
|
|
870
|
-
|
|
871
|
-
// Draw a rectangle
|
|
872
|
-
const { topLeft } = await drawRectangularPolygon({
|
|
873
|
-
mapDiv,
|
|
874
|
-
page,
|
|
875
|
-
size: "small",
|
|
876
|
-
});
|
|
877
|
-
|
|
878
|
-
// Change to select mode
|
|
879
|
-
await changeMode({ page, mode });
|
|
880
|
-
|
|
881
|
-
// Before drag
|
|
882
|
-
const x = topLeft.x - 2;
|
|
883
|
-
const y = topLeft.y - 2;
|
|
884
|
-
await expectGroupPosition({ page, x, y });
|
|
885
|
-
|
|
886
|
-
// Select
|
|
887
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
888
|
-
// await expectPaths({ page, count: 9 }); // 8 selection points and 1 square
|
|
889
|
-
|
|
890
|
-
// Drag
|
|
891
|
-
await page.mouse.move(topLeft.x, topLeft.y);
|
|
892
|
-
await page.mouse.down();
|
|
893
|
-
await page.mouse.move(topLeft.x - 50, topLeft.y - 50, { steps: 30 });
|
|
894
|
-
await page.mouse.up();
|
|
895
|
-
|
|
896
|
-
// Deselect
|
|
897
|
-
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2);
|
|
898
|
-
|
|
899
|
-
// We are attempting to dragg right tothe top left corner but it is not getting there
|
|
900
|
-
// because it is capped by the validation. If this was allowed x would be ~90
|
|
901
|
-
await expectGroupPosition({ page, x: 553, y: 273 });
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
test(`selected polygon can have individual coordinates dragged and fail when validation fails ${name}`, async ({
|
|
905
|
-
page,
|
|
906
|
-
}) => {
|
|
907
|
-
const mapDiv = await setupMap({
|
|
908
|
-
page,
|
|
909
|
-
configQueryParam: config
|
|
910
|
-
? [...config, "validationFailure"]
|
|
911
|
-
: ["validationFailure"],
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
await changeMode({ page, mode: "polygon" });
|
|
915
|
-
|
|
916
|
-
// Draw a rectangle
|
|
917
|
-
const { topLeft } = await drawRectangularPolygon({
|
|
918
|
-
mapDiv,
|
|
919
|
-
page,
|
|
920
|
-
size: "small",
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
// Change to select mode
|
|
924
|
-
await changeMode({ page, mode });
|
|
925
|
-
|
|
926
|
-
// Before drag
|
|
927
|
-
const x = topLeft.x - 2;
|
|
928
|
-
const y = topLeft.y - 2;
|
|
929
|
-
await expectGroupPosition({ page, x, y });
|
|
930
|
-
|
|
931
|
-
// Select
|
|
932
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
933
|
-
// await expectPaths({ page, count: 9 }); // 8 selection points and 1 square
|
|
934
|
-
|
|
935
|
-
// Drag
|
|
936
|
-
await page.mouse.move(topLeft.x, topLeft.y);
|
|
937
|
-
await page.mouse.down();
|
|
938
|
-
await page.mouse.move(0, 0, { steps: 30 });
|
|
939
|
-
await page.mouse.up();
|
|
940
|
-
|
|
941
|
-
// Deselect
|
|
942
|
-
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2);
|
|
943
|
-
|
|
944
|
-
// We are attempting to dragg right tothe top left corner but it is not getting there
|
|
945
|
-
// because it is capped by the validation. If this was allowed x would be ~90
|
|
946
|
-
await expectGroupPosition({ page, x: 563, y: 301 });
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
test("selected rectangle has it's shape maintained when coordinates are dragged with resizable flag", async ({
|
|
951
|
-
page,
|
|
952
|
-
}) => {
|
|
953
|
-
const mapDiv = await setupMap({ page });
|
|
954
|
-
|
|
955
|
-
await changeMode({ page, mode: "rectangle" });
|
|
956
|
-
|
|
957
|
-
// Draw a rectangle
|
|
958
|
-
const { topLeft } = await drawTwoClickShape({ mapDiv, page });
|
|
959
|
-
|
|
960
|
-
// Change to select mode
|
|
961
|
-
await changeMode({ page, mode });
|
|
962
|
-
|
|
963
|
-
// Before drag
|
|
964
|
-
const x = topLeft.x - 2;
|
|
965
|
-
const y = topLeft.y - 2;
|
|
966
|
-
await expectGroupPosition({ page, x, y });
|
|
967
|
-
|
|
968
|
-
// Select
|
|
969
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
970
|
-
await expectPaths({ page, count: 5 }); // 4 selection points and 1 square
|
|
971
|
-
|
|
972
|
-
// Drag
|
|
973
|
-
await page.mouse.move(topLeft.x, topLeft.y);
|
|
974
|
-
await page.mouse.down();
|
|
975
|
-
await page.mouse.move(topLeft.x - 100, topLeft.y + 100, { steps: 50 }); // Steps is required
|
|
976
|
-
await page.mouse.up();
|
|
977
|
-
|
|
978
|
-
// Deselect
|
|
979
|
-
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2);
|
|
980
|
-
|
|
981
|
-
// Dragged the square up and to the left
|
|
982
|
-
await expectGroupPosition({ page, x: 490, y: 408 });
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
test("selected circle has it's shape maintained from center origin when coordinates are dragged with resizable flag", async ({
|
|
986
|
-
page,
|
|
987
|
-
}) => {
|
|
988
|
-
const mapDiv = await setupMap({ page });
|
|
989
|
-
|
|
990
|
-
await changeMode({ page, mode: "circle" });
|
|
991
|
-
|
|
992
|
-
// Draw a circle
|
|
993
|
-
await drawTwoClickShape({ mapDiv, page });
|
|
994
|
-
|
|
995
|
-
// Change to select mode
|
|
996
|
-
await changeMode({ page, mode });
|
|
997
|
-
|
|
998
|
-
// Select
|
|
999
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
1000
|
-
await expectPaths({ page, count: 65 }); // 4 selection points and 1 square
|
|
1001
|
-
|
|
1002
|
-
// Drag
|
|
1003
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2 + 50);
|
|
1004
|
-
await page.mouse.down();
|
|
1005
|
-
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2 + 100, {
|
|
1006
|
-
steps: 50,
|
|
1007
|
-
}); // Steps is required
|
|
1008
|
-
await page.mouse.up();
|
|
1009
|
-
|
|
1010
|
-
// Deselect
|
|
1011
|
-
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2);
|
|
1012
|
-
|
|
1013
|
-
// Dragged the square up and to the left
|
|
1014
|
-
await expectGroupPosition({ page, x: 447, y: 138 });
|
|
1015
|
-
});
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
test.describe("clear", () => {
|
|
1019
|
-
test("drawn geometries can be cleared correctly", async ({ page }) => {
|
|
1020
|
-
const mapDiv = await setupMap({ page });
|
|
1021
|
-
|
|
1022
|
-
await changeMode({ page, mode: "point" });
|
|
1023
|
-
await page.mouse.click(mapDiv.width / 4, mapDiv.height / 4);
|
|
1024
|
-
|
|
1025
|
-
await changeMode({ page, mode: "linestring" });
|
|
1026
|
-
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
1027
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
1028
|
-
await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
|
|
1029
|
-
|
|
1030
|
-
await changeMode({ page, mode: "polygon" });
|
|
1031
|
-
await drawRectangularPolygon({ mapDiv, page });
|
|
1032
|
-
|
|
1033
|
-
await expectPaths({ page, count: 3 });
|
|
1034
|
-
|
|
1035
|
-
const button = page.getByText("clear");
|
|
1036
|
-
await button.click();
|
|
1037
|
-
|
|
1038
|
-
await expectPaths({ page, count: 0 });
|
|
1039
|
-
});
|
|
1040
|
-
});
|