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

turbolinks accepts a document, run tests inside an iframe #163

Merged
merged 1 commit into from
Oct 4, 2016

Conversation

marutypes
Copy link
Contributor

@marutypes marutypes commented Sep 29, 2016

We now have a browser runner again!

image
(closes #138)

This PR makes two primary changes.

  • Turbolinks.document allows you to set a document for turbolinks to operate on.
  • Tests are now run leveraging this, allowing for use of the browser test runner by sandboxing TG's DOM mutations to an iframe.

How

We had to move the way we defined ASSET_FIXTURES due to some weirdness in teaspoon config, and change all uses of document to reference a variable in module scope to facilitate this change. We also had to make some minor changes in how we initialize tests.

Why

Development velocity is better when we can actually use the browser test runner. Everything else is gravy.

Follow up:

We should change remote_test to do this as well, since it's currently suffering from the same problem turbolinks_test had.

Reviewers

@qq99
@GoodForOneFare
@edward
CC @Shopify/tnt

@qq99
Copy link
Contributor

qq99 commented Sep 29, 2016

Nice :D

afterEach ->
Turbolinks.document(testDocument)

it 'assigning a document', ->
Copy link
Member

Choose a reason for hiding this comment

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

Rename to state some kind of behaviour, or cause and effect. Or just delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll delete it :P

@GoodForOneFare
Copy link
Member

I can run browser tests! 😃 Excellent stuff 👍

@marutypes marutypes force-pushed the enhancement/turbolinks#document branch from 1f59b1c to 34a7bb6 Compare October 3, 2016 18:44
…an iframe

group iframe setup into function

remove silly test, fix results
@marutypes marutypes force-pushed the enhancement/turbolinks#document branch from 34a7bb6 to 9eee511 Compare October 3, 2016 18:47
@marutypes
Copy link
Contributor Author

@qq99 You think this is good to 🚢 ?

@@ -42,7 +43,7 @@ requestMethodIsSafe =
browserSupportsTurbolinks = browserSupportsPushState and requestMethodIsSafe

browserSupportsCustomEvents =
document.addEventListener and document.createEvent
activeDocument.addEventListener and activeDocument.createEvent
Copy link
Contributor

Choose a reason for hiding this comment

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

this could probably just be document right?

Copy link
Contributor Author

@marutypes marutypes Oct 4, 2016

Choose a reason for hiding this comment

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

well you actually want to know it about the document you're operating on, but it usually shouldn't matter

Copy link
Contributor

@qq99 qq99 left a comment

Choose a reason for hiding this comment

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

Changes LGTM. Looks very no-op-y for consumers

I did not review the tests however but if they run in the browser now, that's fantastic!

@marutypes marutypes merged commit 3306e89 into master Oct 4, 2016
@marutypes marutypes deleted the enhancement/turbolinks#document branch October 4, 2016 15:39
GoodForOneFare added a commit that referenced this pull request Oct 4, 2016
Changes
=======
* #122 - Specify minimum Ruby version
* #145 - Defend against nulls in full page navigate
* #144 - Refactor process doc; add new error
* #163 - Turbolinks accepts a document and runs tests inside an iframe
@casperisfine casperisfine temporarily deployed to rubygems September 1, 2020 12:29 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turbolinks should accept a document parameter
4 participants