Skip to content

Commit 423270c

Browse files
authored
Merge pull request #1260 from adobe/dev-to-master-june6
Sync dev to master
2 parents d901cd9 + d44e650 commit 423270c

File tree

10 files changed

+220
-54
lines changed

10 files changed

+220
-54
lines changed

examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/page/.content.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
jcr:description="Page Component for the Forms Components Library"
44
jcr:primaryType="cq:Component"
55
jcr:title="Page"
6-
sling:resourceSuperType="core/fd/components/page/v1/page"
6+
sling:resourceSuperType="core/fd/components/page/v2/page"
77
componentGroup=".hidden"/>

it/config/src/main/content/jcr_root/apps/system/config/com.adobe.granite.toggle.impl.dev.DynamicToggleProviderImpl.cfg.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"FT_FORMS-12052",
1818
"FT_FORMS-13209",
1919
"FT_FORMS-11581",
20-
"FT_FORMS-14545"
20+
"FT_FORMS-14545",
21+
"FT_SITES-19631"
2122
]
2223
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
3+
jcr:primaryType="dam:Asset">
4+
<jcr:content
5+
jcr:lastModified="{Date}2023-01-30T15:58:14.439+05:30"
6+
jcr:primaryType="dam:AssetContent"
7+
sling:resourceType="fd/fm/af/render"
8+
guide="1"
9+
type="guide">
10+
<metadata
11+
fd:version="2.1"
12+
jcr:primaryType="nt:unstructured"
13+
allowedRenderFormat="HTML"
14+
author="admin"
15+
availableInMobileApp="{Boolean}false"
16+
dorType="none"
17+
formmodel="none"
18+
hasCustomThumbnail="{Boolean}false"
19+
themeRef="/libs/fd/af/themes/canvas"
20+
title="Number Input Validation"/>
21+
</jcr:content>
22+
</jcr:root>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
3+
jcr:primaryType="cq:Page">
4+
<jcr:content
5+
cq:deviceGroups="[mobile/groups/responsive]"
6+
cq:lastModified="{Date}2024-03-15T11:49:56.500+05:30"
7+
cq:lastModifiedBy="admin"
8+
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
9+
jcr:language="en"
10+
jcr:primaryType="cq:PageContent"
11+
jcr:title="Number Input Validation"
12+
sling:configRef="/conf/forms/core-components-it/samples/numberinput/basic/"
13+
sling:resourceType="forms-components-examples/components/page">
14+
<guideContainer
15+
fd:version="2.1"
16+
jcr:lastModified="{Date}2024-03-15T11:49:22.521+05:30"
17+
jcr:lastModifiedBy="admin"
18+
jcr:primaryType="nt:unstructured"
19+
sling:resourceType="forms-components-examples/components/form/container"
20+
clientLibRef="corecomponent.it.customfunction"
21+
dorType="none"
22+
fieldType="form"
23+
schemaType="none"
24+
textIsRich="true"
25+
thankYouMessage="Thank you for submitting the form."
26+
thankYouOption="page"
27+
themeRef="/libs/fd/af/themes/canvas">
28+
<numberinput1
29+
jcr:lastModified="{Date}2023-01-30T15:58:08.713+05:30"
30+
jcr:lastModifiedBy="admin"
31+
jcr:primaryType="nt:unstructured"
32+
jcr:title="Number Input 1"
33+
sling:resourceType="forms-components-examples/components/form/numberinput"
34+
enabled="{Boolean}true"
35+
fieldType="number-input"
36+
hideTitle="false"
37+
mandatoryMessage="This is required numberinput"
38+
name="numberinput1"
39+
readOnly="{Boolean}false"
40+
required="true"
41+
type="number"
42+
visible="{Boolean}true"/>
43+
<numberinput2
44+
jcr:lastModified="{Date}2023-01-30T15:58:08.713+05:30"
45+
jcr:lastModifiedBy="admin"
46+
jcr:primaryType="nt:unstructured"
47+
jcr:title="Number Input 2"
48+
sling:resourceType="forms-components-examples/components/form/numberinput"
49+
enabled="{Boolean}true"
50+
fieldType="number-input"
51+
hideTitle="false"
52+
mandatoryMessage="This is required integer numberinput"
53+
name="numberinput2"
54+
readOnly="{Boolean}false"
55+
required="true"
56+
type="integer"
57+
visible="{Boolean}true"/>
58+
<numberinput3
59+
jcr:lastModified="{Date}2023-01-30T15:58:08.713+05:30"
60+
jcr:lastModifiedBy="admin"
61+
jcr:primaryType="nt:unstructured"
62+
jcr:title="Number Input 3"
63+
sling:resourceType="forms-components-examples/components/form/numberinput"
64+
default="10"
65+
enabled="{Boolean}true"
66+
fieldType="number-input"
67+
hideTitle="false"
68+
mandatoryMessage="mandatory message!!!"
69+
name="numberinput3"
70+
readOnly="{Boolean}false"
71+
required="true"
72+
type="integer"
73+
visible="{Boolean}true"/>
74+
<submit
75+
jcr:lastModified="{Date}2023-06-22T17:28:46.456+05:30"
76+
jcr:lastModifiedBy="admin"
77+
jcr:primaryType="nt:unstructured"
78+
jcr:title="Submit"
79+
sling:resourceType="forms-components-examples/components/form/actions/submit"
80+
buttonType="submit"
81+
dorExclusion="true"
82+
fieldType="button"
83+
name="submit1687435309125">
84+
<fd:rules
85+
fd:click="[{&quot;nodeName&quot;:&quot;ROOT&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_SCRIPTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;EVENT_CONDITION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;COMPONENT&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.button1667450213112&quot;\,&quot;type&quot;:&quot;BUTTON&quot;\,&quot;name&quot;:&quot;button1667450213112&quot;}}\,{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON_OPERATOR&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;is clicked&quot;\,&quot;value&quot;:null}}\,{&quot;nodeName&quot;:&quot;PRIMITIVE_EXPRESSION&quot;\,&quot;choice&quot;:null}]}\,&quot;nested&quot;:false}\,{&quot;nodeName&quot;:&quot;Then&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;BLOCK_STATEMENTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;BLOCK_STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;SUBMIT_FORM&quot;\,&quot;items&quot;:[]}}]}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:[&quot;submitForm()&quot;]\,&quot;eventName&quot;:&quot;Click&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
86+
jcr:primaryType="nt:unstructured"/>
87+
<fd:events
88+
jcr:primaryType="nt:unstructured"
89+
click="[submitForm()]"/>
90+
</submit>
91+
</guideContainer>
92+
</jcr:content>
93+
</jcr:root>

it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/page/afv2/.content.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
jcr:language="en"
1010
jcr:primaryType="cq:PageContent"
1111
jcr:title="Page Edge Delivery"
12-
sling:configRef="/conf/forms/afv2/"
12+
sling:configRef="/conf/core-components-it/samples/customfunctionedgedelivery/"
13+
cq:conf="/conf/core-components-it"
1314
sling:resourceType="core/fd/components/page/v2/page">
1415
<guideContainer
1516
fd:version="2.1"

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/container.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
data-sly-test.isEdgeDeliveryRequest="${formUtil.edgeDeliveryRequest}">
2222
<div>
2323
<div>
24-
<pre>
25-
<code>${formstructparser.formDefinition}</code>
26-
</pre>
24+
<pre>
25+
<code>"${formstructparser.formDefinition @ context='jsonString'}"</code>
26+
</pre>
2727
</div>
2828
</div>
2929
</div>

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/numberinput/v1/numberinput/clientlibs/site/js/numberinputwidget.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@
7878
this.#regex = new RegExp(localeStr, "g");
7979
this.#engRegex = new RegExp(engStr, "g");
8080
}
81-
//initialise the model by the existing value entered in the widget (in case data was entered before initialisation)
82-
this.#model.value = this.getValue(this.#widget.value);
81+
8382
// change the input type to text for patterns
8483
this.#widget.setAttribute("type", "text");
8584
this.#attachEventHandlers(widget);

ui.tests/test-module/specs/numberinput/numberinput.runtime.spec.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,53 @@ describe("Form with Number Input", () => {
251251
});
252252
})
253253

254+
describe("Form with Number Input Required Validation", () => {
255+
256+
const pagePath = "content/forms/af/core-components-it/samples/numberinput/validation.html";
257+
let formContainer = null;
258+
259+
beforeEach(() => {
260+
cy.previewForm(pagePath).then(p => {
261+
formContainer = p;
262+
});
263+
});
264+
265+
const validateRequiredMessage = (id, submitButton, errorMessage) => {
266+
cy.get(`#${submitButton}`).find("button").click();
267+
cy.get(`#${id}`).find("input").then(x => {
268+
cy.get(`#${id}`).find(".cmp-adaptiveform-numberinput__errormessage").should('have.text',errorMessage);
269+
});
270+
271+
cy.get(`#${id}`).find("input").clear().type("1234").blur().then(x => {
272+
cy.get(`#${id}`).find(".cmp-adaptiveform-numberinput__errormessage").should('have.text',"");
273+
});
274+
275+
cy.get(`#${id}`).find("input").clear().blur().then(x => {
276+
cy.get(`#${id}`).find(".cmp-adaptiveform-numberinput__errormessage").should('have.text',errorMessage);
277+
});
278+
}
279+
280+
281+
it("integer type validation for required field", () => {
282+
const [numberInput1] = Object.entries(formContainer._fields)[0];
283+
const [numberInput2] = Object.entries(formContainer._fields)[1];
284+
const [submitbutton] = Object.entries(formContainer._fields)[3];
285+
validateRequiredMessage(numberInput1, submitbutton, "This is required numberinput");
286+
validateRequiredMessage(numberInput2, submitbutton, "This is required integer numberinput");
287+
});
288+
289+
it("check value entered before model initialization", () => {
290+
const [numberInput3, numberInput3FieldView] = Object.entries(formContainer._fields)[2];
291+
const input = "1212";
292+
let model = numberInput3FieldView.getModel();
293+
expect(Number(model.getState().value)).to.equal(Number(10));
294+
295+
cy.get(`#${numberInput3}`).find("input").clear().type(input).blur().then(x => {
296+
expect(Number(model.getState().value)).to.equal(Number(input));
297+
})
298+
});
299+
})
300+
254301
describe("Form with number input and language", () => {
255302
const pagePath = "content/forms/af/core-components-it/samples/numberinput/basic.html"
256303
const bemBlock = 'cmp-adaptiveform-numberinput'

ui.tests/test-module/specs/page/pagev2.runtime.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,23 @@ describe("Form with Page component version 2", () => {
3030
cy.get("html body main form").should("exist");
3131
})
3232
})
33+
34+
describe("Form with Page component version 2 for eds rendering", () => {
35+
const pagePath = "/bin/franklin.delivery/adobe-rnd/aem-boilerplate-forms/main/content/forms/af/core-components-it/samples/page/afv2.html"
36+
beforeEach(() => {
37+
cy.openPage(pagePath);
38+
});
39+
40+
it(" form should get rendered with main tag in body and should have pre code tags ", () => {
41+
cy.get("html body main div div div pre code").should("exist");
42+
cy.get("html body main div div div pre code").then(($codeEle)=>{
43+
const encodedJson=$codeEle.get()[0].innerHTML;
44+
const formJson=JSON.parse(JSON.parse(encodedJson));
45+
expect(formJson).to.have.property("id");
46+
expect(formJson).to.have.property("fieldType");
47+
expect(formJson).to.have.property(":items");
48+
expect(formJson).to.have.property("title");
49+
50+
})
51+
})
52+
})

ui.tests/test-module/specs/recaptcha/recaptcha.runtime.spec.js

Lines changed: 29 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import 'cypress-wait-until';
1717

1818
describe("Form Runtime with Recaptcha Input", () => {
1919

20-
const FT_CLOUD_CONFIG_PROVIDER = "FT_FORMS-8771";
2120
const pagePath = "content/forms/af/core-components-it/samples/recaptcha/basic.html"
2221
const enterprisePagePath = "content/forms/af/core-components-it/samples/recaptcha/enterprisescore.html"
2322
const bemBlock = 'cmp-adaptiveform-recaptcha'
@@ -28,16 +27,6 @@ describe("Form Runtime with Recaptcha Input", () => {
2827

2928
let formContainer = null
3029

31-
let toggle_array = [];
32-
33-
before(() => {
34-
cy.fetchFeatureToggles().then((response) => {
35-
if (response.status === 200) {
36-
toggle_array = response.body.enabled;
37-
}
38-
});
39-
});
40-
4130
// Whitelist the error message
4231
cy.on('uncaught:exception', (err) => {
4332
// when we render form with captcha, and FT is not enabled, this error is expected
@@ -73,44 +62,38 @@ describe("Form Runtime with Recaptcha Input", () => {
7362
})
7463
}
7564

76-
if (toggle_array.includes(FT_CLOUD_CONFIG_PROVIDER)) {
77-
it(" should get model and view initialized properly ", () => {
78-
expect(formContainer, "formcontainer is initialized").to.not.be.null;
79-
expect(formContainer._model.items.length, "model and view elements match").to.equal(Object.keys(formContainer._fields).length);
80-
Object.entries(formContainer._fields).forEach(([id, field]) => {
81-
expect(field.getId()).to.equal(id)
82-
expect(formContainer._model.getElement(id), `model and view are in sync`).to.equal(field.getModel())
83-
});
84-
})
85-
86-
it(" model's changes are reflected in the html ", () => {
87-
const [id, fieldView] = Object.entries(formContainer._fields)[0]
88-
const model = formContainer._model.getElement(id)
89-
cy.get('#' + id + ' .cmp-adaptiveform-recaptcha__widget > div.g-recaptcha').should('exist');
90-
91-
checkHTML(model.id, model.getState()).then(() => {
92-
model.visible = false
93-
return checkHTML(model.id, model.getState())
94-
}).then(() => {
95-
model.enable = false
96-
return checkHTML(model.id, model.getState())
97-
})
65+
it(" should get model and view initialized properly ", () => {
66+
expect(formContainer, "formcontainer is initialized").to.not.be.null;
67+
expect(formContainer._model.items.length, "model and view elements match").to.equal(Object.keys(formContainer._fields).length);
68+
Object.entries(formContainer._fields).forEach(([id, field]) => {
69+
expect(field.getId()).to.equal(id)
70+
expect(formContainer._model.getElement(id), `model and view are in sync`).to.equal(field.getModel())
9871
});
72+
})
9973

100-
it(" html changes are reflected in model ", () => {
101-
const [id, fieldView] = Object.entries(formContainer._fields)[0]
102-
const model = formContainer._model.getElement(id)
74+
it(" model's changes are reflected in the html ", () => {
75+
const [id, fieldView] = Object.entries(formContainer._fields)[0]
76+
const model = formContainer._model.getElement(id)
77+
cy.get('#' + id + ' .cmp-adaptiveform-recaptcha__widget > div.g-recaptcha').should('exist');
78+
79+
checkHTML(model.id, model.getState()).then(() => {
80+
model.visible = false
81+
return checkHTML(model.id, model.getState())
82+
}).then(() => {
83+
model.enable = false
84+
return checkHTML(model.id, model.getState())
85+
})
86+
});
87+
88+
it(" html changes are reflected in model ", () => {
89+
const [id, fieldView] = Object.entries(formContainer._fields)[0]
90+
const model = formContainer._model.getElement(id)
91+
cy.log(model.getState().value)
92+
cy.get(`#${id}`).click().then(x => {
10393
cy.log(model.getState().value)
104-
cy.get(`#${id}`).click().then(x => {
105-
cy.log(model.getState().value)
106-
expect(model.getState().value).to.not.be.null
107-
})
108-
});
109-
} else {
110-
it('Feature toggle of captcha is disabled, skipping tests', () => {
111-
cy.log('Tests were skipped because the feature toggle of captcha is disabled');
112-
});
113-
}
94+
expect(model.getState().value).to.not.be.null
95+
})
96+
});
11497

11598
it("decoration element should not have same class name", () => {
11699
expect(formContainer, "formcontainer is initialized").to.not.be.null;

0 commit comments

Comments
 (0)