Skip to content

Add tests for the Draggable component when rendered into an iframe #182

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

Merged
merged 1 commit into from
Jul 27, 2016

Conversation

acusti
Copy link
Contributor

@acusti acusti commented Jul 23, 2016

Add tests for #180 (all passing ✅ )

Note that I was unable to get these tests working using TestUtils’ renderIntoDocument function (or the various find* helpers) and had to use actual ReactDOM.render along with querySelector on the returned DOM node to make assertions on the rendered results. Has something to do with the tricky parts of react-frame-component (rendering an iframe with React), and looking at the react-frame-component tests, they take the same approach.

As a result of needing to use ReactDOM.render, I had to add a setTimeout before selecting the rendered nodes from the DOM to avoid the tests breaking in Firefox. Here’s the error I saw when I tried to select the nodes synchronously:

[1A[2K[1A[2K[1A[2KFirefox 42.0.0 (Mac OS X 10.11.0) react-draggable props should be draggable when in an iframe FAILED
    TypeError: domComponentOrNode is null in specs/main.js (line 22648)
    makeSimulator/<@specs/main.js:22648:1
    simulateMovementFromTo@specs/main.js:1376:1
    @specs/main.js:801:8

I had another weird seemingly unrelated test failure on Firefox that I worked around by rounding the mouse event’s deltaY in the onDrag function’s assertions. Here’s that error:

Firefox 42.0.0 (Mac OS X 10.11.0): Executed 11 of 37 (2 FAILED) (0 secs / 0.096 secs)
[1A[2K[1A[2K[1A[2KFirefox 42.0.0 (Mac OS X 10.11.0) ERROR
  AssertionError:   # specs/draggable.spec.jsx:527

    assert(coreEvent.deltaY === 500)
           |         |      |       
           |         |      false   
           |         500.00001525878906
           Object{node:#HTMLDivElement#,x:0,y:500.00001525878906,deltaX:0,deltaY:500.00001525878906,lastX:0,lastY:0}

    [number] 500
    => 500
    [number] coreEvent.deltaY
    => 500.00001525878906

I was unable to get these tests working using TestUtils’
renderIntoDocument function (or the various find* helpers) for these
tests and had to use actual ReactDOM.render instead along with regular
querySelector. Has something to do with the tricky parts of
react-frame-component (rendering an iframe with React).
@acusti
Copy link
Contributor Author

acusti commented Jul 27, 2016

Just noticed that these new tests brings the number of tests running in CI up to 111, which strikes me as highly auspicious. 😉

@STRML
Copy link
Collaborator

STRML commented Jul 27, 2016

:shipit: 111 sounds lucky enough to me

@STRML
Copy link
Collaborator

STRML commented Jul 27, 2016

Thanks for the contribution!

@STRML STRML merged commit a7a35b2 into react-grid-layout:master Jul 27, 2016
@acusti
Copy link
Contributor Author

acusti commented Jul 27, 2016

My pleasure! And thanks to you.

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