You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Tzvetanov Grigorov (Jira)" <ji...@apache.org> on 2021/12/16 13:48:00 UTC
[jira] [Resolved] (WICKET-6939) Problems with testing form submission if dealing with multiple AJAX click behaviors
[ https://issues.apache.org/jira/browse/WICKET-6939?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Tzvetanov Grigorov resolved WICKET-6939.
-----------------------------------------------
Resolution: Not A Problem
Closing as "Not a problem".
Please share more information if you believe there is some misunderstanding and we will re-open the ticket!
> Problems with testing form submission if dealing with multiple AJAX click behaviors
> -----------------------------------------------------------------------------------
>
> Key: WICKET-6939
> URL: https://issues.apache.org/jira/browse/WICKET-6939
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-core
> Affects Versions: 8.7.0
> Reporter: Markus Bohr
> Priority: Minor
>
> both wicketTester.executeAjaxEvent(..) aswell as wicketTester.newFormTester(..).submit(..)
> cannot handle cases where multiple click behaviors are attached to the submitting component, i.e. a button, and the first behavior processed within BaseWicketTester.executeAjaxEvent(final Component component, final String event) is the non-submitting (i.e. not AjaxFormSubmitBehavior) behavior.
> This first behavoir creates a brand new request after being processed, and thus clears the uploadedFile added beforehand via tester.getRequest().addFile(..) needed when submission of the form is processed.
> In my case there is such a behavior (a loading indicator) that I had, as a workaround to this bug, first to remove in my test code in order to make my unit test work:
>
> {noformat}
> final BeladungPage startedPage = this.tester.startPage(this.beladungPage);
> final File xmlFile = new File("src/test/resources/camunda.cfg.xml");
> final FormComponent<?> formComponent = (FormComponent<?>) tester.getComponentFromLastRenderedPage(
> "upload:form:sections:sections:0:section:body:file:upload");
> // workaround for wicket bug in tester.executeAjaxEvent() / tester.newFormTester().submit() if dealing with multiple AJAX click behaviors
> final Button submitButton = (Button) this.tester.getComponentFromLastRenderedPage("upload:form:buttons:buttons:0:button");
> submitButton.remove(submitButton.getBehaviors(ClickAjaxEventBehavior.class).get(0));
> tester.getRequest().addFile(formComponent.getInputName(), xmlFile, "application/xml");
> tester.executeAjaxEvent("upload:form:buttons:buttons:0:button", "click");
> // tester.newFormTester("upload:form", false).submit("buttons:buttons:0:button");
> final IFeedbackMessageFilter msgFilter = new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR);
> final List<FeedbackMessage> feedbackMessages = this.tester.getFeedbackMessages(msgFilter);
> Assert.assertEquals(
> "[[FeedbackMessage message = \"Ein Fehler ist aufgetreten! Die markierten Felder wurden unzureichend ausgefüllt.<br>Bitte überprüfen Sie Ihre Angaben.\", reporter = form, level = ERROR], [FeedbackMessage message = \"content-type 'application/xml' wird nicht unterstützt\", reporter = file, level = ERROR]]",
> feedbackMessages.toString());{noformat}
>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)