Skip to content

Commit

Permalink
Upgrade Cypress & package.json & apply some fixes from Pro version (#…
Browse files Browse the repository at this point in the history
…1533) (patch)

* Upgrade package.json and Cypress

* Update ISSUE_TEMPLATE to new code editor with newest version

* Apply changes from Pro Codebase
  • Loading branch information
Falke-Design authored Nov 23, 2024
1 parent d83df5e commit 346205f
Show file tree
Hide file tree
Showing 38 changed files with 621 additions and 752 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ npm-debug.log
/cypress/screenshots
/cypress/videos
.eslintcache
.env
*.tgz
2 changes: 1 addition & 1 deletion ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- hey there, thanks for reporting an issue or feature request. If you found unexpected behaviour or problems using leaflet-geoman, please provide a demo via JSfiddle that reproduces the problem. You can use this as a starting point: https://jsfiddle.net/o1dwu2vg/ . This saves me a lot of time to find the issue and I can help you / fix it much faster :-) - THANKS -->
<!-- hey there, thanks for reporting an issue or feature request. If you found unexpected behaviour or problems using leaflet-geoman, please provide a demo that reproduces the problem. You can use this as a starting point: https://plnkr.co/edit/3XhAuzVQ2CMyNFSr . This saves a lot of time to find the issue and to help you / fix it much faster :-) - THANKS -->
16 changes: 16 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { defineConfig } = require('cypress');

module.exports = defineConfig({
video: false,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config);
},
experimentalRunAllSpecs: true,
},
retries: {
runMode: 2,
},
});
3 changes: 0 additions & 3 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ describe('Draw Circle', () => {
// move marker
const marker = circle.pm._markers[1];
marker.setLatLng([marker.getLatLng().lng, marker.getLatLng().lat + 10]);
circle.pm._resizeCircle();

expect(167).to.eq(Math.floor(circle.getRadius()));
});
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions cypress/integration/line.spec.js → cypress/e2e/line.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ describe('Draw & Edit Line', () => {
cy.hasMiddleMarkers(2);
});

it('snapping doesn\'t throw an error when Polyline has only one coordinate' , () => {
it("snapping doesn't throw an error when Polyline has only one coordinate", () => {
cy.window().then(({ map, L }) => {
L.polyline([map.getCenter()]).addTo(map);
});
Expand All @@ -371,7 +371,6 @@ describe('Draw & Edit Line', () => {
.should('have.class', 'active');

// draw a line
cy.get(mapSelector)
.click(150, 250)
cy.get(mapSelector).click(150, 250);
});
});
10 changes: 5 additions & 5 deletions cypress/integration/marker.spec.js → cypress/e2e/marker.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Draw Marker', () => {
});
});

it('calls pm:drag-events on Marker drag', () => {
it('calls pm:drag-events on Marker drag', (done) => {
let handFinish = false;
let dragstart = false;
let drag = false;
Expand Down Expand Up @@ -141,11 +141,11 @@ describe('Draw Marker', () => {
.moveTo(170, 290, 400)
.up()
.wait(100); // Not allowed
});

// wait until hand is finished
cy.waitUntil(() => cy.window().then(() => handFinish)).then(() => {
expect(handFinish).to.equal(true);
setTimeout(() => {
expect(handFinish).to.equal(true);
done();
}, 2000);
});
});

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ describe('Draw & Edit Poly', () => {
cy.toolbarButton('edit').click();
});

it('allowSelfIntersectionEdit on polygon', () => {
it('allowSelfIntersectionEdit on polygon', (done) => {
cy.timeout(10000);
cy.window().then(({ map, L, Hand }) => {
cy.fixture('PolygonIntersects')
.then((json) => {
Expand Down Expand Up @@ -766,12 +767,10 @@ describe('Draw & Edit Poly', () => {
.up()
.wait(500); // allowed

// wait until hand is finished
cy.waitUntil(() => cy.window().then(() => handFinish), {
timeout: 9000,
}).then(() => {
setTimeout(() => {
expect(handFinish).to.equal(true);
});
done();
}, 7000);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ describe('Draw Rectangle', () => {

cy.toolbarButton('cut').click();
cy.get(mapSelector)
.click(226, 419)
.click(226, 349)
.click(230, 105)
.click(270, 419)
.click(226, 419);
.click(270, 349)
.click(226, 349);

cy.toolbarButton('cut').click();
cy.get(mapSelector)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import 'cypress-wait-until';
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
Expand Down
8 changes: 7 additions & 1 deletion cypress/support/index.js → cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ beforeEach(() => {
new CustomEvent('prostheticHandStop', { target: this })
);
if (this._onStop && typeof this._onStop === 'function') {
this._onStop(this);
try {
this._onStop(this);
} catch (e) {
/* eslint-disable-next-line no-console */
console.error(e);
throw e;
}
}
}
this._fingersAreIdle = true;
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<script src="https://unpkg.com/[email protected]"></script>
-->

<script src="cypress/libs/proj4-2.8.0.min.js"></script>
<script src="cypress/libs/proj4leaflet-1.0.2.min.js"></script>

<style>
html,
body {
Expand Down
1 change: 1 addition & 0 deletions leaflet-geoman.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ declare module 'leaflet' {
onClick?: (e: any) => void;
title?: string;
name?: string;
isActive?: () => boolean;
}

type TOOLBAR_CONTROL_ORDER =
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@
"polyclip-ts": "^0.16.5"
},
"devDependencies": {
"@types/leaflet": "^1.7.9",
"@types/leaflet": "^1.9.12",
"cross-env": "^7.0.3",
"cypress": "6.9.1",
"cypress-wait-until": "1.7.1",
"esbuild": "^0.20.0",
"cypress": "^13.11.0",
"esbuild": "^0.20.2",
"eslint": "8.56.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "2.15.1",
"eslint-plugin-import": "2.29.1",
"husky": "^9.0.7",
"husky": "^9.0.11",
"leaflet": "1.9.3",
"lint-staged": "^15.2.1",
"lint-staged": "^15.2.5",
"prettier": "3.2.4",
"prosthetic-hand": "1.3.1",
"ts-node": "^10.9.2"
Expand All @@ -53,12 +52,12 @@
"start": "pnpm run dev",
"dev": "cross-env DEV=true ts-node bundle.mjs",
"build": "ts-node bundle.mjs",
"test": "cypress run",
"test": "cypress run --browser chrome",
"cypress": "cypress open",
"prepare": "pnpm run build && husky",
"eslint-check": "eslint --print-config . | eslint-config-prettier-check",
"eslint": "eslint \"{src,cypress,demo}/**/*.js\" --fix ",
"prettier": "prettier --write \"{src,cypress,demo}/**/*.{js,css}\" --log-level=warn",
"eslint": "eslint \"{src,demo}/**/*.js\" --fix ",
"prettier": "prettier --write \"{src,demo}/**/*.{js,css}\" --log-level=warn",
"lint": "pnpm run eslint && pnpm run prettier"
},
"repository": {
Expand All @@ -82,7 +81,7 @@
"singleQuote": true
},
"lint-staged": {
"*.js": "eslint \"{src,cypress,demo}/**/*.js\" --fix",
"*.{js,css,md}": "prettier --write \"{src,cypress,demo}/**/*.{js,css}\""
"*.js": "eslint \"{src,demo}/**/*.js\" --fix",
"*.{js,css,md}": "prettier --write \"{src,demo}/**/*.{js,css}\""
}
}
Loading

0 comments on commit 346205f

Please sign in to comment.