diff --git a/ee/app/views/trials/new.html.haml b/ee/app/views/trials/new.html.haml index 2e78a9090e80daec1cb0a9def4e4226994902aaf..8bc98fb9eaf6a18ad3e4bba1b81a8eaf2eb33a19 100644 --- a/ee/app/views/trials/new.html.haml +++ b/ee/app/views/trials/new.html.haml @@ -20,7 +20,7 @@ = text_field_tag :phone_number, params[:phone_number], class: 'form-control', required: true .form-group = label_tag :number_of_users, _('How many users will be evaluating the trial?'), for: :number_of_users, class: 'col-form-label' - = number_field_tag :number_of_users, nil, class: 'form-control', required: true + = number_field_tag :number_of_users, nil, class: 'form-control', required: true, min: 1 .form-group = label_tag :country, _('Country'), class: 'col-form-label' = select_tag :country, options_for_select([[_('Please select a country'), '']]), class: 'select2', required: true, id: 'country_select', data: { countries_end_point: countries_path } diff --git a/ee/changelogs/unreleased/vslobodin-restrict-number-of-users-field-for-trials.yml b/ee/changelogs/unreleased/vslobodin-restrict-number-of-users-field-for-trials.yml new file mode 100644 index 0000000000000000000000000000000000000000..4c96057b04eb1e2b9d458313476cc7040b981067 --- /dev/null +++ b/ee/changelogs/unreleased/vslobodin-restrict-number-of-users-field-for-trials.yml @@ -0,0 +1,5 @@ +--- +title: Restrict number of users input to positive numbers +merge_request: 18381 +author: +type: fixed diff --git a/ee/spec/features/trials/capture_lead_spec.rb b/ee/spec/features/trials/capture_lead_spec.rb index ffc029a08197fa2ae090f57fd0eb72aa80affc19..7d0e93d514db1d0abee1f3d42a42baa8a8ed01cf 100644 --- a/ee/spec/features/trials/capture_lead_spec.rb +++ b/ee/spec/features/trials/capture_lead_spec.rb @@ -41,27 +41,38 @@ end end - context 'enters invalid company information' do + context 'enters company information' do before do fill_in 'company_name', with: 'GitLab' select2 '1-99', from: '#company_size' - # to trigger validation error - # skip filling phone number - # fill_in 'phone_number', with: '+1234567890' fill_in 'number_of_users', with: '1' select2 'US', from: '#country_select' - - click_button 'Continue' end - it 'shows validation error' do - message = page.find('#phone_number').native.attribute('validationMessage') + context 'without phone number' do + it 'shows validation error' do + fill_in 'number_of_users', with: '1' + + click_button 'Continue' - expect(message).to eq('Please fill out this field.') + message = page.find('#phone_number').native.attribute('validationMessage') + + expect(message).to eq('Please fill out this field.') + expect(current_path).to eq(new_trial_path) + end end - it 'does not proceeds to the next step' do - expect(current_path).to eq(new_trial_path) + context 'and enters negative number to the number of users field' do + it 'shows validation error' do + fill_in 'number_of_users', with: '-1' + + click_button 'Continue' + + message = page.find('#number_of_users').native.attribute('validationMessage') + + expect(message).to eq('Value must be greater than or equal to 1.') + expect(current_path).to eq(new_trial_path) + end end end end