diff --git a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/termsandconditions/_cq_template/.content.xml b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/termsandconditions/_cq_template/.content.xml index 95a10387e4..6b2bdabe8f 100644 --- a/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/termsandconditions/_cq_template/.content.xml +++ b/examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/termsandconditions/_cq_template/.content.xml @@ -19,6 +19,7 @@ jcr:title="I agree to the terms & conditions" sling:resourceType="core/fd/components/form/checkbox/v1/checkbox" enabled="false" + required="true" checkedValue="true" fieldType="checkbox"> diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_template.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_template.xml index 95a10387e4..856d620fbc 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_template.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/termsandconditions/v1/termsandconditions/_cq_template.xml @@ -18,6 +18,7 @@ jcr:primaryType="nt:unstructured" jcr:title="I agree to the terms & conditions" sling:resourceType="core/fd/components/form/checkbox/v1/checkbox" + required="true" enabled="false" checkedValue="true" fieldType="checkbox"> diff --git a/ui.tests/test-module/specs/termsandconditions/tnc.runtime.spec.js b/ui.tests/test-module/specs/termsandconditions/tnc.runtime.spec.js index d2a12800fa..6858432dfd 100644 --- a/ui.tests/test-module/specs/termsandconditions/tnc.runtime.spec.js +++ b/ui.tests/test-module/specs/termsandconditions/tnc.runtime.spec.js @@ -110,5 +110,25 @@ describe("Form Runtime with Terms and Conditions", () => { }) }) }); -}) + it('checkbox should be required by default', () => { + const tncWithLinksID = formContainer._model.items[1].id; + const model = formContainer._model.getElement(tncWithLinksID) + expect(model.getState().items[0].enabled).to.equal(false); + cy.get(`#${tncWithLinksID}`).get('a').click() + .then(() => { + expect(model.getState().items[0].enabled).to.equal(true); + cy.get(`#${tncWithLinksID} .cmp-adaptiveform-checkbox`).invoke('attr', 'data-cmp-enabled') + .should('eq', 'true'); + cy.get(`#${tncWithLinksID} .cmp-adaptiveform-checkbox`).click() + .then(() => { + cy.get(`#${tncWithLinksID} .cmp-adaptiveform-checkbox__errormessage`).should('be.empty'); + }) + cy.get(`#${tncWithLinksID} .cmp-adaptiveform-checkbox`).dblclick().should('not.be.checked') + .then(() => { + cy.get(`#${tncWithLinksID} .cmp-adaptiveform-checkbox__errormessage`).should('not.be.null'); + }) + }) + }) + + })