Skip to content

Commit

Permalink
IssueID #3144 - Rspec fixes for Bootstrap 5 upgrade:
Browse files Browse the repository at this point in the history
1: Fix for SuperAdmins Orgs Super admin removes links
     Failure/Error: all('.link a > .fa-circle-xmark').last.click
Changed selectors in spec/features/super_admins/orgs_spec.rb & updated spec/support/helpers/links_helper.rb updated. It was necessary, to scroll to links that were not visible and click by using Javascripts scripts.
2: Fixed errors in ./spec/features/questions/textarea_questions_spec.rb.
Changed "(0/1) answered" -> "( 0 / 1)",
        "(1/1) answered" -> "( 1 / 1)"
3: Fix for error in ./spec/features/annotations/annotations_editing_spec.rb
Changed "Noo bar" -> "<p>Noo bar</p>".
4: Fixed error in ./spec/features/questions/radiobuttons_questions_spec.rb.
Changed "(0/1) answered" -> "(0 / 1)".
5: Fixed error in ./spec/features/questions/dropdown_questions_spec.rb.
Changed "(0/1) answered" -> "( 0 / 1)".
6: Fixed error in spec/features/feedback_requests_spec.rb
Replaced "within('div.panel') do" -> "within('.tab-pane.active')"
7: Fixed errors in ./spec/features/questions/checkbox_questions_spec.rb.
Changed "(0/1) answered" -> "( 0 / 1)",
        "(1/1) answered" -> "( 1 / 1)"
8: Fixed error in ./spec/features/templates/templates_editings_spec.rb.
Changed "Foo bar" -. "<p>Foo bar</p>".
9: Fix for ./spec/features/questions/textfield_questions_spec.rb.
Changed "(0/1) answered" -> "( 0 / 1)",
        "(1/1) answered" -> "( 1 / 1)"
  • Loading branch information
John Pinto committed Mar 20, 2024
1 parent b7b09d2 commit 2b994c5
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion spec/features/annotations/annotations_editing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
expect { click_button 'Save' }.not_to change { Annotation.count }
end
expect(annotation.text).to eql('Foo bar')
expect(Annotation.order('created_at').last.text).to eql('Noo bar')
expect(Annotation.order('created_at').last.text).to eql('<p>Noo bar</p>')
expect(page).not_to have_errors
end

Expand Down
2 changes: 1 addition & 1 deletion spec/features/feedback_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end

# Click "Request feedback" button within panel
within('div.panel') do
within('.tab-pane.active') do
click_link 'Request feedback'
end

Expand Down
4 changes: 2 additions & 2 deletions spec/features/questions/checkbox_questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Expectations
expect(current_path).to eql(edit_plan_path(@plan))
# 4 sections x 3 questions
expect(page).to have_text('0/1 answered')
expect(page).to have_text('(0 / 1)')

# Action
find("#section-panel-#{@section.id}").click
Expand All @@ -38,7 +38,7 @@

# Expectations
expect(page).to have_text 'Answered just now'
expect(page).to have_text '1/1 answered'
expect(page).to have_text '(1 / 1)'
expect(Answer.where(question_id: @question.id)).to be_any
end
end
2 changes: 1 addition & 1 deletion spec/features/questions/dropdown_questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Expectations
expect(current_path).to eql(edit_plan_path(@plan))
# 4 sections x 3 questions
expect(page).to have_text('0/1 answered')
expect(page).to have_text('(0 / 1)')

# Action
find("#section-panel-#{@section.id}").click
Expand Down
2 changes: 1 addition & 1 deletion spec/features/questions/radiobuttons_questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Expectations
expect(current_path).to eql(edit_plan_path(@plan))
# 4 sections x 3 questions
expect(page).to have_text('0/1 answered')
expect(page).to have_text('(0 / 1)')

# Action
find("#section-panel-#{@section.id}").click
Expand Down
4 changes: 2 additions & 2 deletions spec/features/questions/textarea_questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Expectations
expect(current_path).to eql(edit_plan_path(@plan))
# 4 sections x 3 questions
expect(page).to have_text('0/1 answered')
expect(page).to have_text('(0 / 1)')

# Action
find("#section-panel-#{@section.id}").click
Expand All @@ -39,7 +39,7 @@

# Expectations
expect(page).to have_text 'Answered just now'
expect(page).to have_text '1/1 answered'
expect(page).to have_text '(1 / 1)'
expect(Answer.where(question_id: @question.id)).to be_any
end
end
4 changes: 2 additions & 2 deletions spec/features/questions/textfield_questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Expectations
expect(current_path).to eql(edit_plan_path(@plan))
# 4 sections x 3 questions
expect(page).to have_text('0/1 answered')
expect(page).to have_text('(0 / 1)')

# Action
find("#section-panel-#{@section.id}").click
Expand All @@ -39,7 +39,7 @@

# Expectations
expect(page).to have_text 'Answered just now'
expect(page).to have_text '1/1 answered'
expect(page).to have_text '(1 / 1)'
expect(Answer.where(question_id: @question.id)).to be_any
end
end
8 changes: 4 additions & 4 deletions spec/features/super_admins/orgs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
# Edit the first org in the table
find('table .dropdown-toggle').click
find('.dropdown-menu > li > a').click
nbr_links = all('.link').length
nbr_links = all('input[name="link_link"]').length
add_link
expect(all('.link').length).to eql(nbr_links + 1)
expect(all('input[name="link_link"]').length).to eql(nbr_links + 1)
end

scenario 'Super admin removes links' do
Expand All @@ -39,8 +39,8 @@
find('table .dropdown-toggle').click
find('.dropdown-menu > li > a').click
add_link
nbr_links = all('.link').length
nbr_links = all('input[name="link_link"]').length
remove_link
expect(all('.link').length).to eql(nbr_links - 1)
expect(all('input[name="link_link"]').length).to eql(nbr_links - 1)
end
end
2 changes: 1 addition & 1 deletion spec/features/templates/templates_editings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
click_button 'Save'
end
# Make sure annotation has been updated
expect(Question.find(template.question_ids.first).annotations.first.text).to eql('Foo bar')
expect(Question.find(template.question_ids.first).annotations.first.text).to eql('<p>Foo bar</p>')
# Make sure blank records are not created for empty annotation form
expect(Question.find(template.question_ids.first).annotations.count).to eql(1)
expect(page).not_to have_errors
Expand Down
11 changes: 10 additions & 1 deletion spec/support/helpers/links_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ def add_link
end

def remove_link
all('.link a > .fa-circle-xmark').last.click
# # Scroll the element into view
last_link = all('a.delete > .fas.fa-circle-xmark.fa-reverse', visible: false).last
scroll_to_element(last_link)
# Use Javascript to click link element, as it appears to be size 0
execute_script("arguments[0].click();", last_link);
end

def scroll_to_element(element)
script = 'arguments[0].scrollIntoView(true)'
execute_script(script, element.native)
end
end

0 comments on commit 2b994c5

Please sign in to comment.