Skip to content

Commit

Permalink
Fix Rubocop warning
Browse files Browse the repository at this point in the history
Use click_link_or_button

The warning:

Capybara/ClickLinkOrButtonStyle: Use click_link_or_button or click_on
instead of click_button.
  • Loading branch information
Obsiye committed Jan 24, 2024
1 parent 0e16f08 commit 978b6a1
Show file tree
Hide file tree
Showing 35 changed files with 206 additions and 206 deletions.
28 changes: 14 additions & 14 deletions spec/features/breadcrumbs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

it 'breadcrumbs are not displayed' do
within_breadcrumbs do
expect(page).not_to have_content(/.+/)
expect(page).to have_no_content(/.+/)
end
end
end
Expand All @@ -25,7 +25,7 @@
context 'when on search filters page' do
scenario 'no breadcrumbs are displayed' do
within '.govuk-breadcrumbs' do
expect(page).not_to have_content(/.+/)
expect(page).to have_no_content(/.+/)
end
end
end
Expand Down Expand Up @@ -56,7 +56,7 @@
when_i_choose_search_filter 'A case by URN'
when_i_search_for case_urn

click_link(case_urn, match: :first)
click_link_or_button(case_urn, match: :first)
expect(page).to have_current_path(prosecution_case_path(case_urn))
then_has_case_details_breadcrumbs(case_urn)
end
Expand All @@ -67,8 +67,8 @@
when_i_choose_search_filter 'A case by URN'
when_i_search_for case_urn

click_link(case_urn, match: :first)
click_link('Jammy Dodger')
click_link_or_button(case_urn, match: :first)
click_link_or_button('Jammy Dodger')
expect(page).to have_current_path(%r{/laa_references/.+})
then_has_defendant_details_breadcrumbs(case_urn, 'Jammy Dodger')
end
Expand All @@ -79,8 +79,8 @@
when_i_choose_search_filter 'A case by URN'
when_i_search_for case_urn

click_link(case_urn, match: :first)
click_link('23/10/2019', match: :first)
click_link_or_button(case_urn, match: :first)
click_link_or_button('23/10/2019', match: :first)
expect(page).to have_current_path(hearing_path(hearing_id_from_fixture,
column: 'date',
direction: 'asc',
Expand All @@ -94,19 +94,19 @@
when_i_choose_search_filter 'A case by URN'
when_i_search_for case_urn

click_link(case_urn, match: :first)
click_link_or_button(case_urn, match: :first)
expect(page).to have_current_path(prosecution_case_path(case_urn))
then_has_case_details_breadcrumbs(case_urn)

click_link('Jammy Dodger')
click_link_or_button('Jammy Dodger')
expect(page).to have_current_path(%r{/laa_references/.+})
then_has_defendant_details_breadcrumbs(case_urn, 'Jammy Dodger')

click_breadcrumb 'Case TEST12345'
expect(page).to have_current_path(prosecution_case_path(case_urn))
then_has_case_details_breadcrumbs(case_urn)

click_link('23/10/2019', match: :first)
click_link_or_button('23/10/2019', match: :first)
expect(page).to have_current_path(hearing_path(hearing_id_from_fixture,
column: 'date',
direction: 'asc',
Expand All @@ -133,17 +133,17 @@

def when_i_choose_search_filter(search_filter_option)
choose search_filter_option
click_button 'Continue'
click_link_or_button 'Continue'
end

def when_i_search_for(term)
fill_in 'search-term-field', with: term
click_button 'Search'
click_link_or_button 'Search'
end

def click_breadcrumb(crumb)
within_breadcrumbs do
click_link crumb
click_link_or_button crumb
end
end

Expand All @@ -155,7 +155,7 @@ def within_breadcrumbs(&block)

def then_breadcrumbs_are_not_displayed
within_breadcrumbs do
expect(page).not_to have_content(/.+/)
expect(page).to have_no_content(/.+/)
end
end

Expand Down
40 changes: 20 additions & 20 deletions spec/features/cookie_banner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
context 'when cookies are accepted via banner' do
before do
visit '/'
click_link 'Accept analytics cookies'
click_link_or_button 'Accept analytics cookies'
end

scenario 'confirmation banner is visible' do
within '.app-cookie-banner' do
expect(page).to have_text "You've accepted additional cookies."
expect(page).not_to have_text 'Cookies on View Court Data'
expect(page).to have_no_text 'Cookies on View Court Data'
end
end

scenario 'confirmation message can link to cookie settings' do
click_link 'change your cookie settings'
click_link_or_button 'change your cookie settings'

expect(page).to have_current_path cookies_settings_path, ignore_query: true
within '.govuk-main-wrapper' do
Expand All @@ -24,14 +24,14 @@
end

scenario 'confirmation message can be hidden' do
click_link 'Hide this message'
click_link_or_button 'Hide this message'

expect(page).not_to have_css '.app-cookie-banner'
expect(page).not_to have_text "You've accepted additional cookies"
expect(page).to have_no_css '.app-cookie-banner'
expect(page).to have_no_text "You've accepted additional cookies"
end

scenario 'cookies setting form shows cookies are on' do
click_link 'change your cookie settings'
click_link_or_button 'change your cookie settings'

within '#new_cookie' do
expect(find_by_id('cookie-analytics-true-field').checked?).to be true
Expand All @@ -42,18 +42,18 @@
context 'when cookies are rejected via banner' do
before do
visit '/'
click_link 'Reject analytics cookies'
click_link_or_button 'Reject analytics cookies'
end

scenario 'confirmation banner is visible' do
within '.app-cookie-banner' do
expect(page).to have_text "You've rejected additional cookies."
expect(page).not_to have_text('Cookies on View Court Data')
expect(page).to have_no_text('Cookies on View Court Data')
end
end

scenario 'confirmation message can link to cookie settings' do
click_link 'change your cookie settings'
click_link_or_button 'change your cookie settings'

expect(page).to have_current_path cookies_settings_path, ignore_query: true
within '.govuk-main-wrapper' do
Expand All @@ -62,14 +62,14 @@
end

scenario 'confirmation message can be hidden' do
click_link 'Hide this message'
click_link_or_button 'Hide this message'

expect(page).not_to have_css '.app-cookie-banner'
expect(page).not_to have_text "You've rejected additional cookies"
expect(page).to have_no_css '.app-cookie-banner'
expect(page).to have_no_text "You've rejected additional cookies"
end

scenario 'cookies setting form shows cookies are off' do
click_link 'change your cookie settings'
click_link_or_button 'change your cookie settings'

within '#new_cookie' do
expect(find_by_id('cookie-analytics-false-field').checked?).to be true
Expand All @@ -86,25 +86,25 @@
allow(Feature).to receive(:enabled?).with(:defendants_page).and_return(true)
sign_in user
visit "laa_references/new?id=#{defendant_id}&urn=#{case_urn}"
click_link 'Accept analytics cookies'
click_link_or_button 'Accept analytics cookies'
end

scenario 'confirmation banner is visible' do
within '.app-cookie-banner' do
expect(page).to have_text "You've accepted additional cookies."
expect(page).not_to have_text 'Cookies on View Court Data'
expect(page).to have_no_text 'Cookies on View Court Data'
end
end

scenario 'confirmation message can be hidden' do
click_link 'Hide this message'
click_link_or_button 'Hide this message'

expect(page).not_to have_css '.app-cookie-banner'
expect(page).not_to have_text "You've accepted additional cookies"
expect(page).to have_no_css '.app-cookie-banner'
expect(page).to have_no_text "You've accepted additional cookies"
end

scenario 'cookies setting form shows cookies are on' do
click_link 'change your cookie settings'
click_link_or_button 'change your cookie settings'

within '#new_cookie' do
expect(find_by_id('cookie-analytics-true-field').checked?).to be true
Expand Down
42 changes: 21 additions & 21 deletions spec/features/cookies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.feature 'Cookies', type: :feature do
scenario 'viewing cookie settings' do
visit cookies_path
click_link 'Cookie settings'
click_link_or_button 'Cookie settings'

expect(page).to have_current_path cookies_settings_path, ignore_query: true
within '.govuk-main-wrapper' do
Expand All @@ -14,7 +14,7 @@
context 'when on the cookies page' do
scenario 'content should be available' do
visit '/'
click_link('Cookies')
click_link_or_button('Cookies')

expect(page).to have_current_path cookies_settings_path, ignore_query: true
within '.govuk-main-wrapper' do
Expand All @@ -30,7 +30,7 @@
expect(page).to have_css('.app-no-js-only', text: 'Analytics cookies are unavailable')
expect(page).to have_css('.app-js-only', text: 'Turn Google Analytics cookies on or off')
end
click_link 'View cookies'
click_link_or_button 'View cookies'

expect(page).to have_current_path cookies_path, ignore_query: true
end
Expand Down Expand Up @@ -60,7 +60,7 @@
expect(page).to have_text 'Hide this message'
end

click_link 'View cookies'
click_link_or_button 'View cookies'

expect(page).to have_current_path cookies_path, ignore_query: true
end
Expand All @@ -78,24 +78,24 @@
scenario 'cookie banner is not visible' do
visit cookies_settings_path
page.choose 'On'
click_button 'Save changes'
click_link_or_button 'Save changes'

within '.govuk-notification-banner--success' do
expect(page).to have_text "You've set your cookie preferences."
end
within '#new_cookie' do
expect(find_by_id('cookie-analytics-true-field').checked?).to be true
end
expect(page).not_to have_css '.app-cookie-banner'
expect(page).to have_no_css '.app-cookie-banner'
end

scenario 'notification banner links back to previous page' do
visit unauthenticated_root_path
click_link 'Contact'
click_link 'Cookies'
click_link_or_button 'Contact'
click_link_or_button 'Cookies'
page.choose 'On'
click_button 'Save changes'
click_link 'Go back to the page you were looking at'
click_link_or_button 'Save changes'
click_link_or_button 'Go back to the page you were looking at'
expect(page).to have_current_path contact_us_path, ignore_query: true
end
end
Expand All @@ -104,24 +104,24 @@
scenario 'cookie banner is not visible' do
visit cookies_settings_path
page.choose 'Off'
click_button 'Save changes'
click_link_or_button 'Save changes'

within '.govuk-notification-banner--success' do
expect(page).to have_text "You've set your cookie preferences."
end
within '#new_cookie' do
expect(find_by_id('cookie-analytics-false-field').checked?).to be true
end
expect(page).not_to have_css '.app-cookie-banner'
expect(page).to have_no_css '.app-cookie-banner'
end

scenario 'notification banner links back to previous page' do
visit unauthenticated_root_path
click_link 'Contact'
click_link 'Cookies'
click_link_or_button 'Contact'
click_link_or_button 'Cookies'
page.choose 'Off'
click_button 'Save changes'
click_link 'Go back to the page you were looking at'
click_link_or_button 'Save changes'
click_link_or_button 'Go back to the page you were looking at'
expect(page).to have_current_path contact_us_path, ignore_query: true
end
end
Expand All @@ -137,13 +137,13 @@
visit '/'

choose 'A case by URN'
click_button 'Continue'
click_link_or_button 'Continue'
fill_in 'search-term-field', with: 'TEST12345'
click_button 'Search'
click_link 'Cookies'
click_link_or_button 'Search'
click_link_or_button 'Cookies'
page.choose 'Off'
click_button 'Save changes'
click_link 'Go back to the page you were looking at'
click_link_or_button 'Save changes'
click_link_or_button 'Go back to the page you were looking at'
expect(page).to have_current_path(searches_path)
end
end
Expand Down
Loading

0 comments on commit 978b6a1

Please sign in to comment.