Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Hello integration testing #410

Merged
merged 4 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ group :development, :test do
gem 'simplecov', require: false
end

group :test do
gem 'capybara'
gem 'chromedriver-helper'
gem 'selenium-webdriver'
end

group :development do
gem 'bullet'
gem 'fit-commit'
Expand Down
24 changes: 24 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ GEM
nokogiri
ancestry (3.0.2)
activerecord (>= 3.2.0)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (9.0.0)
ast (2.4.0)
aws-eventstream (1.0.1)
Expand Down Expand Up @@ -83,7 +85,19 @@ GEM
bundler (~> 1.2)
thor (~> 0.18)
byebug (10.0.2)
capybara (3.8.2)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
xpath (~> 3.1)
chartkick (3.0.1)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (2.1.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
cocoon (1.2.11)
codacy-coverage (2.1.0)
simplecov
Expand Down Expand Up @@ -143,6 +157,7 @@ GEM
image_processing (1.7.0)
mini_magick (~> 4.0)
ruby-vips (>= 2.0.13, < 3)
io-like (0.3.0)
jaro_winkler (1.5.1)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -253,6 +268,7 @@ GEM
ruby-vips (2.0.13)
ffi (~> 1.9)
ruby_dep (1.5.0)
rubyzip (1.2.2)
sass (3.6.0)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand All @@ -276,6 +292,9 @@ GEM
nokogiri (>= 1.8.1)
nori (~> 2.4)
wasabi (~> 3.4)
selenium-webdriver (3.14.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
sidekiq (5.2.2)
connection_pool (~> 2.2, >= 2.2.2)
rack-protection (>= 1.5.0)
Expand Down Expand Up @@ -334,6 +353,8 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
xpath (3.1.0)
nokogiri (~> 1.8)

PLATFORMS
ruby
Expand All @@ -347,7 +368,9 @@ DEPENDENCIES
bullet
bundler-audit
byebug
capybara
chartkick
chromedriver-helper
cocoon
codacy-coverage
coffee-rails (~> 4.2)
Expand Down Expand Up @@ -375,6 +398,7 @@ DEPENDENCIES
ruby-progressbar
sassc-rails
savon (~> 2.12.0)
selenium-webdriver
sidekiq
simple_form
simplecov
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<% end %>
</div>
</div>
<div class="card text-white bg-primary py-5 d-md-down-none" style="width:44%">
<div class="card text-white bg-primary py-5">
<div class="card-body text-center">
<div>
<h2><%= t('devise.common.register') %></h2>
Expand Down
17 changes: 17 additions & 0 deletions test/integration/login_page_flow_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'test_helper'

class LoginPageFlowTest < ActionDispatch::IntegrationTest
SUPPORTED_SCREEN_RESOLUTIONS.each do |resolution|
test "can login with correct credentials with a #{resolution} screen" do
page.driver.browser.manage.window.resize_to(resolution[0], resolution[1])
visit('/')
fill_in('user[id_number]', with: users(:serhat).id_number)
fill_in('user[password]', with: '123456')
check(t('devise.sessions.new.remember_login'))
click_button(t('devise.common.login'))
assert_equal t('devise.sessions.signed_in'), page.find('div', class: 'toast-message').text
end
end
end
15 changes: 15 additions & 0 deletions test/integration/login_page_interaction_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'test_helper'

class LoginPageInteractionTest < ActionDispatch::IntegrationTest
SUPPORTED_SCREEN_RESOLUTIONS.each do |resolution|
test "can see login elements with a #{resolution} screen" do
page.driver.browser.manage.window.resize_to(resolution[0], resolution[1])
visit('/')
assert find_button(t('devise.common.login'), visible: true).visible?
assert find_link(t('devise.sessions.new.did_you_forget'), visible: true).visible?
assert find_link(t('devise.sessions.new.create_account'), visible: true).visible?
end
end
end
15 changes: 15 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
require 'minitest/autorun'
require_relative '../config/environment'
require 'rails/test_help'
require 'capybara/rails'
require 'capybara/minitest'

module ActiveSupport
class TestCase
include AbstractController::Translation
include Devise::Test::IntegrationHelpers
include Capybara::DSL
include Capybara::Minitest::Assertions

fixtures :all

def controller_name
Expand All @@ -30,5 +35,15 @@ def create_file_blob(filename, content_type, metadata = nil)
io: file_fixture(filename).open, filename: filename, content_type: content_type, metadata: metadata
)
end

SUPPORTED_SCREEN_RESOLUTIONS = [[360, 640], [1024, 768], [1366, 768], [1920, 1080]].freeze
msdundar marked this conversation as resolved.
Show resolved Hide resolved

Capybara.default_driver = :selenium_chrome_headless
Capybara.server = :puma, { Silent: true }

def teardown
Capybara.reset_sessions!
Capybara.use_default_driver
end
end
end