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

Calculation of coordinates are wrong when Cypress scales the application view port #317

Closed
Im-a-Train opened this issue Nov 3, 2022 · 3 comments

Comments

@Im-a-Train
Copy link
Contributor

Im-a-Train commented Nov 3, 2022

Problem
Depending on the Cypress view port scaling, the coordinates are calculated different and with the wrong proportions.

Code to reproduce:

describe('Real Event Demo', () => {
    beforeEach(() => {
        cy.visit('https://www.pdftron.com/webviewer/demo/')
    });

    it('Insert Rectangle', () => {
        cy.get('iframe[id="webviewer-1"]')
            .its('0.contentDocument.body')
            .then(body => cy.wrap(body))
            .within(() => {
                cy.get('div[data-element="shapeToolGroupButton"]').click()
                const startPos = {x: 100, y: 100}
                const endPos = {x: 200, y: 200}

                cy.get('div[id=pageContainer1]')
                    .realMouseDown({button: 'left', position: startPos})
                    .realMouseMove(endPos.x, endPos.y)
                    .realMouseUp({button: 'left', position: endPos});
            })
    });
});

Current Behavior:
The same test code produces different output, depending on the view port scaling:
View Port 100%:
image
View Port 56%:
image

realEventsWrongCoordinates.mp4

Expected Behavior
The view port scaling should not affect the test output.
Versions

  • Cypress: 9.7.0
  • cypress-real-events: 1.7.2
Im-a-Train added a commit to Im-a-Train/cypress-real-events that referenced this issue Nov 8, 2022
@Im-a-Train
Copy link
Contributor Author

I could also reproduce the problem with the click test from this repo:
Viewport Scaling to 50%:
image
Viewport Scaling to 100%:
image

I'm working on a Pull Request to fix this problem.

@wtachau
Copy link

wtachau commented Nov 9, 2022

Thank you for digging into this— we are also having this issue!

dmtrKovalenko pushed a commit that referenced this issue Nov 10, 2022
… scaled (#323)

* fix: use the cypress viewport scale to prevent a position shift if the viewport is scaled
#317

* no scaling on the click radius

* fixed right click test

* added tests for viewport scaling with a custom drawCanvas

* fix small code smells in the drawCanvas test page

* merged dependency updates in develop from main repo

* fixed error with internal registries in yarn.lock

* fix out folder for compareImage diffs to screenshots

* fix max allowed pixel difference
@wtachau
Copy link

wtachau commented Nov 11, 2022

Thanks all! New release is working like a charm :)

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

No branches or pull requests

3 participants