terra-draw 1.0.0-beta.1 → 1.0.0-beta.4
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/README.md +9 -2
- package/dist/adapters/mapbox-gl.adapter.d.ts +0 -1
- package/dist/adapters/openlayers.adapter.d.ts +6 -13
- package/dist/common.d.ts +0 -3
- package/dist/geometry/clockwise.d.ts +10 -0
- package/dist/geometry/measure/bearing.d.ts +1 -0
- package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +0 -4
- package/dist/modes/sector/sector.mode.d.ts +60 -0
- package/dist/modes/sensor/sensor.mode.d.ts +69 -0
- package/dist/store/store.d.ts +2 -2
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +3 -1
- 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.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/e2e/public/index.html +2 -0
- package/e2e/tests/leaflet.spec.ts +319 -18
- package/e2e/tests/setup.ts +14 -4
- package/package.json +18 -3
- package/tsconfig.json +2 -1
- package/readme.gif +0 -0
package/e2e/public/index.html
CHANGED
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
<button id="polygon">Polygon</button>
|
|
43
43
|
<button id="rectangle">Rectangle</button>
|
|
44
44
|
<button id="angled-rectangle">Angled Rectangle</button>
|
|
45
|
+
<button id="sector">Sector</button>
|
|
46
|
+
<button id="sensor">Sensor</button>
|
|
45
47
|
<button id="circle">Circle</button>
|
|
46
48
|
<button id="clear">Clear</button>
|
|
47
49
|
</div>
|
|
@@ -53,7 +53,7 @@ test.describe("page setup", () => {
|
|
|
53
53
|
test.describe("point mode", () => {
|
|
54
54
|
const mode = "point";
|
|
55
55
|
|
|
56
|
-
test("mode can set and
|
|
56
|
+
test("mode can set and used to create a point", async ({ page }) => {
|
|
57
57
|
const mapDiv = await setupMap({ page });
|
|
58
58
|
await changeMode({ page, mode });
|
|
59
59
|
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
|
|
@@ -61,9 +61,7 @@ test.describe("point mode", () => {
|
|
|
61
61
|
await expectPaths({ page, count: 1 });
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
test("mode can set and
|
|
65
|
-
page,
|
|
66
|
-
}) => {
|
|
64
|
+
test("mode can set and used to create multiple points", async ({ page }) => {
|
|
67
65
|
const mapDiv = await setupMap({ page });
|
|
68
66
|
await changeMode({ page, mode });
|
|
69
67
|
|
|
@@ -91,7 +89,7 @@ test.describe("linestring mode", () => {
|
|
|
91
89
|
] as { name: string; config: TestConfigOptions[] }[];
|
|
92
90
|
|
|
93
91
|
for (const { name, config } of options) {
|
|
94
|
-
test(`mode can set and
|
|
92
|
+
test(`mode can set and used to create a linestring${name}`, async ({
|
|
95
93
|
page,
|
|
96
94
|
}) => {
|
|
97
95
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -108,7 +106,7 @@ test.describe("linestring mode", () => {
|
|
|
108
106
|
await expectPaths({ page, count: 1 });
|
|
109
107
|
});
|
|
110
108
|
|
|
111
|
-
test(`mode can set and
|
|
109
|
+
test(`mode can set and used to create a linestring with multiple points${name}`, async ({
|
|
112
110
|
page,
|
|
113
111
|
}) => {
|
|
114
112
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -133,7 +131,7 @@ test.describe("linestring mode", () => {
|
|
|
133
131
|
await expectPaths({ page, count: 1 });
|
|
134
132
|
});
|
|
135
133
|
|
|
136
|
-
test(`mode can set and
|
|
134
|
+
test(`mode can set and used to create a linestring with multiple clicked points${name}`, async ({
|
|
137
135
|
page,
|
|
138
136
|
}) => {
|
|
139
137
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -158,7 +156,7 @@ test.describe("linestring mode", () => {
|
|
|
158
156
|
await expectPaths({ page, count: 1 });
|
|
159
157
|
});
|
|
160
158
|
|
|
161
|
-
test(`mode can set and
|
|
159
|
+
test(`mode can set and used to create multiple linestrings${name}`, async ({
|
|
162
160
|
page,
|
|
163
161
|
}) => {
|
|
164
162
|
const mapDiv = await setupMap({ page, configQueryParam: config });
|
|
@@ -197,7 +195,7 @@ test.describe("linestring mode", () => {
|
|
|
197
195
|
test.describe("polygon mode", () => {
|
|
198
196
|
const mode = "polygon";
|
|
199
197
|
|
|
200
|
-
test("mode can set and
|
|
198
|
+
test("mode can set and used to create a polygon", async ({ page }) => {
|
|
201
199
|
const mapDiv = await setupMap({ page });
|
|
202
200
|
await changeMode({ page, mode });
|
|
203
201
|
|
|
@@ -312,9 +310,7 @@ test.describe("polygon mode", () => {
|
|
|
312
310
|
test.describe("rectangle mode", () => {
|
|
313
311
|
const mode = "rectangle";
|
|
314
312
|
|
|
315
|
-
test("mode can set and
|
|
316
|
-
page,
|
|
317
|
-
}) => {
|
|
313
|
+
test("mode can set and used to create a rectangle", async ({ page }) => {
|
|
318
314
|
const mapDiv = await setupMap({ page });
|
|
319
315
|
await changeMode({ page, mode });
|
|
320
316
|
|
|
@@ -331,7 +327,7 @@ test.describe("rectangle mode", () => {
|
|
|
331
327
|
test.describe("angled rectangle mode", () => {
|
|
332
328
|
const mode = "angled-rectangle";
|
|
333
329
|
|
|
334
|
-
test("mode can set and
|
|
330
|
+
test("mode can set and used to create an angled rectangle (horizontal up)", async ({
|
|
335
331
|
page,
|
|
336
332
|
}) => {
|
|
337
333
|
const mapDiv = await setupMap({ page });
|
|
@@ -350,7 +346,7 @@ test.describe("angled rectangle mode", () => {
|
|
|
350
346
|
await expectPathDimensions({ page, width: 217, height: 74 });
|
|
351
347
|
});
|
|
352
348
|
|
|
353
|
-
test("mode can set and
|
|
349
|
+
test("mode can set and used to create an angled rectangle (horizontal down)", async ({
|
|
354
350
|
page,
|
|
355
351
|
}) => {
|
|
356
352
|
const mapDiv = await setupMap({ page });
|
|
@@ -369,7 +365,7 @@ test.describe("angled rectangle mode", () => {
|
|
|
369
365
|
await expectPathDimensions({ page, width: 217, height: 84 });
|
|
370
366
|
});
|
|
371
367
|
|
|
372
|
-
test("mode can set and
|
|
368
|
+
test("mode can set and used to create an angled (diagonal)", async ({
|
|
373
369
|
page,
|
|
374
370
|
}) => {
|
|
375
371
|
const mapDiv = await setupMap({ page });
|
|
@@ -388,7 +384,7 @@ test.describe("angled rectangle mode", () => {
|
|
|
388
384
|
await expectPathDimensions({ page, width: 245, height: 174 });
|
|
389
385
|
});
|
|
390
386
|
|
|
391
|
-
test("mode can set and
|
|
387
|
+
test("mode can set and used to create an angled (diagonal 2)", async ({
|
|
392
388
|
page,
|
|
393
389
|
}) => {
|
|
394
390
|
const mapDiv = await setupMap({ page });
|
|
@@ -410,10 +406,315 @@ test.describe("angled rectangle mode", () => {
|
|
|
410
406
|
});
|
|
411
407
|
});
|
|
412
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
|
+
|
|
413
714
|
test.describe("circle mode", () => {
|
|
414
715
|
const mode = "circle";
|
|
415
716
|
|
|
416
|
-
test("mode can set and
|
|
717
|
+
test("mode can set and used to create a web mercator circle", async ({
|
|
417
718
|
page,
|
|
418
719
|
}) => {
|
|
419
720
|
const mapDiv = await setupMap({ page });
|
|
@@ -428,7 +729,7 @@ test.describe("circle mode", () => {
|
|
|
428
729
|
await expectPathDimensions({ page, width: 146, height: 146 });
|
|
429
730
|
});
|
|
430
731
|
|
|
431
|
-
test("mode can set and
|
|
732
|
+
test("mode can set and used to create a geodesic circle", async ({
|
|
432
733
|
page,
|
|
433
734
|
}) => {
|
|
434
735
|
const mapDiv = await setupMap({ page, configQueryParam: ["globeCircle"] });
|
package/e2e/tests/setup.ts
CHANGED
|
@@ -60,7 +60,9 @@ export const changeMode = async ({
|
|
|
60
60
|
| "select"
|
|
61
61
|
| "rectangle"
|
|
62
62
|
| "circle"
|
|
63
|
-
| "angled-rectangle"
|
|
63
|
+
| "angled-rectangle"
|
|
64
|
+
| "sector"
|
|
65
|
+
| "sensor";
|
|
64
66
|
}) => {
|
|
65
67
|
let modeText = mode.charAt(0).toUpperCase() + mode.slice(1);
|
|
66
68
|
|
|
@@ -83,7 +85,10 @@ export const changeMode = async ({
|
|
|
83
85
|
const color = await button.evaluate((el) =>
|
|
84
86
|
window.getComputedStyle(el).getPropertyValue("color"),
|
|
85
87
|
);
|
|
86
|
-
expect(
|
|
88
|
+
expect(
|
|
89
|
+
color,
|
|
90
|
+
"Text rgb color should match the expected selected button color",
|
|
91
|
+
).toBe("rgb(39, 204, 255)"); // We set hex but it gets computed to rgb
|
|
87
92
|
};
|
|
88
93
|
|
|
89
94
|
export const expectPaths = async ({
|
|
@@ -99,7 +104,10 @@ export const expectPaths = async ({
|
|
|
99
104
|
await page.waitForSelector(selector);
|
|
100
105
|
expect(await page.locator(selector).count()).toBe(count);
|
|
101
106
|
} else {
|
|
102
|
-
await expect(
|
|
107
|
+
await expect(
|
|
108
|
+
await page.locator(selector).count(),
|
|
109
|
+
`locator count should be greater than 0 for selector ${selector}`,
|
|
110
|
+
).toBe(0);
|
|
103
111
|
}
|
|
104
112
|
};
|
|
105
113
|
|
|
@@ -107,14 +115,16 @@ export const expectPathDimensions = async ({
|
|
|
107
115
|
page,
|
|
108
116
|
width,
|
|
109
117
|
height,
|
|
118
|
+
item = 0,
|
|
110
119
|
}: {
|
|
111
120
|
page: Page;
|
|
112
121
|
width: number;
|
|
113
122
|
height: number;
|
|
123
|
+
item?: number;
|
|
114
124
|
}) => {
|
|
115
125
|
const selector = "svg > g > path";
|
|
116
126
|
|
|
117
|
-
const boundingBox = await page.locator(selector).boundingBox();
|
|
127
|
+
const boundingBox = await page.locator(selector).nth(item).boundingBox();
|
|
118
128
|
|
|
119
129
|
expect(boundingBox?.width).toBe(width);
|
|
120
130
|
expect(boundingBox?.height).toBe(height);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terra-draw",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"description": "Frictionless map drawing across mapping provider",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"docs": "typedoc",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"release:beta:next": "tsx ./scripts/next-beta-version.ts",
|
|
11
11
|
"build": "microbundle",
|
|
12
12
|
"watch": "microbundle --watch --format modern",
|
|
13
|
+
"unused": "knip",
|
|
13
14
|
"test": "jest --config jest.config.ts",
|
|
14
15
|
"test:coverage": "jest --config jest.config.ts --coverage",
|
|
15
16
|
"test:nocheck": "jest --config jest.nocheck.config.ts",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"husky": "7.0.0",
|
|
71
72
|
"jest": "29.7.0",
|
|
72
73
|
"jest-environment-jsdom": "29.7.0",
|
|
74
|
+
"knip": "^5.30.2",
|
|
73
75
|
"leaflet": "^1.9.4",
|
|
74
76
|
"mapbox-gl": "2.13.0",
|
|
75
77
|
"maplibre-gl": "3.2.0",
|
|
@@ -80,7 +82,7 @@
|
|
|
80
82
|
"ts-jest": "29.1.2",
|
|
81
83
|
"ts-loader": "9.5.1",
|
|
82
84
|
"tsx": "4.7.2",
|
|
83
|
-
"typedoc": "^0.26.
|
|
85
|
+
"typedoc": "^0.26.6",
|
|
84
86
|
"typescript": "5.5.2"
|
|
85
87
|
},
|
|
86
88
|
"commitlint": {
|
|
@@ -155,5 +157,18 @@
|
|
|
155
157
|
}
|
|
156
158
|
]
|
|
157
159
|
},
|
|
158
|
-
"sideEffects": false
|
|
160
|
+
"sideEffects": false,
|
|
161
|
+
"knip": {
|
|
162
|
+
"$schema": "https://unpkg.com/knip@5/schema.json",
|
|
163
|
+
"entry": [
|
|
164
|
+
"src/terra-draw.ts"
|
|
165
|
+
],
|
|
166
|
+
"project": [
|
|
167
|
+
"src/**/*.ts"
|
|
168
|
+
],
|
|
169
|
+
"include": [
|
|
170
|
+
"files",
|
|
171
|
+
"types"
|
|
172
|
+
]
|
|
173
|
+
}
|
|
159
174
|
}
|
package/tsconfig.json
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"entryPoints": ["src/terra-draw.ts"],
|
|
15
15
|
"exclude": ["src/geometry/**/*.ts", "src/test/**/*.ts", "src/util/**/*.ts"],
|
|
16
16
|
"out": "docs",
|
|
17
|
-
"skipErrorChecking": true
|
|
17
|
+
"skipErrorChecking": true,
|
|
18
|
+
"sourceLinkExternal": true
|
|
18
19
|
},
|
|
19
20
|
"exclude": [
|
|
20
21
|
"node_modules/",
|
package/readme.gif
DELETED
|
Binary file
|