Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent the creation of an additional Marker when dragging a Marker i… #1569

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

tfitzsim
Copy link

Prevent the creation of an additional Marker when dragging a Marker in "Create Marker" mode (#1568)

  • Replicate CircleMarker _layerIsDragging functionality in Marker

…n "Create Marker" mode (geoman-io#1568)

  - Replicate CircleMarker _layerIsDragging functionality in Marker
Copy link
Collaborator

@Falke-Design Falke-Design left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks already good, thank you. Can you please add a test as well?

@tfitzsim
Copy link
Author

Looks already good, thank you. Can you please add a test as well?

I appear to be out of my depth, so I'll need some help with the test. I tried to get it working for quite a while, but couldn't.

  1. I can create a Marker with click(), but not with trigger(mousedown/mouseup).
  2. I could drag the Marker with both trigger(mousedown/mousemove/mouseup) and "touchMarker" logic used in other tests
  3. However, after the Marker was dragged and the mouse moved away, there was still only 1 Marker
  4. The issue was easy to trigger manually after the test completed.

I doubt this will be overly useful, but he is the basis of the code I was trying:

  it('drag in draw mode does not create additional marker', (done) => {
    cy.toolbarButton('marker').click();
    cy.get(mapSelector).click(150, 250);
    cy.wait(1000);

    cy.window().then(({ map }) => {
      expect(map.pm.getGeomanDrawLayers().length).to.eq(1);
    });

    cy.get(mapSelector).trigger("mousemove", 150, 230);
    cy.wait(1000);
    cy.get(mapSelector).trigger("mouseover", 150, 230, { which: 1 });
    cy.wait(1000);
    cy.get(mapSelector).trigger("mousedown", 150, 230, { which: 1 });
    cy.wait(1000);
    cy.get(mapSelector).trigger("mousemove", 170, 290, { which: 1 });
    cy.wait(1000);
    cy.get(mapSelector).trigger("mouseup", 170, 290, { which: 1, force: true });
    cy.wait(1000);
    cy.get(mapSelector).trigger("mousemove", 190, 340, { which: 1 });
    cy.wait(1000);

    cy.window().then(({ map }) => {
      expect(map.pm.getGeomanDrawLayers().length).to.eq(1);
      done();
    });
  });

@tfitzsim
Copy link
Author

PR is updated with a test. I believe simulating a click before the mouseup is the correct thing to do. The test fails without the fix, and succeeds with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants