Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.4.19, 1.5.3, 6.0.0-beta1
-
None
Description
While working on WICKET-4295, I discovered that FormTester doesn't handle nested form submits correctly.
The browser will always submit the outermost form, because that is the only form it sees. Wicket will then determine the correct form by looking at the submitting component. If you create a FormTester on an inner form, however, the test request will point directly at that inner form. This is a problem for the new feature in WICKET-4295, but also in general since it does not correctly model the actual interaction. Also the submitting component is not found due to the wrong form being looked at. (form.getRootForm() == Form.this in Form#findSubmittingButton()) This means that for a nested form, the submitting component could never be found! I think it's mostly luck that this is not a bigger issue in tests
It is possible to have the correct handling in a test, if you do newFormTester(outerForm) and then submit with a submit button in the inner form (formtester.submit("inner:submitButton")).
I think FormTester should do the correct thing on its own though. The fix is trivial: in submit() don't just use the form it's pointing at, but use form.getRootForm(). This fixes both the correct request handling, as well as the issue with not finding the submitting component.
I'll attach the appropriate patches.
Attachments
Attachments
1.
|
Correct tests for nested form handling | Resolved | Unassigned |