-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read-only is not working in file-attachment #1200
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,20 @@ | |
return this.element.querySelector(FileInputV2.selectors.attachButtonLabel); | ||
} | ||
|
||
updateEnabled(enabled, state) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Always try to create a constant inside the if condition to make the code more readable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, implemented the same |
||
if (this.widget) { | ||
this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled); | ||
const isDisabled = !enabled || state.readOnly; | ||
if (isDisabled) { | ||
this.widget.setAttribute("disabled", "disabled"); | ||
this.widget.setAttribute(FormView.Constants.ARIA_DISABLED, true); | ||
} else { | ||
this.widget.removeAttribute("disabled"); | ||
this.widget.removeAttribute(FormView.Constants.ARIA_DISABLED); | ||
} | ||
} | ||
} | ||
|
||
updateValue(value) { | ||
if (this.widgetObject == null) { | ||
this.widgetObject = new FileInputWidget(this.widgetFields); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ describe("Form with File Input - Basic Tests", () => { | |
const checkHTML = (id, state) => { | ||
const visible = state.visible; | ||
const passVisibleCheck = `${visible === true ? "" : "not."}be.visible`; | ||
const passDisabledAttributeCheck = `${state.enabled === false ? "" : "not."}have.attr`; | ||
const passDisabledAttributeCheck = `${state.enabled === false || state.readOnly === true ? "" : "not."}have.attr`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed in the scrum, can you please add the same check in all the test specs for all the components ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure Rishi, Will be adding the test cases in the next pr which I am working on for tnc component |
||
const value = (state.value == null ? '' : (Array.isArray(state.value) ? state.value[0].name : state.value.name)); // check for file name in dom | ||
cy.get(`#${id}`) | ||
.should(passVisibleCheck) | ||
|
@@ -138,7 +138,12 @@ describe("Form with File Input - Basic Tests", () => { | |
if (model.visible && model.enabled) { | ||
cy.get(`#${id}`).should('have.class', 'cmp-adaptiveform-fileinput--empty'); | ||
cy.get(`#${id}`).invoke('attr', 'data-cmp-required').should('eq', 'false'); | ||
cy.get(`#${id}`).invoke('attr', 'data-cmp-readonly').should('eq', 'false'); | ||
if(model.readOnly) { | ||
cy.get(`#${id}`).should('have.attr', 'data-cmp-readonly', 'true'); | ||
} else { | ||
cy.get(`#${id}`).should('have.attr', 'data-cmp-readonly', 'false'); | ||
} | ||
//cy.get(`#${id}`).invoke('attr', 'data-cmp-readonly').should('eq', 'false'); | ||
cy.get(`#${id}`).find("input").attachFile(fileName).then(x => { | ||
let expectedFileName = Array.isArray(model.getState().value) ? model.getState().value[0].name : model.getState().value.name; | ||
expect(expectedFileName).to.equal(fileName) | ||
|
@@ -148,7 +153,7 @@ describe("Form with File Input - Basic Tests", () => { | |
} | ||
} | ||
}); | ||
getFormObjTest(['empty.pdf', 'empty.pdf', 'empty.pdf', 'empty.pdf']) | ||
getFormObjTest(['empty.pdf', 'empty.pdf', 'empty.pdf', 'empty.pdf', 'empty.pdf']) | ||
}); | ||
|
||
it("should toggle description and tooltip", () => { | ||
|
@@ -177,6 +182,11 @@ describe("Form with File Input - Basic Tests", () => { | |
cy.get(".cmp-adaptiveform-fileinput__widgetlabel").should('have.attr', 'role', 'button'); | ||
}) | ||
|
||
it(`fielinput is disabled when readonly property is true`, () => { | ||
const fileInput5 = "input[name='fileinput5']"; | ||
cy.get(fileInput5).should("have.attr", "disabled", "disabled"); | ||
}); | ||
|
||
}) | ||
|
||
describe("Form with File Input - Prefill & Submit tests", () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this code removed ? Isn't this backward incompatible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was adding aria-disabled attribute to the parent div which is of no use, so I had removed this line.