Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Events dependency #7274

Closed

Conversation

jugglinmike
Copy link
Contributor

Both the Slider and Rangeslider widgets depend on the events module to function correctly. The integration tests currently pass because they explicitly load the init module, which has a dependency on the events module.

This implicit dependency causes the following problems:

  • The modules in question cannot be cleanly loaded from AMD projects
  • It is possble to create broken custom builds of jQuery Mobile (for instance, by selecting only the "Slider" widget)

@jugglinmike
Copy link
Contributor Author

I would like to back this with tests, but I could use a little guidance there. (I naively attempted to remove the init requirement from the appropriate integration test folder, but doing so caused the tests to hang in the browser.)

@@ -9,6 +9,7 @@ define( [ "jquery",
"../../core",
"../../widget",
"./textinput",
"../../events",
Copy link
Contributor

Choose a reason for hiding this comment

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

@jugglinmike thanks for catching this however I think this should depend on just "../../events/touch" i dont see any references to orientationchange, throttledresize, or navigate events in either widget.

@gseguin gseguin added this to the 1.4.3 milestone Mar 24, 2014
@arschmitz
Copy link
Contributor

@jugglinmike yes that is needed to initialize the library and make autoinit work however i think what we want to test here is that it works without autoinit and the rest of the library for this we have https://github.com/jquery/jquery-mobile/tree/master/tests/unit/individual-modules these are to make sure a build with just that widget works. I think this is what we need for slider and rangeslider.

@gabrielschulhof
Copy link

@jugglinmike Nice catch!

@jugglinmike
Copy link
Contributor Author

Thanks!

@arschmitz: In order to test this, I plan to simulate two mouse clicks on the slider/rangeslider. This doesn't seem like a unit test exactly, so I wanted to check with you to see if that's the same approach you had in mind. If so, does jQuery Mobile's test infrastructure have any tooling for pointer event simulation that I can re-use?

@jugglinmike
Copy link
Contributor Author

(also: I've updated the dependency lists to specifically reference the events/touch module as recommended by @arschmitz)

@arschmitz
Copy link
Contributor

@jugglinmike any interest in still working on tests for this? If so i'm happy to help in any way you need.

@jugglinmike
Copy link
Contributor Author

@arschmitz Certainly! Could you tell me if I was on the right track with this comment?

@arschmitz
Copy link
Contributor

@jugglinmike sorry i thought i had responded to that but clearly I didn't. I think we need two types of tests here. one similar to these tests https://github.com/jquery/jquery-mobile/tree/master/tests/unit/individual-modules to make sure the widget properly initializes on its own this covers the second problem of broken builds. Then a second test like what you mention in your comment. For something like this we generally just trigger a click with proper event data you can see similar tests using simulated mouse events here https://github.com/jquery/jquery-mobile/blob/32902786925aa7b5ddc8d2b989bfc65a5fe80def/tests/unit/slider/slider_events.js#L248

@jugglinmike if you have any other questions please just let me know.

@jugglinmike
Copy link
Contributor Author

Got the first tests in. Now working on the click tests...

@jugglinmike
Copy link
Contributor Author

@arschmitz I've run up against a problem: I can't reproduce this in the test environment as it stands today. The environment explicitly depends on the init module, which depends on the navigation module, which depends on the events module, which depends on the events/touch module.

This means that the change I'm proposing will be undetectable from that
environment. I've written a passing test, but it passes even without my change.
As it stands, regressions wouldn't be detected.

Some of the existing tests depend on the init module. I think those tests
should be moved to a separate document, maybe named slider_auto_init.html.

I want to hear your thoughts on that approach before I try that, though.
Whatever we decide on, we'll most likely have to do something similar for the
RangeSlider. What do you think?

@arschmitz
Copy link
Contributor

@jugglinmike all of our normal tests explicitly depend on the init module I think we want to keep that as is at least for now. For tests which we explicitly don't want the init module, like for these tests I think we should add those to the individual module tests so in this case the additional tests would go in the slider_core and rangeslider_core files you added already. We probably want to reconsider the organization of these tests as we add more ( not just being all in a single folder as they are now but thats more or less unrelated )

@jugglinmike
Copy link
Contributor Author

Alrighty @arschmitz I've added the tests to the respective _core.js files as you've suggested. I've also shuffled the commits according to what I think makes sense for master: one set for the introduction of the _core.js files (which on their own are not related to this pull request), and a separate set for the patch to the source and related "unit" test.

It's a lot of test code, so I'm sure there's plenty I got wrong in terms of structure for this project. Just let me know what needs changing!

@jugglinmike
Copy link
Contributor Author

TravisCI is reporting a test error for the "TYPES=unit JQUERIES=git" build:

FAIL 5 tests executed in 3.657s, 4 passed, 1 failed, 0 dubious, 0 skipped.      
Details for the 1 failed test:
In tests/casperjs/demos.test.js:14
  Root index should redirect to demos/
    assertHttpStatus: HTTP status code is: 200
>> 
error: trueCasper Task 'casper:demos.src' took ~4125ms to run
Warning: Task "casper:demos.src" failed.� Use --force to continue.
Aborted due to warnings.

This looks unrelated. Can you verify, @arschmitz?

@arschmitz
Copy link
Contributor

This is indeed unrelated ill look at the tests shortly one thing i realized though is rather then depend on all of events we should be good with just vmouse since we are not using tap taphold swipe or scroll start which are the other touch events

@jugglinmike
Copy link
Contributor Author

@arschmitz Updated to depend on the vmouse module as you requested. Seeing a different set of CasperJS failures on the "JQUERIES=git" build. Let me know what's next :)

@arschmitz
Copy link
Contributor

@jugglinmike awesome im going to pull this local and review it in detail ill let you know if i see anything.

var rangeslider = $( "#plain" ).rangeslider();
var handles = rangeslider.parent().find( ".ui-slider-handle" );
var track = handles.closest( ".ui-slider-track" );
var offset = handles.offset();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a single car statements and comma separate each variable on a separate line.

handle.trigger(down);
handle.trigger(move);
handle.trigger(up);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also: this semicolon is unnecessary. I'll remove it.

@jugglinmike
Copy link
Contributor Author

Thanks for the feedback, @arschmitz! I think I've addressed it all. I haven't squashed the changes in case that helps you review, but I'm happy to do so at your request.

track = handles.closest( ".ui-slider-track" ),
offset = handles.offset();

deepEqual( rangeslider.rangeslider( "widget" ).hasClass( "ui-rangeslider" ), true, "Has class ui-rangeslider" );
Copy link
Contributor

Choose a reason for hiding this comment

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

max line length 100chars

@arschmitz
Copy link
Contributor

@jugglinmike sorry I missed those line lengths last night but iv tested local and double checked and everything looks good after these. So if you want to squash at the same ill push this to master when your done. Thanks for all the work on this!

@jugglinmike
Copy link
Contributor Author

No worries, @arschmitz. I've wrapped the three lines you identified using the button_core.js tests as a guide.

@arschmitz
Copy link
Contributor

@jugglinmike looks great if you want to squash all the commits ill push it to master

jugglinmike added a commit to jugglinmike/jquery-mobile that referenced this pull request May 15, 2014
Both modules have a hard dependency on the "vmouse" module that should
be expressed in AMD.

Closes jquery-archivegh-7274
@jugglinmike
Copy link
Contributor Author

Alright @arschmitz . Although I think this should be (at least) two separate commits, I found one example of a multi-module commit in master within the last seven months or so. I've based my commit message on that.

@arschmitz
Copy link
Contributor

@jugglinmike ah you are right i think it should have been two commits but its fine . Thanks for the contribution!

@gabrielschulhof
Copy link

The commit message should also say "Re gh-5987".

Both modules have a hard dependency on the "vmouse" module that should
be expressed in AMD.

Re jquery-archivegh-5987
Closes jquery-archivegh-7274
@jugglinmike
Copy link
Contributor Author

@gabrielschulhof Done. Think this is ready to merge?

@arschmitz
Copy link
Contributor

@jugglinmike it is ready i already pulled rebased tested and added the re just apparently never pushed it ( it was late at night lol ) ill push it right now

@coveralls
Copy link

Coverage Status

Coverage increased (+0.21%) when pulling b5fe86d on jugglinmike:events-dependency into 7b818d8 on jquery:master.

@jugglinmike
Copy link
Contributor Author

@arschmitz Another late night, maybe? :P

@jaspermdegroot
Copy link
Contributor

@arschmitz - To which branch did you push this?

For the commit message: merging will fix #7383

@arschmitz arschmitz closed this in 44e2d98 Jun 2, 2014
arschmitz pushed a commit that referenced this pull request Jun 3, 2014
Both modules have a hard dependency on the "vmouse" module that should
be expressed in AMD.

Re gh-5987
Closes gh-7383
Closes gh-7274

(cherry picked from commit 44e2d98)
agcolom pushed a commit to agcolom/jquery-mobile that referenced this pull request Nov 26, 2014
Both modules have a hard dependency on the "vmouse" module that should
be expressed in AMD.

Re jquery-archivegh-5987
Closes jquery-archivegh-7383
Closes jquery-archivegh-7274
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants