Skip to content

Commit

Permalink
Merge pull request #1406 from adobe/devMaster17Sep
Browse files Browse the repository at this point in the history
Dev master17 sep
  • Loading branch information
rismehta authored Sep 17, 2024
2 parents 2f9aff9 + bcffd89 commit d824333
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
name="fileinput5"
readOnly="{Boolean}true"
textIsRich="[true,true]"
maxFileSize="2"
type="file[]"
visible="{Boolean}true"/>
<submit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@
this.widget.forEach(widget => {
if (selectedWidgetValues.includes((widget.value))) {
widget.checked = true
widget.setAttribute(FormView.Constants.HTML_ATTRS.CHECKED, FormView.Constants.HTML_ATTRS.CHECKED)
widget.setAttribute(FormView.Constants.ARIA_CHECKED, true)
widget.setAttribute(FormView.Constants.HTML_ATTRS.CHECKED, FormView.Constants.HTML_ATTRS.CHECKED);
} else {
widget.checked = false
widget.removeAttribute(FormView.Constants.HTML_ATTRS.CHECKED);
widget.setAttribute(FormView.Constants.ARIA_CHECKED, false);
}
}, this)
super.updateEmptyStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,9 @@
if (modelValue != null && widget.value != null && (modelValue.toString() == widget.value.toString())) {
widget.checked = true;
widget.setAttribute(FormView.Constants.HTML_ATTRS.CHECKED, FormView.Constants.HTML_ATTRS.CHECKED);
widget.setAttribute(FormView.Constants.ARIA_CHECKED, true);
} else {
widget.checked = false;
widget.removeAttribute(FormView.Constants.HTML_ATTRS.CHECKED);
widget.setAttribute(FormView.Constants.ARIA_CHECKED, false);
}
}, this)
super.updateEmptyStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@
<sly data-sly-test.formLocaleString="${form.locale || 'en'}"/>
<iframe title="${form.title}"
role="${form.roleAttribute || ''}"
data-sly-set.dataRef="?${['dataRef=', request.requestParameterMap['dataRef'][0].toString] @ join=''}"
class="cmp-aemform__iframecontent"
src="${request.contextPath}${resource.path}.iframe.${formLocaleString}.html?dataRef=${request.requestParameterMap['dataRef'] != null ? request.requestParameterMap['dataRef'][0].toString : '' @ context='attribute'}${!wcmmode.edit ? '&wcmmode={0}':'' @ format=[wcmmode.toString]}"
src="${request.contextPath}${resource.path}.iframe.${formLocaleString}.html${request.requestParameterMap['dataRef'] != null ? dataRef : '' @ context='attribute'}"
width="100%;"
width="100%;"
data-form-page-path="${form.formEditPagePath}"></iframe>
<sly data-sly-test="${form.useIframe != 'false' && form.height == 'auto'}"
Expand Down
2 changes: 1 addition & 1 deletion ui.frontend/src/LanguageUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class LanguageUtils {
translatedText = this.#langData[lang][key];
if (snippets) {
//resolve message with snippet
translatedText = translatedText.replace(/{(\d+)}/g, function (match, number) {
translatedText = translatedText.replace(/\${(\d+)}/g, function (match, number) {
return typeof snippets[number] != 'undefined'
? snippets[number]
: match;
Expand Down
2 changes: 0 additions & 2 deletions ui.frontend/src/view/FormCheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ class FormCheckBox extends FormFieldBase {
if (modelValue === this._model._jsonModel.enum[0]) {
this.widget.checked = true
this.widget.setAttribute(FormView.Constants.HTML_ATTRS.CHECKED, FormView.Constants.HTML_ATTRS.CHECKED)
this.widget.setAttribute(FormView.Constants.ARIA_CHECKED, true);
} else {
this.widget.checked = false
this.widget.removeAttribute(FormView.Constants.HTML_ATTRS.CHECKED);
this.widget.setAttribute(FormView.Constants.ARIA_CHECKED, false);
}
this.widget.value = modelValue;
super.updateEmptyStatus();
Expand Down
4 changes: 2 additions & 2 deletions ui.frontend/src/view/FormFieldBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ class FormFieldBase extends FormField {
let widgetElement = typeof this.getWidget === 'function' ? this.getWidget() : null;
let widgetElements = typeof this.getWidgets === 'function' ? this.getWidgets() : null;
widgetElement = widgetElements || widgetElement;
const model = this.getModel?.();
const model = this.getModel?.();

if (widgetElement && model?.screenReaderText) {
if (widgetElement && model?.screenReaderText && model?.enabled) {
// Use DOMPurify to sanitize and strip HTML tags
const screenReaderText = window.DOMPurify ? window.DOMPurify.sanitize(model.screenReaderText, { ALLOWED_TAGS: [] }) : model.screenReaderText;
widgetElement.setAttribute('aria-label', screenReaderText);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe("Sites with Aem Embed Container", () => {
cy.get('.cmp-adaptiveform-container').should('have.length', 1);
cy.get('.cmp-adaptiveform-container').find('.cmp-adaptiveform-textinput__widget').should('have.length', 11);
})

it('Test iframe src with dataRef', () => {
cy.get('.cmp-aemform__iframecontent').should('have.attr', 'src').should('not.include', "wcmmode");
});
})

context('aem embed container in iframe mode with custom height ', function () {
Expand Down Expand Up @@ -124,5 +128,6 @@ describe("Sites with Aem Embed Container", () => {
expect(fragmentTextInputModel.getState().value).to.equal(input)
})
})

})
})
1 change: 1 addition & 0 deletions ui.tests/test-module/specs/checkbox/checkbox.runtime.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ describe("Form Runtime with CheckBox Input", () => {
cy.get(`#${id}`).find(".cmp-adaptiveform-checkbox__errormessage").should('have.text',"This is a custom required checkbox")
cy.get(`#${id} > div.${bemBlock}__errormessage`).should('have.attr', 'id', `${id}__errormessage`)
cy.get(`#${id} > .${bemBlock}__widget-container > .${bemBlock}__widget`).should('have.attr', 'aria-describedby', `${id}__errormessage`)
cy.get(`#${id} > .${bemBlock}__widget-container > .${bemBlock}__widget`).should('not.have.attr', 'aria-checked')
cy.get(`#${id} > .${bemBlock}__widget-container > .${bemBlock}__widget`).should('have.attr', 'aria-invalid', 'true')
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ describe("Form Runtime with CheckBoxGroup Input", () => {
cy.get(`#${checkBox5}`).find("input").uncheck().check(["1"])
cy.get(`#${checkBox5}`).find(".cmp-adaptiveform-checkboxgroup__errormessage").should('have.text',"Please enter a valid value.")
cy.get(`#${checkBox5}`).should('have.attr', 'data-cmp-valid', 'false')
cy.get(`#${checkBox5}`).find(".cmp-adaptiveform-checkboxgroup__widget").should('not.have.attr', 'aria-checked')
cy.get(`#${checkBox5}`).find(".cmp-adaptiveform-checkboxgroup__widget").should('have.attr', 'aria-describedby', `${checkBox5}__errormessage`)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe("Form with File Input - Prefill & Submit tests", () => {

if (idx === 0) {
cy.on('window:alert', (str) => {
expect(str).to.equal('File(s) $test.bat are unsupported file types');
expect(str).to.equal('File(s) test.bat are unsupported file types');
});
} else {
// check for successful attachment of file in the view
Expand Down
18 changes: 17 additions & 1 deletion ui.tests/test-module/specs/fileinput/fileinputv3.runtime.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,23 @@ describe('Click on button tag (V-3)', () => {
cy.get(`#${id} > .${bemBlock}__container > .${bemBlock}__dragarea > .${bemBlock}__widgetlabel`).should('exist').click().then(() => {
cy.attachFile(`#${id} input[type="file"]`, [sampleFileName]).then(() => {
cy.get('.cmp-adaptiveform-fileinput__filename').should('contain', sampleFileName);
});
});
});
it('should display an alert if the file size exceeds the maximum allowed size', () => {
// Define the maximum file size (in bytes, e.g., 2MB)
const maxFileSize = 2 * 1024 * 1024; // 2MB

// Set up a stub for the alert message
const expectedAlertMessage = `File(s) FileAttachment3mb.jpg are greater than the expected size: ${maxFileSize / (1024 * 1024)}MBMB.`;

const fileInput = 'input[name=\'fileinput5\']';
cy.attachFile(fileInput, ['FileAttachment3mb.jpg']);

// Stub the window alert function
cy.on('window:alert', (alertText) => {
expect(alertText).to.equal(expectedAlertMessage);
});

});
});
})
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe("Form with Radio Button Input", () => {
cy.get(`#${id}`).find(".cmp-adaptiveform-radiobutton__errormessage").should('have.text',"");
cy.get(`#${id}`).should('have.attr', 'data-cmp-valid', 'true')
cy.get(`#${id}`).find(".cmp-adaptiveform-radiobutton__option__widget").should('have.attr', 'aria-invalid', 'false');
cy.get(`#${id}`).find(".cmp-adaptiveform-radiobutton__option__widget").should('not.have.attr', 'aria-checked');
cy.get(`#${id}`).find(".cmp-adaptiveform-radiobutton__widget").should('have.attr', 'aria-describedby', '');
});
});
Expand Down

0 comments on commit d824333

Please sign in to comment.