Skip to content
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

FORMS-14013 - Testcase added - Fixing Dropdown that had a selected value without default/placeholder set #1203

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
data-sly-attribute.multiple="${dropdown.isMultiSelect ? 'multiple' : ''}"
aria-readonly="${dropdown.readOnly ? 'true' : ''}">
<div data-sly-test.isPlaceHolderSet="${dropdown.placeHolder != null}" data-sly-unwrap></div>
<option data-sly-test="${!isPlaceHolderSet}" style="display: none;"></option>
<option data-sly-test="${!isPlaceHolderSet}" disabled selected></option>
<option data-sly-test="${isPlaceHolderSet}" value="" disabled selected>${dropdown.placeHolder}</option>
<div data-sly-list.enumName="${dropdown.enumNames}" data-sly-unwrap>
<div data-sly-test="${enumName != null && dropdown.enums[enumNameList.index] != null}" data-sly-unwrap>
Expand Down
13 changes: 13 additions & 0 deletions ui.tests/test-module/specs/dropdown/dropdown.runtime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,17 @@ describe("Form with Dropdown", () => {
cy.get(`#${id}`).should('have.class', 'cmp-adaptiveform-dropdown--filled');
});
});

it("should have empty placeholder checked when default option is not configured", () => {
const [idDropdown, fieldView1] = Object.entries(formContainer._fields)[9];
const model = formContainer._model.getElement(idDropdown);
cy.get(`#${idDropdown} select`).invoke('val').then(val => {
expect(val, "Actual value of unselected dropdown").to.equal(null);
})
cy.get(`#${idDropdown} select`).find('option').then(options => {
expect(options[0].selected, "Empty Placeholder to be selected").to.be.true
expect(options[0].disabled, "Empty Placeholder to be disabled").to.be.true
expect(options[0].value, "Empty Placeholder to be empty in it's visual content").to.equal('')
});
});
})