You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Markus Bohr (Jira)" <ji...@apache.org> on 2021/12/10 11:20:00 UTC

[jira] [Created] (WICKET-6939) Problems with testing form submission if dealing with multiple AJAX click behaviors

Markus Bohr created WICKET-6939:
-----------------------------------

             Summary: 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: Bug
          Components: wicket-core
    Affects Versions: 8.7.0
            Reporter: Markus Bohr


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



In my case there is such a behavior (a loding indicator) that a had, as aworkaround to this bug, first to remove in my test code to make my unit test work:



 
{noformat}
        final BeladungPage startedPage = this.tester.startPage(this.beladungPage);        final SingleFileUploadField fileUploadInput = (SingleFileUploadField) this.tester.getComponentFromLastRenderedPage(
                "upload:form:sections:sections:0:section:body:file:upload");
        final RefFileUpload refFileUploadField = new RefFileUpload(new DiskFileItem("xx", "csv", false, "yy", 33, null), "zz", "aa", 11);
        fileUploadInput.setModel(Model.of(refFileUploadField));        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)