Skip to content

Commit 03125a5

Browse files
committed
better testing
1 parent 289dc81 commit 03125a5

12 files changed

Lines changed: 90 additions & 29 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ group :development, :test do
2828
gem 'capybara'
2929
gem 'selenium-webdriver'
3030
gem 'sqlite3'
31+
gem 'factory_bot_rails'
3132
end
3233

3334
group :development do

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ GEM
8282
crass (1.0.4)
8383
docile (1.1.5)
8484
erubi (1.7.1)
85+
factory_bot (4.8.2)
86+
activesupport (>= 3.0.0)
87+
factory_bot_rails (4.8.2)
88+
factory_bot (~> 4.8.2)
89+
railties (>= 3.0.0)
8590
ffi (1.9.23)
8691
globalid (0.4.1)
8792
activesupport (>= 4.2.0)
@@ -198,6 +203,7 @@ DEPENDENCIES
198203
capistrano3-puma
199204
capybara
200205
codeclimate-test-reporter
206+
factory_bot_rails
201207
jbuilder
202208
listen
203209
mysql2

client/components/PrevDeltasModal/PrevDeltasModal.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PrevDeltasModal extends React.Component {
6666

6767
render() {
6868
const modal = (
69-
<div className="modal fade show in" tabIndex="-1" role="dialog">
69+
<div className="modal fade show in js-test-prev-deltas-modal" tabIndex="-1" role="dialog">
7070
<div className="modal-dialog" role="document">
7171
<div className="modal-content">
7272
<div className="modal-body">
@@ -85,7 +85,7 @@ class PrevDeltasModal extends React.Component {
8585
className={css(styles.deltaItem)}
8686
>
8787
<input
88-
className={css(styles.deltaItemCheck)}
88+
className={css(styles.deltaItemCheck) + ' js-test-prev-delta-check'}
8989
type="checkbox"
9090
selected={this.state.selected.includes(delta.id)}
9191
onClick={() => this.handleCheckbox(delta.id)}

test/controllers/retro_controller_test.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,22 @@ class RetroControllerTest < ActionDispatch::IntegrationTest
4848
end
4949
end
5050

51+
test "should show retro" do
52+
retro = create(:full_retro, key: 'abcdef')
53+
get "/api/retro/#{retro.key}"
54+
assert_response :success
55+
json_response = JSON.parse(@response.body)
56+
assert_equal retro.id, json_response['id']
57+
assert_equal 'abcdef', json_response['key']
58+
assert_equal 'in_progress', json_response['status']
59+
assert_equal 5, json_response['deltas'].count
60+
assert_equal 5, json_response['pluses'].count
61+
end
62+
5163
test "should show retro with previous deltas" do
5264
get "/api/retro/#{retros(:empty).key}"
5365
assert_response :success
5466
json_response = JSON.parse(@response.body)
55-
assert_equal 2, json_response['id']
56-
assert_equal 'jjj222', json_response['key']
57-
assert_equal 'locked', json_response['status']
58-
assert_equal 0, json_response['deltas'].count
59-
assert_equal 0, json_response['pluses'].count
6067
assert_equal 2, json_response['prev_deltas'].count
6168
end
6269

test/factories/deltas.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FactoryBot.define do
2+
factory :delta do
3+
content "a delta"
4+
end
5+
end

test/factories/pluses.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FactoryBot.define do
2+
factory :plus do
3+
content "a plus"
4+
end
5+
end

test/factories/retros.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FactoryBot.define do
2+
factory :retro do
3+
status "in_progress"
4+
end
5+
6+
factory :full_retro, parent: :retro do
7+
transient do
8+
delta_count 5
9+
pluses_count 5
10+
end
11+
12+
after(:create) do |retro, evaluator|
13+
create_list(:delta, evaluator.delta_count, retro: retro)
14+
create_list(:plus, evaluator.pluses_count, retro: retro)
15+
end
16+
end
17+
end

test/factories/teams.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FactoryBot.define do
2+
factory :team do
3+
name "test team"
4+
end
5+
end

test/system/.keep

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require "application_system_test_case"
2+
3+
4+
class RetrobotSystemTestCase < ApplicationSystemTestCase
5+
def teardown
6+
errors = page.driver.browser.manage.logs.get(:browser)
7+
if errors.present?
8+
message = errors.map(&:message).join("\n")
9+
puts message
10+
end
11+
assert !errors.present?
12+
end
13+
14+
def visit(url)
15+
if !ENV['LOCAL_TESTING'].nil?
16+
super 'http://localhost:8080' + url
17+
else
18+
super url
19+
end
20+
end
21+
end

0 commit comments

Comments
 (0)