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

FLUID-5534: UIO responsiveness and unit testing #844

Merged
merged 48 commits into from Oct 5, 2017
Merged

FLUID-5534: UIO responsiveness and unit testing #844

merged 48 commits into from Oct 5, 2017

Conversation

ghost
Copy link

@ghost ghost commented Sep 6, 2017

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

}
},
invokers: {
scrollToPanel: {
Copy link
Member

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.

Copy link
Author

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?

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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;
Copy link
Member

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;?

Copy link
Author

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", {
Copy link
Member

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.

Copy link
Author

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?

Copy link
Member

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.

@ghost ghost changed the title Fluid 5534 Fluid 5534: UIO responsiveness and unit testing Sep 11, 2017
@ghost ghost changed the title Fluid 5534: UIO responsiveness and unit testing FLUID-5534: UIO responsiveness and unit testing Sep 13, 2017
jobara and others added 3 commits September 15, 2017 09:50
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: {
Copy link
Member

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) {
Copy link
Member

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: {
Copy link
Member

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
Copy link
Member

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

Copy link
Member

@jobara jobara Sep 19, 2017

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?

Copy link
Member

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
Copy link
Member

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)

@jobara
Copy link
Member

jobara commented Sep 21, 2017

@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?

@amb26
Copy link
Member

amb26 commented Sep 21, 2017

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.

event = new Event(type);
} else {
event = document.createEvent("Event");
event.initEvent("resize", true, true);
Copy link
Member

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

@jobara
Copy link
Member

jobara commented Sep 25, 2017

@amb26 I believe this is ready for more review. I've also added an Infusion-Docs PR.

}]
});

fluid.tests.iframeSetup.load = function (that) {
Copy link
Member

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>
Copy link
Member

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 () {
Copy link
Member

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

@jobara
Copy link
Member

jobara commented Oct 2, 2017

@amb26 this is ready for more review

type: "fluid.transforms.limitRange",
input: "{that}.model.panelIndex",
min: 0,
max: "{that}.model.panelMaxIndex"
Copy link
Member

Choose a reason for hiding this comment

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

Now it is lovely!

jobara and others added 2 commits October 5, 2017 10:37
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.
@jobara
Copy link
Member

jobara commented Oct 5, 2017

@amb26 the build process has been updated so that buildStylus is run on prepublish

@amb26 amb26 merged commit 5857a79 into fluid-project:master Oct 5, 2017
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.

3 participants