Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests #916

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions test/system/dashboard/projects_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ def teardown
end
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{@project2.full_path}']").click
perform_enqueued_jobs do
click_on I18n.t('projects.samples.transfers.dialog.submit_button')
end
click_on I18n.t('projects.samples.transfers.dialog.submit_button')
assert_text I18n.t('projects.samples.transfers.dialog.spinner_message')
perform_enqueued_jobs only: [::Samples::TransferJob]
end

visit dashboard_projects_url
Expand Down Expand Up @@ -385,9 +385,10 @@ def teardown
end
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{@project2.full_path}']").click
perform_enqueued_jobs do
click_on I18n.t('projects.samples.clones.dialog.submit_button')
end

click_on I18n.t('projects.samples.clones.dialog.submit_button')
assert_text I18n.t('projects.samples.clones.dialog.spinner_message')
perform_enqueued_jobs only: [::Samples::CloneJob]
end
assert_text I18n.t('projects.samples.clones.create.success')

Expand Down
149 changes: 105 additions & 44 deletions test/system/groups/samples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,22 @@ def retrieve_puids

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 26,
locale: @user.locale))
assert_selector 'table tbody tr', count: 20
assert_text @sample1.name
assert_text @sample2.name
within('table tbody') do
assert_selector 'tr', count: 20
assert_text @sample1.name
assert_text @sample2.name
end

fill_in placeholder: I18n.t(:'groups.samples.table_filter.search.placeholder'), with: 'Sample 1'
find('input.t-search-component').native.send_keys(:return)

assert_text 'Samples: 13'
assert_selector 'table tbody tr', count: 13
within('table tbody') do
assert_selector 'tr', count: 13

assert_text @sample1.name
assert_no_text @sample2.name
assert_text @sample1.name
assert_no_text @sample2.name
end
end

test 'can sort the list of samples' do
Expand All @@ -145,7 +149,9 @@ def retrieve_puids
# Because PUIDs are not always generated the same, issues regarding order have occurred when hard testing
# the expected ordering of samples based on PUID. To resolve this, we will gather the first 4 PUIDs and ensure
# they are ordered as expected against one another.
assert_selector 'table tbody tr', count: 20
within('table tbody') do
assert_selector 'tr', count: 20
end

click_on 'Sample ID'
assert_selector 'table thead th:first-child svg.icon-arrow_up'
Expand Down Expand Up @@ -194,7 +200,9 @@ def retrieve_puids

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 26,
locale: @user.locale))
assert_selector 'table tbody tr', count: 20
within('table tbody') do
assert_selector 'tr', count: 20
end
within('table tbody tr:first-child th') do
assert_text @sample1.puid
end
Expand All @@ -203,10 +211,12 @@ def retrieve_puids
find('input.t-search-component').native.send_keys(:return)

assert_text 'Samples: 13'
assert_selector 'table tbody tr', count: 13
within('table tbody') do
assert_selector 'tr', count: 13

assert_text @sample1.name
assert_no_text @sample2.name
assert_text @sample1.name
assert_no_text @sample2.name
end

assert_no_selector 'table thead th:nth-child(2) svg.icon-arrow_up'
click_on 'Sample Name'
Expand Down Expand Up @@ -237,14 +247,17 @@ def retrieve_puids

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 1, count: 1,
locale: @user.locale))
assert_selector 'table tbody tr', count: 1
assert_text @sample1.name
assert_no_text @sample2.name

within('table tbody') do
assert_selector 'tr', count: 1
assert_text @sample1.name
assert_no_text @sample2.name
end
click_on 'Sample Name'
assert_selector 'table thead th:nth-child(2) svg.icon-arrow_up'

assert_selector 'table tbody tr', count: 1
within('table tbody') do
assert_selector 'tr', count: 1
end
assert_selector 'table tbody tr:first-child th', text: @sample1.puid
assert_selector 'table tbody tr:first-child td:nth-child(2)', text: @sample1.name
end
Expand All @@ -260,18 +273,22 @@ def retrieve_puids
assert_selector 'div#limit-component button div span', text: '10'
assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 10, count: 26,
locale: @user.locale))
assert_selector 'table tbody tr', count: 10
assert_text @sample1.puid
assert_text @sample2.puid
within('table tbody') do
assert_selector 'tr', count: 10
assert_text @sample1.puid
assert_text @sample2.puid
end

fill_in placeholder: I18n.t(:'groups.samples.table_filter.search.placeholder'), with: @sample1.puid
find('input.t-search-component').native.send_keys(:return)

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 1, count: 1,
locale: @user.locale))
assert_selector 'table tbody tr', count: 1
assert_text @sample1.name
assert_no_text @sample2.name
within('table tbody') do
assert_selector 'tr', count: 1
assert_text @sample1.name
assert_no_text @sample2.name
end
assert_selector 'div#limit-component button div span', text: '10'
end

Expand All @@ -286,16 +303,27 @@ def retrieve_puids
assert_selector 'div#limit-component button div span', text: '10'
assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 10, count: 26,
locale: @user.locale))
assert_selector 'table tbody tr', count: 10
assert_selector 'table thead tr th', count: 6
within('table tbody') do
assert_selector 'tr', count: 10
end

within('table thead tr') do
assert_selector 'th', count: 6
end

assert_selector 'label', text: I18n.t('projects.samples.shared.metadata_toggle.label'), count: 1
find('label', text: I18n.t('projects.samples.shared.metadata_toggle.label')).click

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 10, count: 26,
locale: @user.locale))
assert_selector 'table tbody tr', count: 10
assert_selector 'table thead tr th', count: 9

within('table tbody') do
assert_selector 'tr', count: 10
end

within('table thead tr') do
assert_selector 'th', count: 9
end
assert_selector 'div#limit-component button div span', text: '10'
end

Expand All @@ -304,7 +332,9 @@ def retrieve_puids

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 26,
locale: @user.locale))
assert_selector 'table tbody tr', count: 20
within('table tbody') do
assert_selector 'tr', count: 20
end
within('table tbody tr:first-child th') do
assert_text @sample1.puid
end
Expand All @@ -331,18 +361,24 @@ def retrieve_puids
find('input.t-search-component').native.send_keys(:return)

assert_text '1-13 of 13'
assert_selector 'table tbody tr', count: 13
assert_text @sample1.name
assert_no_text @sample2.name
assert_no_text @sample9.name
within('table tbody') do
assert_selector 'tr', count: 13

assert_text @sample1.name
assert_no_text @sample2.name
assert_no_text @sample9.name
end
end

test 'can sort and then filter the list of samples by puid' do
visit group_samples_url(@group)

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 26,
locale: @user.locale))
assert_selector 'table tbody tr', count: 20
within('table tbody') do
assert_selector 'tr', count: 20
end

within('table tbody tr:first-child th') do
assert_text @sample1.puid
end
Expand Down Expand Up @@ -370,26 +406,34 @@ def retrieve_puids

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 1, count: 1,
locale: @user.locale))
assert_selector 'table tbody tr', count: 1
assert_text @sample1.name
assert_no_text @sample2.name
assert_no_text @sample9.name
within('table tbody') do
assert_selector 'tr', count: 1

assert_text @sample1.name
assert_no_text @sample2.name
assert_no_text @sample9.name
end
end

test 'should be able to toggle metadata' do
visit group_samples_url(@group)

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 26,
locale: @user.locale))
assert_selector 'table thead tr th', count: 6
within('table thead tr') do
assert_selector 'th', count: 6
end

click_on 'Last Updated'
assert_selector 'table thead th:nth-child(5) svg.icon-arrow_up'

assert_selector 'label', text: I18n.t('projects.samples.shared.metadata_toggle.label'), count: 1
find('label', text: I18n.t('projects.samples.shared.metadata_toggle.label')).click

assert_selector 'table thead tr th', count: 9
within('table thead tr') do
assert_selector 'th', count: 9
end

within('table tbody tr:first-child') do
assert_text @sample30.name
assert_selector 'td:nth-child(7) button', text: 'value1'
Expand All @@ -406,9 +450,14 @@ def retrieve_puids
assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 26,
locale: @user.locale))
assert_selector 'label', text: I18n.t('projects.samples.shared.metadata_toggle.label'), count: 1
assert_selector 'table thead tr th', count: 6
within('table thead tr') do
assert_selector 'th', count: 6
end

find('label', text: I18n.t('projects.samples.shared.metadata_toggle.label')).click
assert_selector 'table thead tr th', count: 9
within('table thead tr') do
assert_selector 'th', count: 9
end

click_on 'metadatafield1'
assert_selector 'table thead th:nth-child(7) svg.icon-arrow_up'
Expand All @@ -424,7 +473,10 @@ def retrieve_puids

# toggling metadata again causes sort to be reset
find('label', text: I18n.t(:'projects.samples.shared.metadata_toggle.label')).click
assert_selector 'table thead tr th', count: 6

within('table thead tr') do
assert_selector 'th', count: 6
end

assert_selector 'table thead th:nth-child(5) svg.icon-arrow_down'
within('tbody') do
Expand Down Expand Up @@ -836,14 +888,20 @@ def retrieve_puids
test 'can update metadata value that is not from an analysis' do
### SETUP START ###
visit group_samples_url(@group)
assert_selector 'table thead tr th', count: 6

within('table thead tr') do
assert_selector 'th', count: 6
end

fill_in placeholder: I18n.t(:'groups.samples.table_filter.search.placeholder'), with: @sample1.name
find('input.t-search-component').native.send_keys(:return)

assert_selector 'label', text: I18n.t('projects.samples.shared.metadata_toggle.label'), count: 1
find('label', text: I18n.t('projects.samples.shared.metadata_toggle.label')).click
assert_selector 'table thead tr th', count: 9

within('table thead tr') do
assert_selector 'th', count: 9
end

within 'div.overflow-auto.scrollbar' do |div|
div.scroll_to div.find('table thead th:nth-child(7)')
Expand Down Expand Up @@ -877,7 +935,10 @@ def retrieve_puids
visit group_samples_url(@group)

find('label', text: I18n.t('projects.samples.shared.metadata_toggle.label')).click
assert_selector 'table thead tr th', count: 9

within('table thead tr') do
assert_selector 'th', count: 9
end

fill_in placeholder: I18n.t(:'projects.samples.table_filter.search.placeholder'), with: @sample28.name
find('input.t-search-component').native.send_keys(:return)
Expand Down
2 changes: 1 addition & 1 deletion test/system/projects/bots_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def setup
assert_selector '#access-token-section'
assert_no_selector '#access-token-section div'
# create new PAT to render PAT panel
within "tr[id='#{@project_bot.id}']" do
within "table tbody tr[id='#{@project_bot.id}']" do
click_link I18n.t('bots.index.table.actions.generate_new_token')
end

Expand Down
Loading
Loading