Skip to content

Commit

Permalink
Fix flaky tests / optimize checking of page title
Browse files Browse the repository at this point in the history
This commit replaces `page.source` with (the hopefully more efficient) `page.title` for verifying the page title. Checking the entire page source was potentially causing slowdowns and leading to the intermittent failing of tests within this file.
  • Loading branch information
aaronskiba committed Sep 4, 2024
1 parent 56759df commit ae27a0d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spec/features/plans/exports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
select('html')
new_window = window_opened_by { click_button 'Download Plan' }
within_window new_window do
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
end
end

Expand All @@ -60,7 +60,7 @@
select('html')
new_window = window_opened_by { click_button 'Download Plan' }
within_window new_window do
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
end
end

Expand Down Expand Up @@ -91,7 +91,7 @@
click_button 'Download Plan'
end
within_window new_window do
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
plan.phases.each do |phase|
expect(page.source).to have_text(phase.title)
end
Expand All @@ -101,7 +101,7 @@
click_button 'Download Plan'
end
within_window new_window do
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
expect(page.source).to have_text(plan.phases[1].title)
expect(page.source).not_to have_text(plan.phases[2].title) if plan.phases.length > 2
end
Expand Down Expand Up @@ -173,18 +173,18 @@ def _regular_download(format)
click_button 'Download Plan'
end
within_window new_window do
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
end
else
click_button 'Download Plan'
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
end
end

def _all_phase_download
_select_option('phase_id', 'All')
click_button 'Download Plan'
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
plan.phases.each do |phase| # All phase titles should be included in output
expect(page.source).to have_text(phase.title)
end
Expand All @@ -193,7 +193,7 @@ def _all_phase_download
def _single_phase_download
_select_option('phase_id', plan.phases[1].id)
click_button 'Download Plan'
expect(page.source).to have_text(plan.title)
expect(page.title).to have_text(plan.title)
expect(page.source).to have_text(plan.phases[1].title)
expect(page.source).not_to have_text(plan.phases[2].title) if plan.phases.length > 2
end
Expand Down

0 comments on commit ae27a0d

Please sign in to comment.