Skip to content

Commit e9381e4

Browse files
Pavitra KhatriPavitra Khatri
authored andcommitted
Add prefill test case
1 parent d9cc699 commit e9381e4

File tree

2 files changed

+21
-2
lines changed
  • it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/prefill/basic
  • ui.tests/test-module/specs/prefill

2 files changed

+21
-2
lines changed

it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/prefill/basic/.content.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@
8484
type="string"
8585
typeIndex="0"
8686
visible="{Boolean}true"/>
87+
<fileinput
88+
fd:dragDropText="Drag and drop to Upload"
89+
jcr:created="{Date}2025-06-04T15:37:31.303+05:30"
90+
jcr:createdBy="admin"
91+
jcr:lastModified="{Date}2025-06-04T15:37:31.303+05:30"
92+
jcr:lastModifiedBy="admin"
93+
jcr:primaryType="nt:unstructured"
94+
jcr:title="File Attachment"
95+
sling:resourceType="forms-components-examples/components/form/fileinput"
96+
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
97+
buttonText="Attach"
98+
fieldType="file-input"
99+
name="fileinput1749031651340"/>
87100
<button
88101
jcr:lastModified="{Date}2022-12-13T15:44:11.564+05:30"
89102
jcr:lastModifiedBy="admin"

ui.tests/test-module/specs/prefill/customprefill.cy.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('Custom Prefill Test', function () {
2828
dobDropdown = "input[name='dob']",
2929
jobDropdown = "select[name='job']";
3030
let genderRadioButton = "input[name='radiobutton-c8c660bac8_gender']";
31+
let fileAttachment = "input[name='fileinput1749031651340']";
3132
let formContainer = null;
3233

3334
beforeEach(() => {
@@ -61,11 +62,13 @@ describe('Custom Prefill Test', function () {
6162
}
6263
cy.get(genderRadioButton).should("have.value", "0");
6364
cy.get(jobDropdown).should("have.value", "1");
65+
cy.get('.cmp-adaptiveform-fileinput__fileitem') .should('exist');
6466
}
6567

6668
}
6769

6870
it('', function() {
71+
let sampleFileNames = ['sample.txt'];
6972
if (cy.af.isOldCoreComponent()) {
7073
genderRadioButton = "input[name='gender']"; // was added due to enhancement in repeatibility of radio buttons in core components
7174
}
@@ -74,10 +77,11 @@ describe('Custom Prefill Test', function () {
7477
cy.get(dobDropdown).type("1999-10-10");
7578
cy.get(genderRadioButton).first().check();
7679
cy.get(jobDropdown).select('Working');
80+
cy.attachFile(fileAttachment,[sampleFileNames[0]]);
7781

7882
// submitting the form and fetching the prefillID
7983
let prefillId;
80-
cy.get("button").click();
84+
cy.get("button").eq(2).click();
8185

8286
cy.wait('@afSubmission').then(({response}) => {
8387
expect(response.statusCode).to.equal(200);
@@ -91,6 +95,7 @@ describe('Custom Prefill Test', function () {
9195
});
9296

9397
it('prefill using service in dataRef', function() {
98+
let sampleFileNames = ['sample2.txt'];
9499
if (cy.af.isOldCoreComponent()) {
95100
genderRadioButton = "input[name='gender']"; // was added due to enhancement in repeatibility of radio buttons in core components
96101
}
@@ -99,10 +104,11 @@ describe('Custom Prefill Test', function () {
99104
cy.get(dobDropdown).type("1999-10-10");
100105
cy.get(genderRadioButton).first().check();
101106
cy.get(jobDropdown).select('Working');
107+
cy.attachFile(fileAttachment,[sampleFileNames[0]]);
102108

103109
// submitting the form and fetching the prefillID
104110
let prefillId;
105-
cy.get("button").click();
111+
cy.get("button").eq(2).click();
106112

107113
cy.wait('@afSubmission').then(({response}) => {
108114
prefillId = response.body.metadata.prefillId;

0 commit comments

Comments
 (0)