-
Notifications
You must be signed in to change notification settings - Fork 6
GPII-2933 Common Event Bindings #13
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
base: main
Are you sure you want to change the base?
Conversation
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/2/ |
|
Great idea, and very useful, as we do this kind of grunt work all the time in downstream grades. Although I could look at stuff in isolation, it'd be helpful to see tests so that I can see examples of what you're passing and what the intended effect is. I'm happy with these being synthetic testem-friendly tests, simulating keyboard input crudely rather than using gpii-webdriver. Also, linting! Dude! (I was wondering how the heck you managed to break the tests without adding tests for your work. That's how.) |
|
Hi @the-t-in-rtf . I added a few unit tests for this, and everything should lint now. :) |
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/4/ |
|
Hi, @sgithens, I'm trying to make sense of the associated ticket, you kind of describe in the title the change you're making, but I couldn't get more info as most of the links to example there are broken. I think I get it, but for posterity we need a clear summary. Also, the new functionality needs to be described somewhere, perhaps in a new section towards the end of the README. |
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/5/ |
|
@the-t-in-rtf Updated the README and ticket. I believe this should be ready for another review now. |
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/6/ |
src/js/common-event-bindings.js
Outdated
| * Function to process the markup binding decorators and create the events described | ||
| * by them. The markup needs to be rendered and settled before this can be called. | ||
| * | ||
| * @param {Object} that - The component itself. |
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 am the guiltiest party here, I do this all the time, but in later work, @amb26 and I have been adding the grade to these for purposes of clarity.
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.
Make these more specific using the component grade for the type.
| paragraphClick: ".paragraph-click", | ||
| multipleEventInputButton: "#input-multiple-events-button" | ||
| }, | ||
| markupEventBindings: { |
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.
Also supply a test which shows that these handlers can be overridden cleanly
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.
Added a test where 1) Some are left as is, 2) some are overridden, and 3) some new one is introduced.
| markupEventBindings: { | ||
| inputButton: { | ||
| method: "click", | ||
| args: ["{that}.handleInputClick"] |
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.
Supply further tests to validate the primitive kinds of "compact" IoC syntax we support which allows for args
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.
Thanks for this tip, I didn't know this was possibly actually, and will simplify my usage in the capture tool, PPT, and elsewhere
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/11/ |
- Adding ability to pass an array of handlers to eventMarkupBindings - Adding unit tests for overriding bindings in sub grades - Adding unit tests for compact IoC invocation - Grammar and jsdoc fixes
|
@amb26 @the-t-in-rtf I believe this should be ready for another round of review now |
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/12/ |
|
The build failed because the VM couldn't be created: OK to test again. |
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/13/ |
|
Vagrant timeout this go around. Ok to test again, if it fails a third time we should rope in Alfredo to assist. |
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/14/ |
Looks like the build was killed after timing out, I suspect issues with testem. I am testing locally at the moment and will advise shortly on how to proceed. |
|
OK, there are two problems:
With those two fixes your tests pass in Vagrant locally. |
|
@the-t-in-rtf Thanks for the sluething, try these updates now. |
|
CI job passed: https://ci.gpii.net/job/gpii-binder-tests/15/ |
|
@the-t-in-rtf Yes! It passed |
|
CI job failed: https://ci.gpii.net/job/gpii-binder-tests/16/ |
|
Looks like a timeout... ok to test |
|
CI job passed: https://ci.gpii.net/job/gpii-binder-tests/17/ |
|
@the-t-in-rtf Ok, this is passed, and I think ready for another review now. |
| */ | ||
| fluid.defaults("gpii.binder.bindMarkupEvents", { | ||
| mergePolicy: { | ||
| decorators: "noexpand" |
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.
Why is this "decorators"?
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.
In other words, is there a pattern we're emulating? Just curious.
| onMarkupRendered: null | ||
| }, | ||
| listeners: { | ||
| onMarkupRendered: "{that}.events.onDomBind.fire({that}, {that}.container)", |
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.
These should all be namespaced. I'd also suggest using the "long form" to this shorter notation. That way someone can at least opt out of part of the contract in a derived grade by changing the "funcName" to fluid.identity or the like.
| if (node.length > 0) { | ||
| var name = "Decorator for DOM node with selector " + key + " for component " + fluid.dumpThat(that); | ||
| // val can be an array to support multiple event handlers | ||
| var handlerDecs = fluid.isArrayable(val) ? val : [val]; |
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.
Why not just use fluid.makeArray here?
| } | ||
| }, | ||
| listeners: { | ||
| "onCreate.markupEventBindings": "{that}.events.onMarkupRendered.fire()" |
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 is the kind of thing I'd also write out, what if someone needs to do other work before firing the event? I guess they can just rewrite the whole string.
| } | ||
| }); | ||
|
|
||
| gpii.tests.binder.commonEventBindings.environment(); |
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 guess it matters less on the browser side (I think?), but for consistency with the rest of the package, this should use fluid.test.runTests instead of calling the environment directly.
| } | ||
| }); | ||
|
|
||
| gpii.tests.binder.commonEventBindingsOverride.environment(); |
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.
We should either consistently use fluid.test.runTests or consistently not use it.
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.
+1 since without runTests there is no teardown
| <script type="text/javascript" src="../../src/js/common-event-bindings.js"></script> | ||
| </head> | ||
| <body> | ||
| <h1 id="qunit-header">"Common Event Bindings" Component Tests</h1> |
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 update the page and header title to distinguish this from the other tests.
| <!-- Test HTML, we have to hide this ourselves. QUnit's styles put it offscreen, which doesn't work for us. --> | ||
| <div class="viewport-common-event-bindings" style="display:none"> | ||
| <form> | ||
| <h3>Common Event Bindings...</h3> |
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 know it's mostly harmless, but for any human trying to troubleshoot the test, this should also be different than the other comment event bindings tests.
|
|
@amb26 @the-t-in-rtf I'm going to look at adding a few unit tests, but if you wanted to take an initial look at this and give me any feedback, that'd be helpful