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

ComboPopup: Fix cancel button's handler. #682

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Combobox/ComboPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ define([
* @protected
*/
okHandler: function () {
this.combobox._validateMultiple(this.combobox.inputNode);
// NOTE: no need to validate since it's handled by the `selection-change` listener
this.combobox.closeDropDown();
},

Expand All @@ -76,7 +76,11 @@ define([
* @protected
*/
cancelHandler: function () {
// INFO: resetting any selected items.
this.combobox.list.selectedItems = [];
this.combobox.closeDropDown();
// cont: then ask to validate, so widget's value and inputNode get updated as well.
this.combobox._validateMultiple(true);
},

/**
Expand Down
42 changes: 35 additions & 7 deletions tests/functional/ComboPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ define([
.end();
};

var checkMultiSelection = function (remote, comboId) {
var checkMultiSelection = function (remote, comboId, pressOkButton) {
var executeExpr = "return getComboState(\"" + comboId + "\");";
return loadFile(remote, "./ComboPopup.html")
.findById(comboId)
Expand Down Expand Up @@ -342,7 +342,7 @@ define([
.end()
.findById(comboId + "_item1") // "Germany"
.click()
.sleep(500) // wait for popup to close
.sleep(500)
.execute(executeExpr)
.then(function (comboState) {
checkComboState(comboId, comboState,
Expand Down Expand Up @@ -384,12 +384,12 @@ define([
}, "after clicking option (China))");
})
.end()
.findByCssSelector(".d-combo-ok-button")
.findByCssSelector(pressOkButton ? ".d-combo-ok-button" : ".d-combo-cancel-button")
.click()
.sleep(500) // wait for the async closing of the popup
.execute(executeExpr)
.then(function (comboState) {
checkComboState(comboId, comboState,
checkComboState(comboId, comboState, pressOkButton ?
{ // expected combo state
inputNodeValue: string.substitute(comboState.multipleChoiceMsg, {items: 2}),
widgetValue: ["China", "Germany"],
Expand All @@ -403,7 +403,20 @@ define([
valueNodeValueAtLatestInputEvent: "China,Germany",
widgetValueAtLatestChangeEvent: ["China", "Germany"],
valueNodeValueAtLatestChangeEvent: "China,Germany"
}, "after clicking again the root node (close)");
} : { // expected combo state
inputNodeValue: comboState.multipleChoiceNoSelectionMsg,
widgetValue: [],
valueNodeValue: "",
opened: false,
selectedItemsCount: 0,
itemRenderersCount: 37,
inputEventCounter: 1,
changeEventCounter: 1, // incremented
widgetValueAtLatestInputEvent: [],
valueNodeValueAtLatestInputEvent: "",
widgetValueAtLatestChangeEvent: [],
valueNodeValueAtLatestChangeEvent: ""
}, "after clicking on the " + pressOkButton ? 'Ok' : "cancel" + " button (close)");
})
.end();
};
Expand Down Expand Up @@ -555,7 +568,22 @@ define([
return checkSingleSelection(remote, "combo2");
},

"multi selection selection (combo3)": function () {
"multi selection, press ok button (combo3)": function () {
var remote = this.remote;

if (remote.environmentType.browserName === "internet explorer") {
// https://github.com/theintern/leadfoot/issues/17
return this.skip("click() doesn't generate mousedown/mouseup, so popup won't open");
}
if (remote.environmentType.platformName === "iOS") {
// https://github.com/theintern/leadfoot/issues/61
return this.skip("click() doesn't generate touchstart/touchend, so popup won't open");
}

return checkMultiSelection(remote, "combo3", true);
},

"multi selection, press cancel button (combo3)": function () {
var remote = this.remote;

if (remote.environmentType.browserName === "internet explorer") {
Expand All @@ -567,7 +595,7 @@ define([
return this.skip("click() doesn't generate touchstart/touchend, so popup won't open");
}

return checkMultiSelection(remote, "combo3");
return checkMultiSelection(remote, "combo3", false);
},

"tab navigation (combo3)": function () {
Expand Down