Skip to content

Commit

Permalink
Forms 11746 allow attaching same file (#1201)
Browse files Browse the repository at this point in the history
* updated code for ui.frontend with test cases

* resolved PR comments

* test case fixed

---------

Co-authored-by: Gulshan Mishra <gulshanm@adobe.com>
Co-authored-by: Rajat Khurana <rajatkhurana@adobe.com>
  • Loading branch information
3 people authored and ci-build committed May 3, 2024
1 parent 6189774 commit 9313bbe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui.frontend/src/view/FormFileInputWidget.js
Expand Up @@ -472,6 +472,7 @@ class FormFileInputWidget {
this.showInvalidMessage(inValidMimeTypefileNames.substring(0, inValidMimeTypefileNames.lastIndexOf(',')), this.invalidFeature.MIMETYPE);
}
}
this.widget.value = null;
}
}

Expand Down
19 changes: 19 additions & 0 deletions ui.tests/test-module/specs/fileinput/fileinput.runtime.spec.js
Expand Up @@ -108,6 +108,25 @@ describe("Form with File Input - Basic Tests", () => {
checkHTML(id, field.getModel().getState())
});
})
it(" after attaching the file widget value is reset to allow duplicate file ", () => {
const sampleFileName = 'sample2.txt', fileInput = "input[name='fileinput1']";
cy.get(fileInput).should('have.value', "");
cy.get(fileInput).attachFile(sampleFileName).then(() => {
cy.get(".cmp-adaptiveform-fileinput__filename").contains(sampleFileName);
cy.get(fileInput).should(($element) => {
const actualValue = $element.val();
expect(actualValue.includes("")).to.be.true;
})
});
// attaching the same file again to check duplicate file attachment
cy.get(fileInput).attachFile(sampleFileName).then(() => {
cy.get(".cmp-adaptiveform-fileinput__filename").should('have.length', 2);
cy.get(fileInput).should(($element) => {
const actualValue = $element.val();
expect(actualValue.includes("")).to.be.true;
})
});
});

it(" model's changes are reflected in the html ", () => {
Object.entries(formContainer._fields).forEach(([id, field]) => {
Expand Down

0 comments on commit 9313bbe

Please sign in to comment.