Kamil created WICKET-6510:
-----------------------------
Summary: Provide unified "click" and "submit" mechanism in
WicketTester/FormTester
Key: WICKET-6510
URL: https://issues.apache.org/jira/browse/WICKET-6510
Project: Wicket
Issue Type: Improvement
Reporter: Kamil
I started a
[discussion|http://mail-archives.apache.org/mod_mbox/wicket-dev/201708.mbox/%3Cd3ebee6b-479b-2a56-1180-165ed8f26522%40solsoft.pl%3E]
some time ago on dev's mailing list, but it is long forgotten now. Because I
find this feature important, I decided to report it as feature request here
(maybe someday someone will provide a solution).
h3. Click
h4. Links and Buttons
h5. Facts:
Currently WicketTester has "#clickLink" method. Its javadoc says:
{code}
"When clicking an AjaxSubmitLink the form, which the AjaxSubmitLink is attached
to is first submitted, and then the onSubmit method on AjaxSubmitLink is
invoked. If you have changed some values in the form during your test, these
will also be submitted. This should not be used as a replacement for the {@link
FormTester} to test your forms. It should be used to test that the code in your
onSubmit method in AjaxSubmitLink actually works."
{code}
As I stated in https://issues.apache.org/jira/browse/WICKET-6442 it possibly
could work also for SubmitButton, but as Martin Grigorov rightly noticed:
{code}
"clickLink should not deal with Buttons."
{code}
And also:
{code}
"clickLink() is there since early versions and it is hard to remove it now. We
don't want #clickButton(), #submitButton(), #blurButton(), #hoverLabel(), etc."
{code}
h5. Conclusion:
There should be single "click" method that you can use to click on a link/button
h4. Checkboxes
h5. Facts:
Checkboxes are not only used in forms. AjaxCheckbox often serves as
"Enable/Disable" or "Show/Hide" trigger.
It is "logical" that if I *click* checkbox - its action is invoked. Right?
Unfortunately not. It occurs that first I must "set it to true"
(https://issues.apache.org/jira/browse/WICKET-6447)
It's not the way users interact with application and in my opinion it shouldn't
be tested that way because it's cumbersome and away from reality.
Of course for testing forms explicitly (hence selecting explicit value of
checkbox for form submission) we should use of course FormTester.
Here I'm only talking about checkboxes that are "functional" (I don't know how
to call it properly - the ones that are changing state, enabling/disabling
something etc.)
An example:
{code}
final Panel hides = new Panel("hides") {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(model.getObject());
}
};
final AjaxCheckBox functional = new AjaxCheckBox("targeted", model) {
protected void onUpdate(AjaxRequestTarget target) {
target.add(hides);
}
};
{code}
h5. Conclusion:
The same "click" method from the "click Link/Button" should also work for a
checkbox in a way that the behavior of:
1) click(checkbox) + click(checkbox) + submit(form) should: select it, then
deselect it and submit nothing for it
2) click + click should leave the same model value as 0 clicks
h3. Submit
h5. Facts:
It occurs that FormTester #submit method works in a strange way (it submits
form without "submit button", but doesn't submit anything if it has default
button https://issues.apache.org/jira/browse/WICKET-6446) which seem weird to
me.
As Sven Meier noticed:
{code}
There are thousands of tests out there, we won't break these by changing the
semantics of a method.
Feel free to submit a pull request that adds a new method to FormTester, e.g.
#submitDefaultButton()
{code}
But I don't think that another submit method (remember that BaseWicketTester
already has two: #submitForm(Form<?>) and #submitForm(String) ) is what you
want (recall what Martin Grigorov said)
h5. Conclusion:
There should be single "submit" method, which can submit form without any
submit button (as it is now) and additionally a form with default button set
(using this default button).
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)