Skip to content

Commit

Permalink
Quit the session after the test so the alert can show again
Browse files Browse the repository at this point in the history
  • Loading branch information
corylown committed Sep 9, 2024
1 parent 1722b50 commit a309535
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 51 deletions.
71 changes: 39 additions & 32 deletions spec/features/contextual_date_sort_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,50 @@
end
end

# rubocop:disable RSpec/ExampleLength
it 'renders info alert, that is dismissable', js: true do
within '#sort-dropdown' do
click_button('Relevance')
click_link('Date (old to new)')
end
within '#content' do
expect(page).to have_css '.date-sort-message'
within '.date-sort-message' do
click_button 'Dismiss'
context 'when the alert is dismissed' do
before do
within '#sort-dropdown' do
click_button('Relevance')
click_link('Date (old to new)')
end
expect(page).to have_no_css '.date-sort-message'
end
click_button 'Search'
within '#content' do
expect(page).to have_css '.date-sort-message'
end
end
# rubocop:enable RSpec/ExampleLength

# rubocop:disable RSpec/ExampleLength
it 'renders info alert, that is not shown again in the session', js: true do
within '#sort-dropdown' do
click_button('Relevance')
click_link('Date (old to new)')
end
within '#content' do
expect(page).to have_css '.date-sort-message'
within '.date-sort-message' do
click_button "Don't show again"
context 'with the Dismiss button' do
# rubocop:disable RSpec/ExampleLength
it 'shows the alert again when sort is applied', js: true do
within '#content' do
expect(page).to have_css '.date-sort-message'
within '.date-sort-message' do
click_button 'Dismiss'
end
expect(page).to have_no_css '.date-sort-message'
end
click_button 'Search'
within '#content' do
expect(page).to have_css '.date-sort-message'
end
end
expect(page).to have_no_css '.date-sort-message'
# rubocop:enable RSpec/ExampleLength
end
click_button 'Search'
within '#content' do
expect(page).to have_no_css '.date-sort-message'

context 'with the "Don\'t show again" button' do
# rubocop:disable RSpec/ExampleLength
it 'does not show the alert again within the session', js: true do
within '#content' do
expect(page).to have_css '.date-sort-message'
within '.date-sort-message' do
click_button "Don't show again"
end
expect(page).to have_no_css '.date-sort-message'
end
click_button 'Search'
within '#content' do
expect(page).to have_no_css '.date-sort-message'
end
# Quit the session so that the other tests can show the alert again
Capybara.current_session.driver.quit
end
# rubocop:enable RSpec/ExampleLength
end
end
# rubocop:enable RSpec/ExampleLength
end
46 changes: 27 additions & 19 deletions spec/features/contextual_result_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,35 @@
end
end

it 'renders info alert, that is dismissable', js: true do
within '#content' do
expect(page).to have_css '.alert.alert-info', text: 'You might see more results for your query'
click_button 'Dismiss'
expect(page).to have_no_css '.alert.alert-info'
end
click_button 'Search'
within '#content' do
expect(page).to have_css '.alert.alert-info', text: 'You might see more results for your query'
context 'when the alert is dismissed' do
context 'with the dismiss button' do
it 'shows the alert again when after a search', js: true do
within '#content' do
expect(page).to have_css '.alert.alert-info', text: 'You might see more results for your query'
click_button 'Dismiss'
expect(page).to have_no_css '.alert.alert-info'
end
click_button 'Search'
within '#content' do
expect(page).to have_css '.alert.alert-info', text: 'You might see more results for your query'
end
end
end
end

it 'renders info alert, that is not shown again in the session', js: true do
within '#content' do
expect(page).to have_css '.alert.alert-info', text: 'You might see more results for your query'
click_button 'Don\'t show again'
expect(page).to have_no_css '.alert.alert-info'
end
click_button 'Search'
within '#content' do
expect(page).to have_no_css '.alert.alert-info', text: 'You might see more results for your query'
context 'with the "Don\'t show again" button' do
it 'does not show the alert again within the session', js: true do
within '#content' do
expect(page).to have_css '.alert.alert-info', text: 'You might see more results for your query'
click_button 'Don\'t show again'
expect(page).to have_no_css '.alert.alert-info'
end
click_button 'Search'
within '#content' do
expect(page).to have_no_css '.alert.alert-info', text: 'You might see more results for your query'
end
# Quit the session so that the other tests can show the alert again
Capybara.current_session.driver.quit
end
end
end
end

0 comments on commit a309535

Please sign in to comment.