Skip to content

Commit 995a7b9

Browse files
authored
Merge pull request #1602 from adobe/FORMS-20243
Fix size issue on uploading the file again
2 parents 62fbdf9 + e9381e4 commit 995a7b9

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
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.frontend/src/view/FormFileInputWidgetBase.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ class FormFileInputWidgetBase {
481481

482482
// if the file is not invalid, show it and push it to internal array
483483
if (!isCurrentInvalidFileSize && !isCurrentInvalidFileName && !isCurrentInvalidMimeType) {
484-
this.showFileList(currFileName);
485484
if(this.isMultiSelect()) {
486485
this.values.push(currFileName);
487486
this.fileArr.push(file);

ui.tests/test-module/specs/fileinput/fileinputv3.runtime.cy.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,13 @@ describe('Click on button tag (V-3)', () => {
248248
expect(alertText).to.equal(model.getState().constraintMessages.maxFileSize);
249249
});
250250
});
251+
252+
it('file when uploaded again should give actual size', () => {
253+
let sampleFileNames = ['sample.svg'];
254+
const fileInput = "input[name='fileinput2']";
255+
cy.attachFile(fileInput, [sampleFileNames[0]]);
256+
cy.get('.cmp-adaptiveform-fileinput__filesize').should('contain.text', '508 bytes');
257+
cy.attachFile(fileInput, [sampleFileNames[0]]);
258+
cy.get('.cmp-adaptiveform-fileinput__filesize').should('contain.text', '508 bytes');
259+
})
251260
})

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)