Skip to content

Commit fdb9abb

Browse files
committed
Improve stability of integration specs
1 parent a604da5 commit fdb9abb

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

spec/integration/actions/edit_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ class HelpTest < Tableless
774774

775775
execute_script %{$('.form-actions [name="_save"]').attr('name', 'player[name]').attr('value', 'Jackie Robinson')}
776776
find_button('Save').trigger('click')
777+
is_expected.to have_text 'Player successfully updated'
777778
end
778779

779780
it 'submits the value' do

spec/integration/authentication/devise_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
fill_in 'Email', with: user.email
2121
fill_in 'Password', with: 'password'
2222
click_button 'Log in'
23-
is_expected.to have_content 'Site Administration'
23+
is_expected.to have_css 'body.rails_admin'
2424
end
2525

2626
it 'supports logging-out', js: true do

spec/integration/fields/ck_editor_spec.rb

-16
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,4 @@
1414
expect { visit new_path(model_name: 'draft') }.not_to raise_error
1515
is_expected.to have_selector('#cke_draft_notes')
1616
end
17-
18-
it 'supports focusing on sub-modals', js: true do
19-
RailsAdmin.config Comment do
20-
edit do
21-
field :content, :ck_editor
22-
end
23-
end
24-
visit new_path(model_name: 'player')
25-
find_link('Add a new Comment').trigger 'click'
26-
expect(page).to have_text 'New Comment'
27-
expect(page).to have_css '.cke_button__link'
28-
find('.cke_button__link').click
29-
expect(page).to have_css '.cke_dialog_ui_input_text'
30-
first(:css, '.cke_dialog_ui_input_text').click
31-
expect(page).to have_css '.cke_dialog_ui_input_text:focus'
32-
end
3317
end

spec/integration/fields/has_many_association_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
expect(find("select#managing_user_team_ids option[value=\"#{teams[0].id}\"]")).to have_content teams[0].name
165165
select(teams[1].name, from: 'Teams')
166166
click_button 'Save'
167+
is_expected.to have_content 'Managing user successfully updated'
167168
expect(ManagingUser.first.teams).to match_array teams
168169
end
169170

@@ -180,6 +181,7 @@
180181
find('.ra-multiselect-collection option', text: teams[1].name).select_option
181182
find('.ra-multiselect-item-add').click
182183
click_button 'Save'
184+
is_expected.to have_content 'Managing user successfully updated'
183185
expect(ManagingUser.first.teams).to match_array teams
184186
end
185187
end

spec/integration/fields/has_one_association_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
visit edit_path(model_name: 'managing_user', id: user.id)
7777
select(team.name, from: 'Team')
7878
click_button 'Save'
79+
is_expected.to have_content 'Managing user successfully updated'
7980
expect(ManagingUser.first.team).to eq team
8081
end
8182

@@ -93,6 +94,7 @@
9394
expect(page).to have_selector('ul.ui-autocomplete li.ui-menu-item a')
9495
page.execute_script %{[...document.querySelectorAll('ul.ui-autocomplete li.ui-menu-item')].find(e => e.innerText.includes("#{team.name}")).click()}
9596
click_button 'Save'
97+
is_expected.to have_content 'Managing user successfully updated'
9698
expect(ManagingUser.first.team).to eq team
9799
end
98100
end

spec/integration/widgets/datetimepicker_spec.rb

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
require 'spec_helper'
44

55
RSpec.describe 'Datetimepicker widget', type: :request, js: true do
6+
subject { page }
7+
68
before do
79
RailsAdmin.config FieldTest do
810
edit do
@@ -52,6 +54,7 @@
5254
end
5355
end
5456
visit new_path(model_name: 'field_test')
57+
is_expected.to have_text 'New Field test'
5558
page.execute_script <<-JS
5659
document.querySelector('#field_test_datetime_field')._flatpickr.setDate('2015-10-08 12:34:56');
5760
JS

spec/integration/widgets/remote_form_spec.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
RSpec.describe 'Remote form widget', type: :request, js: true do
66
subject { page }
77

8+
describe 'modal' do
9+
it 'supports focusing on sub-modals' do
10+
visit new_path(model_name: 'division')
11+
click_link 'Add a new League'
12+
is_expected.to have_content 'New League'
13+
is_expected.not_to have_css '#modal.modal-static'
14+
execute_script %($(document.body).append($('<div id="sub-modal" class="modal d-block"><input type="text" /></div>')))
15+
find('#sub-modal input').click
16+
is_expected.to have_css '#sub-modal input:focus'
17+
end
18+
end
19+
820
context 'with filtering select widget' do
921
let(:league) { FactoryBot.create :league }
1022
let(:division) { FactoryBot.create :division, league: league }
@@ -119,7 +131,7 @@
119131
is_expected.to have_content 'New Field test'
120132
attach_file 'Carrierwave asset', file_path('test.jpg')
121133
find('#modal .save-action').click
122-
is_expected.to have_css('#modal.fade')
134+
is_expected.to have_css('option', text: /FieldTest #/, visible: false)
123135
expect(FieldTest.first.carrierwave_asset.file.size).to eq 1575
124136
end
125137
end

0 commit comments

Comments
 (0)