Skip to content
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

EditModelWidgetRender renderText generates class="input-small" twice #48

Open
patkyn opened this issue Oct 18, 2019 · 1 comment
Open

Comments

@patkyn
Copy link
Contributor

patkyn commented Oct 18, 2019

While running unit test EditModelWidgetRenderSpec in grails 3, the following test fails:

    def "the input renderer should include the html5 maxlength attribute and a placeholder if a maxSize validation rule is defined"() {
        setup:
        ctx = ctxBuilder().model([source:'myText', type:'text']).validationString("required,maxSize[100]").build()

        when:
        editModelWidgetRenderer.renderText(ctx)

        then:

        TestUtils.compareHtml(ctx.writer, """<input type="text" data-bind="value:${ctx.model.source}" class="input-small" maxlength="100" placeholder="(maximum 100 characters)" data-validation-engine="validate[${ctx.dataModel.validate}]"></textarea>""")
    }

[Fatal Error] :1:206: Attribute "class" was already specified for element "input".

Condition failed with Exception:

TestUtils.compareHtml(ctx.writer, """<input type="text" data-bind="value:${ctx.model.source}" class="input-small" maxlength="100" placeholder="(maximum 100 characters)" data-validation-engine="validate[${ctx.dataModel.validate}]"></textarea>""")
          |           |   |                                                |   |     |                                                                                                                      |   |         |
          |           |   |                                                |   |     myText                                                                                                                 |   |         required,maxSize[100]
          |           |   |                                                |   [type:text, source:myText]                                                                                                   |   [name:myText, validate:required,maxSize[100]]
          |           |   |                                                au.org.ala.ecodata.forms.WidgetRenderContext@f146392                                                                             au.org.ala.ecodata.forms.WidgetRenderContext@f146392
          |           |   <input  class="input-small" maxlength="100" placeholder="(maximum 100 characters)" data-bind='value:myText'  data-validation-engine='validate[required,maxSize[100]]' type='text' class='input-small'/>
          |           au.org.ala.ecodata.forms.WidgetRenderContext@f146392
          org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 206; Attribute "class" was already specified for element "input".

Condition failed with Exception:

TestUtils.compareHtml(ctx.writer, """<input type="text" data-bind="value:${ctx.model.source}" class="input-small" maxlength="100" placeholder="(maximum 100 characters)" data-validation-engine="validate[${ctx.dataModel.validate}]"></textarea>""")
          |           |   |                                                |   |     |                                                                                                                      |   |         |
          |           |   |                                                |   |     myText                                                                                                                 |   |         required,maxSize[100]
          |           |   |                                                |   [type:text, source:myText]                                                                                                   |   [name:myText, validate:required,maxSize[100]]
          |           |   |                                                au.org.ala.ecodata.forms.WidgetRenderContext@f146392                                                                             au.org.ala.ecodata.forms.WidgetRenderContext@f146392
          |           |   <input  class="input-small" maxlength="100" placeholder="(maximum 100 characters)" data-bind='value:myText'  data-validation-engine='validate[required,maxSize[100]]' type='text' class='input-small'/>
          |           au.org.ala.ecodata.forms.WidgetRenderContext@f146392
          org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 206; Attribute "class" was already specified for element "input".

	at au.org.ala.ecodata.forms.EditModelWidgetRenderSpec.the input renderer should include the html5 maxlength attribute and a placeholder if a maxSize validation rule is defined(EditModelWidgetRenderSpec.groovy:100)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 206; Attribute "class" was already specified for element "input".
	at groovy.util.XmlSlurper.parse(XmlSlurper.java:205)
	at groovy.util.XmlSlurper.parse(XmlSlurper.java:258)
	at au.org.ala.ecodata.forms.TestUtils.compareHtml(TestUtils.groovy:39)
	at au.org.ala.ecodata.forms.TestUtils.compareHtml(TestUtils.groovy:28)
	... 1 more


The editModelWidgetRenderer.renderText(ctx) currently is generating 2 input class and SAXParser is now more strict about this.

@patkyn
Copy link
Contributor Author

patkyn commented Oct 18, 2019

Temporarily comment out this test EditModelWidgetRenderSpec grails 3. When this is fixed, the test should be put back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant