disable "go to payment button" on click (ECOM-643)

This commit is contained in:
Adam Palay
2014-11-12 14:52:27 -05:00
parent 559f1e194e
commit bc8d0a9976
5 changed files with 33 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ define(['backbone', 'jquery', 'js/verify_student/photocapture'],
describe("Photo Verification", function () {
beforeEach(function () {
setFixtures('<div id="order-error" style="display: none;"></div><input type="radio" name="contribution" value="35" id="contribution-35" checked="checked"><input type="radio" id="contribution-other" name="contribution" value=""><input type="text" size="9" name="contribution-other-amt" id="contribution-other-amt" value="30"><img id="face_image" src="src="data:image/png;base64,dummy"><img id="photo_id_image" src="src="data:image/png;base64,dummy">');
setFixtures('<div id="order-error" style="display: none;"></div><input type="radio" name="contribution" value="35" id="contribution-35" checked="checked"><input type="radio" id="contribution-other" name="contribution" value=""><input type="text" size="9" name="contribution-other-amt" id="contribution-other-amt" value="30"><img id="face_image" src="src="data:image/png;base64,dummy"><img id="photo_id_image" src="src="data:image/png;base64,dummy"><button id="pay_button">pay button</button>');
});
it('retake photo', function () {
@@ -27,6 +27,7 @@ define(['backbone', 'jquery', 'js/verify_student/photocapture'],
});
submitToPaymentProcessing();
expect(window.submitForm).toHaveBeenCalled();
expect($("#pay_button")).toHaveClass("is-disabled");
});
it('Error during process', function () {
@@ -36,8 +37,18 @@ define(['backbone', 'jquery', 'js/verify_student/photocapture'],
spyOn($, "ajax").andCallFake(function (e) {
e.error({});
});
spyOn($.fn, "addClass").andCallThrough();
spyOn($.fn, "removeClass").andCallThrough();
submitToPaymentProcessing();
expect(window.showSubmissionError).toHaveBeenCalled();
// make sure the button isn't disabled
expect($("#pay_button")).not.toHaveClass("is-disabled");
// but also make sure that it was disabled during the ajax call
expect($.fn.addClass).toHaveBeenCalledWith("is-disabled");
expect($.fn.removeClass).toHaveBeenCalledWith("is-disabled");
});
});

View File

@@ -69,6 +69,7 @@ function refereshPageMessage() {
}
var submitToPaymentProcessing = function() {
$("#pay_button").addClass('is-disabled');
var contribution_input = $("input[name='contribution']:checked")
var contribution = 0;
if(contribution_input.attr('id') == 'contribution-other') {
@@ -95,6 +96,7 @@ var submitToPaymentProcessing = function() {
}
},
error:function(xhr,status,error) {
$("#pay_button").removeClass('is-disabled');
showSubmissionError()
}
});