Skip to content

Commit dd06aed

Browse files
authored
ENGCOM-8287: [BUG] Admin order create validate vat confirm box #29466
2 parents f7759d8 + ea905c2 commit dd06aed

File tree

2 files changed

+29
-7
lines changed
  • app/code/Magento/Sales/view/adminhtml/web/order/create
  • dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/order/create

2 files changed

+29
-7
lines changed

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,12 +1507,17 @@ define([
15071507
if (action === 'change') {
15081508
var confirmText = message.replace(/%s/, customerGroupOption.text);
15091509
confirmText = confirmText.replace(/%s/, currentCustomerGroupTitle);
1510-
if (confirm(confirmText)) {
1511-
$$('#' + groupIdHtmlId + ' option').each(function (o) {
1512-
o.selected = o.readAttribute('value') == groupId;
1513-
});
1514-
this.accountGroupChange();
1515-
}
1510+
confirm({
1511+
content: confirmText,
1512+
actions: {
1513+
confirm: function() {
1514+
$$('#' + groupIdHtmlId + ' option').each(function (o) {
1515+
o.selected = o.readAttribute('value') == groupId;
1516+
});
1517+
this.accountGroupChange();
1518+
}.bind(this)
1519+
}
1520+
})
15161521
} else if (action === 'inform') {
15171522
alert({
15181523
content: message + '\n' + groupMessage

dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/order/create/scripts.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ define([
1414
var formEl,
1515
jQueryAjax,
1616
order,
17+
confirmSpy = jasmine.createSpy('confirm'),
1718
tmpl = '<form id="edit_form" action="/">' +
1819
'<section id="order-methods">' +
1920
'<div id="order-billing_method"></div>' +
@@ -129,7 +130,7 @@ define([
129130
mocks = {
130131
'jquery': $,
131132
'Magento_Catalog/catalog/product/composite/configure': jasmine.createSpy(),
132-
'Magento_Ui/js/modal/confirm': jasmine.createSpy(),
133+
'Magento_Ui/js/modal/confirm': confirmSpy,
133134
'Magento_Ui/js/modal/alert': jasmine.createSpy(),
134135
'Magento_Ui/js/lib/view/utils/async': jasmine.createSpy()
135136
};
@@ -159,6 +160,22 @@ define([
159160
jQueryAjax = undefined;
160161
});
161162

163+
describe('Testing the process customer group change', function () {
164+
it('and confirm method is called', function () {
165+
init();
166+
spyOn(window, '$$').and.returnValue(['testing']);
167+
order.processCustomerGroupChange(
168+
1,
169+
'testMsg',
170+
'customerGroupMsg',
171+
'errorMsg',
172+
1,
173+
'change'
174+
);
175+
expect(confirmSpy).toHaveBeenCalledTimes(1);
176+
});
177+
});
178+
162179
describe('submit()', function () {
163180
function testSubmit(currentPaymentMethod, paymentMethod, ajaxParams) {
164181
$.ajax = jasmine.createSpy('$.ajax');

0 commit comments

Comments
 (0)