Skip to content

Commit 252a0a6

Browse files
feat(FileExtensionSupport): add support for custom file extensions test cases
1 parent 1f87566 commit 252a0a6

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787
textIsRich="[true,true]"
8888
type="file[]"
8989
visible="{Boolean}true"/>
90+
<fileinput6
91+
jcr:primaryType="nt:unstructured"
92+
jcr:title="File Input - 6"
93+
sling:resourceType="core/fd/components/form/fileinput/v2/fileinput"
94+
accept="[audio/*, video/*, image/*, text/*, application/pdf,.ifc]"
95+
fieldType="file-input"
96+
readOnly="{Boolean}false"
97+
name="fileinput6"
98+
type="file"/>
9099
<submit
91100
jcr:lastModified="{Date}2023-01-17T16:28:58.844+05:30"
92101
jcr:lastModifiedBy="admin"

ui.tests/test-module/libs/fixtures/sample.afe

Whitespace-only changes.

ui.tests/test-module/libs/fixtures/sample.ifc

Whitespace-only changes.

ui.tests/test-module/libs/support/commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ const mimeTypes = {
769769
'bat': 'application/x-msdos-program',
770770
'msg': 'application/vnd.ms-outlook',
771771
'svg': 'image/svg+xml',
772+
'ifc': 'model/ifc',
772773
// Add more mappings as needed
773774
};
774775

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,23 @@ describe("Form with File Input V-2 - Basic Tests", () => {
250250
cy.get(fileInput5).should("have.attr", "disabled", "disabled");
251251
});
252252

253+
it(`file input should not support extenstion which are not in accept property`, () => {
254+
const fileInput6 = "input[name='fileinput6']";
255+
cy.attachFile(fileInput6, ['sample.afe']);
256+
cy.get('.cmp-adaptiveform-fileinput__filelist')
257+
.children()
258+
.should('have.length', 0);
259+
});
260+
261+
it(`fileinput should support custom file extensions`, () => {
262+
const fileInput6 = "input[name='fileinput6']";
263+
cy.attachFile(fileInput6, ['sample.ifc']);
264+
cy.get('.cmp-adaptiveform-fileinput__filelist')
265+
.children()
266+
.should('have.length', 1)
267+
.and('contain.text', 'sample.ifc');
268+
});
269+
253270
})
254271

255272
describe("V-2 drag and drop functionality", () => {

0 commit comments

Comments
 (0)