-
Notifications
You must be signed in to change notification settings - Fork 97
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
FLUID-5534: UIO responsiveness and unit testing #844
Conversation
The interactions for the arrows weren't working in IE, so we are hiding them instead. This is still just an interim solution, and hopefully the final solution will be supported across all supported browsers.
Also removed duplicate id's from separated panel markup
Added an example of using full page prefs editor but with separated panel styling and responsive interactions.
} | ||
}, | ||
invokers: { | ||
scrollToPanel: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a modellised component rather than using DOM coordinates as an implicit model - also the range limiting should be done within the model space using a relay. See https://github.com/fluid-project/infusion/blob/master/src/components/textfieldControl/js/TextfieldSlider.js#L64 for examples of the latter.
Rather than a "scrollToPanel" invoker, the component should expose "panelIndex" and "panelCount" as model elements, with the final line "scrollLeft" implemented as a modelListener to the former.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amb26 Thanks for the comment! I'm not sure I totally understand though. Do you mind going through it step-by-step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grrrero, a similar example that has implemented @amb26's suggestion is the scrolling feature in the language panel of the first discovery tool.
The panelIndex
model value in @amb26's comment serves the same purpose as the selectedLang
n the example. It keeps track of the current panel index. A click on arrow keys triggers a model change on the panelIndex
value (to the scrollIndex
value you calculated here). Then the model listener on panelIndex
will perform the scrolling.
@amb26, correct me if this explanation doesn't seem right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grrrero and @cindyli I think this may be similar to https://github.com/GPII/first-discovery/blob/master/src/js/nav.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grrrero I've made some changes to finish up the work we started the other day to modelize panelIndex. I've submit a pull request against your branch ( https://github.com/grrrero/infusion/pull/1 ). You should review those changes and merge them into your branch if you are happy with them. You will need to add more tests to SeparatedPanelPrefsEditorTests for verifying the panelIndex after scrolling and to also trigger scrolling by using the change applier to change the panelIndex value.
|
||
fluid.tests.clickArrow = function (elm, direction) { | ||
var keyEvent = $.Event("click"); | ||
keyEvent.offsetX = direction ? elm.width() : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit indirect and confusing to use {LEFT: false, RIGHT: true}
to calculate offsetX
. What do you think about something like keyEvent.offsetX = direction === "RIGHT" ? elm.width() : 0;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cindyli Hi Cindy, that makes sense, and less confusing.
elm.trigger(keyEvent); | ||
}; | ||
|
||
fluid.defaults("fluid.tests.separatedPanelResponsiveTester", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test the re-rendering at window resize too, when the window changes from a small screen to a wide screen and vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cindyli Tested it, no bugs so far, and is there anything I should be looking out for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grrrero, I mean to add a unit test to make sure the window size change triggers the re-rendering of panels, not only via the manual test.
Started adding/updating unit tests but more should be added for verifying model values and scrolling via model changes in SeparatedPanelPrefsEditorTests
FLUID-5534: Modelizing panelIndex
modelRelay: { | ||
target: "panelIndex", | ||
forward: {excludeSource: "init"}, | ||
singleTransform: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement at modelising this component! Do put a namespace on this relay rule and the model listener which follows it in case anyone wants to override it someday
return Math.max(0, panels.length - 1); | ||
}; | ||
|
||
fluid.prefs.arrowScrolling.translateToScroll = function (that, event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly better naming for this function/invoker - something like "eventToScrollIndex"?
} | ||
}, | ||
invokers: { | ||
scrollToPanel: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This invoker can be axed - the documentation that "scrollToIndex" is modelised is sufficient. Also it confusingly shares a name with the panelIndex listener
}, | ||
model: { | ||
// panelMaxIndex: null, // determined by the number of panels calculated after the onPrefsEditorMarkupReady event fired | ||
// scrollToIndex: null, // the raw index set by translateToScroll, will be transformed to the panelIndex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can get by with just one model field between scrollToIndex and panelIndex, and have translateToScroll attempt to write to panelIndex directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amb26 will the model transformation to limit the range of panelIndex still work in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how it works in the original sample (the pager)
panelIndex: 0 | ||
}, | ||
events: { | ||
// beforeReset: null // should be provided by the fluid.prefs.prefsEditor grade |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to uncomment this so there is a greater chance that the component can be self-sufficient (even if there are currently other reasons why it can't)
@amb26 the SeparatedPanelPrefsEditorResponsive-test.html test is not added to any of the all-tests.html files because the asynchrony needed to wait for the iframe to load is preventing the composite test from seeing any jqUnit tests. Do you know if there is a way to get around this? |
Yes - we have plenty of tests with asynchrony which work fine in the mix. The issue in this case will be most likely the test not beginning to execute sufficiently soon after the page load - this is a problem with QUnit's architecture which is well known. You have a 13ms window after the time QUnit itself is loaded to start queuing your tests, otherwise it will shut down assuming that there are none. The problem is with the organisation of the test fixtures here - https://github.com/fluid-project/infusion/pull/844/files#diff-b55a73d1ab99b3bc42f1d4bc39a00744R251 - rather than waiting for the iframe to load and then starting to queue the tests afterwards, you should integrate the iframe loading into the test fixtures themselves, and start the tests immediately. This is similar to an issue that @michelled had with needing to wait for electron's app singleton to load before starting to run tests. |
FLUID-5534: Added window resize test
FLUID-5534: Update tests to work in all-tests
event = new Event(type); | ||
} else { | ||
event = document.createEvent("Event"); | ||
event.initEvent("resize", true, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this should use the supplied type here
FLUID-5534: Improvements to modelRelay
@amb26 I believe this is ready for more review. I've also added an Infusion-Docs PR. |
}] | ||
}); | ||
|
||
fluid.tests.iframeSetup.load = function (that) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put these definitions in a more descriptive namespace - since they are hardwired to start a pageEnhancer test. The name should at least indicate what broad area of the framework is being tests, e.g. fluid.tests.prefs or so
|
||
<!-- Test HTML --> | ||
<!-- <div id="qunit-fixture"> --> | ||
<iframe class="flc-iframeSetup-responsiveTests"></iframe> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here and/or in the corresponding testDefs to the considerable research you've done in establishing why this is necessary on all current versions of IE (including linking to the jQuery ticket that holds a hopefully related selection bug)
@@ -131,8 +136,9 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt | |||
fluid.tests.afterHideFunc1 = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retrospectively we should take the opportunity to fix namespacing of lots of definitions like this. Even browser tests should be written with the model that one day all these definitions might coexist as part of a single global namespace
FLUID-5534: Updated test namespace
FLUID-5534: Updating namespace for separated panel tests.
@amb26 this is ready for more review |
type: "fluid.transforms.limitRange", | ||
input: "{that}.model.panelIndex", | ||
min: 0, | ||
max: "{that}.model.panelMaxIndex" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it is lovely!
Previously on install, stylus would not be compiled to CSS and on buildDist any generated CSS would be removed. However the CSS is now required for the responsive tests and must be in place.
FLUID-5534: Updating so that the tests will pass after an npm install.
@amb26 the build process has been updated so that buildStylus is run on prepublish |
Expanded unit tests, updated fluid.prefs.separatedPanel.scrollToPanel to constrain panelIndex within the range of panels, added arrows for navigation for responsive version.
https://issues.fluidproject.org/browse/FLUID-5534
Infusion-Docs PR: fluid-project/infusion-docs#127