sponsorship: Ensure that all the fields are filled in form.

This commit is contained in:
Vishnu KS 2020-07-31 20:25:55 +05:30 committed by Tim Abbott
parent 69e0625a09
commit e736bc3ec6
3 changed files with 12 additions and 4 deletions

View File

@ -37,7 +37,9 @@ run_test("initialize", () => {
assert.equal(page_name, "upgrade"); assert.equal(page_name, "upgrade");
}; };
let create_ajax_request_form_call_count = 0;
helpers.create_ajax_request = (url, form_name, stripe_token, numeric_inputs, redirect_to) => { helpers.create_ajax_request = (url, form_name, stripe_token, numeric_inputs, redirect_to) => {
create_ajax_request_form_call_count += 1;
if (form_name === "autopay") { if (form_name === "autopay") {
assert.equal(url, "/json/billing/upgrade"); assert.equal(url, "/json/billing/upgrade");
assert.equal(stripe_token, "stripe_add_card_token"); assert.equal(stripe_token, "stripe_add_card_token");
@ -111,15 +113,18 @@ run_test("initialize", () => {
const request_sponsorship_click_handler = $("#sponsorship-button").get_on_handler("click"); const request_sponsorship_click_handler = $("#sponsorship-button").get_on_handler("click");
helpers.is_valid_input = () => true; helpers.is_valid_input = () => true;
add_card_click_handler(e); add_card_click_handler(e);
assert.equal(create_ajax_request_form_call_count, 1);
invoice_click_handler(e); invoice_click_handler(e);
assert.equal(create_ajax_request_form_call_count, 2);
request_sponsorship_click_handler(e);
assert.equal(create_ajax_request_form_call_count, 3);
helpers.is_valid_input = () => false; helpers.is_valid_input = () => false;
add_card_click_handler(e); add_card_click_handler(e);
invoice_click_handler(e); invoice_click_handler(e);
request_sponsorship_click_handler(e); request_sponsorship_click_handler(e);
assert.equal(create_ajax_request_form_call_count, 3);
helpers.show_license_section = (section) => { helpers.show_license_section = (section) => {
assert.equal(section, "manual"); assert.equal(section, "manual");

View File

@ -40,6 +40,9 @@ exports.initialize = () => {
}); });
$("#sponsorship-button").on("click", (e) => { $("#sponsorship-button").on("click", (e) => {
if (!helpers.is_valid_input($("#sponsorship-form"))) {
return;
}
e.preventDefault(); e.preventDefault();
helpers.create_ajax_request( helpers.create_ajax_request(
"/json/billing/sponsorship", "/json/billing/sponsorship",

View File

@ -223,8 +223,8 @@
<label> <label>
<h4>Organization type</h4> <h4>Organization type</h4>
</label> </label>
<select name="organization-type" required style="width: 100%;"> <select name="organization-type" required style="width: 100%;" required>
<option disabled selected> -- select --</option> <option disabled selected value=""> -- select --</option>
<option value="open_source">{{_('Open source')}}</option> <option value="open_source">{{_('Open source')}}</option>
<option value="research">{{_('Academic research')}}</option> <option value="research">{{_('Academic research')}}</option>
<option value="education">{{_('Education')}}</option> <option value="education">{{_('Education')}}</option>