Skip to content

Commit

Permalink
Merge pull request #162 from slovensko-digital/SSD-385/AF-registratio…
Browse files Browse the repository at this point in the history
…n-form-response-check

Added response check for the autoform registration form
  • Loading branch information
celuchmarek authored Sep 11, 2023
2 parents 9018fb9 + 70f70ea commit 7a7e90b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end

group :test do
gem 'selenium-webdriver'
gem 'webdrivers'
gem "webdrivers", "= 5.3.0"
gem 'capybara'
gem 'launchy'
gem 'simplecov', '~> 0.10', '< 0.18'
Expand Down
26 changes: 13 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
childprocess (3.0.0)
coderay (1.1.3)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
Expand Down Expand Up @@ -117,13 +116,13 @@ GEM
nokogiri (~> 1)
rake
mini_mime (1.0.2)
mini_portile2 (2.5.1)
mini_portile2 (2.8.4)
minitest (5.14.2)
netrc (0.11.0)
newrelic_rpm (6.13.1)
nio4r (2.5.7)
nokogiri (1.11.4)
mini_portile2 (~> 2.5.0)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
pg (0.21.0)
pry (0.13.1)
Expand All @@ -137,7 +136,7 @@ GEM
public_suffix (4.0.6)
puma (5.3.1)
nio4r (~> 2.0)
racc (1.5.2)
racc (1.7.1)
rack (2.2.3)
rack-mini-profiler (2.1.0)
rack (>= 1.2.0)
Expand Down Expand Up @@ -199,7 +198,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.5)
rexml (3.2.6)
rollbar (3.0.0)
rspec-core (3.9.3)
rspec-support (~> 3.9.3)
Expand All @@ -218,7 +217,7 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rubyzip (2.3.0)
rubyzip (2.3.2)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
Expand All @@ -229,10 +228,10 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.0)
childprocess (>= 0.5, < 5.0)
selenium-webdriver (4.9.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -267,14 +266,15 @@ GEM
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webdrivers (5.2.0)
webdrivers (5.3.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
selenium-webdriver (~> 4.0, < 4.11)
webmock (3.9.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket (1.2.9)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down Expand Up @@ -310,7 +310,7 @@ DEPENDENCIES
turbolinks
uglifier
web-console
webdrivers
webdrivers (= 5.3.0)
webmock

RUBY VERSION
Expand Down
29 changes: 29 additions & 0 deletions app/assets/javascripts/autoform_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,33 @@ $(document).ready(function() {
return true;
}
});

var autoformError = $('#autoform-error').get(0);
addCloseButtonListener(autoformError);

var emailInputField = $('#autoform-email').get(0);
emailInputField.addEventListener('click', function (){
removeErrors(autoformError)
});

var domainInputField = $('#autoform-domain').get(0);
domainInputField.addEventListener('click', function (){
removeErrors(autoformError)
});
});

function addCloseButtonListener(node) {
var closeButton = node.querySelector('.alert .close');
closeButton.addEventListener("click", function (){
removeErrors(node);
});
}

function removeErrors(node) {
$('#autoform-email').parent('.form-group').removeClass('has-error');
$('#autoform-domain').parent('.form-group').removeClass('has-error');
$('#' + node.id).hide();
}



12 changes: 9 additions & 3 deletions app/views/services/autoform/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,18 @@
Na výskumné a dobročinné účely zadarmo.
</p>


<div id="autoform-error" style="display: none;">
<%= render 'services/share/flash_message', {type: :alert, message: 'Niektoré údaje ste nezadali správne. Opravte ich prosím a skúste znova.'} %>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" aria-label="Close"><span aria-hidden="true" class="error">&times;</span></button>
<%= 'Niektoré údaje ste nezadali správne. Opravte ich prosím a skúste znova.' %>
</div>
</div>
<div id="autoform-form-sent" style="display: none;">
<%= render 'services/share/flash_message', {type: :notice, message: 'Žiadosť o registráciu bola odoslaná na schválenie. Ďakujeme za Váš záujem a budeme Vás kontaktovať.'} %>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true" class="success">&times;</span>
</button>
<%= 'Registrácia bola odoslaná na schválenie. Ďakujeme za Váš záujem a budeme Vás v priebehu najbližších pracovných dní kontaktovať.' %>
</div>
</div>

<div id="autoform_flash"></div>
Expand Down
4 changes: 1 addition & 3 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Webdrivers::Chromedriver.required_version = "114.0.5735.90"

Webdrivers::Chromedriver.update

Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new(options: { args: %w(headless disable-gpu disable-logging) })
options = Selenium::WebDriver::Chrome::Options.new({ args: %w(headless disable-gpu disable-logging) })
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

Expand Down

0 comments on commit 7a7e90b

Please sign in to comment.