Skip to content

Commit

Permalink
add asserts to try and avoid flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHuynh333 committed Dec 16, 2024
1 parent 588feb0 commit 2376ede
Showing 1 changed file with 46 additions and 5 deletions.
51 changes: 46 additions & 5 deletions test/system/projects/samples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,24 +383,28 @@ class SamplesTest < ApplicationSystemTestCase

test 'transfer samples' do
### SETUP START ###
samples = @project.samples.pluck(:puid, :name)
# show destination project has 20 samples prior to transfer
visit namespace_project_samples_url(@namespace, @project2)
assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 20,
locale: @user.locale))
# originating project has 3 samples prior to transfer
visit namespace_project_samples_url(
@namespace, @project
)
visit namespace_project_samples_url(@namespace, @project)
assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 3, count: 3,
locale: @user.locale))
### SETUP END ###

### ACTIONS START ###
samples = @project.samples.pluck(:puid, :name)
# select all 3 samples
click_button I18n.t(:'projects.samples.index.select_all_button')
click_link I18n.t('projects.samples.index.transfer_button')
within('#dialog') do
within('#list_selections') do
samples.each do |sample|
assert_text sample[0]
assert_text sample[1]
end
end
# select destination project
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{@project2.full_path}']").click
Expand All @@ -426,6 +430,7 @@ class SamplesTest < ApplicationSystemTestCase
end

test 'should not transfer samples with session storage cleared' do
samples = @project.samples.pluck(:puid, :name)
### SETUP START ###
visit namespace_project_samples_url(@namespace, @project)
assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 3, count: 3,
Expand All @@ -440,6 +445,12 @@ class SamplesTest < ApplicationSystemTestCase
# launch transfer dialog
click_link I18n.t('projects.samples.index.transfer_button')
within('#dialog') do
within('#list_selections') do
samples.each do |sample|
assert_text sample[0]
assert_text sample[1]
end
end
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{@project2.full_path}']").click
click_on I18n.t('projects.samples.transfers.dialog.submit_button')
Expand All @@ -458,6 +469,7 @@ class SamplesTest < ApplicationSystemTestCase
# only samples without a matching name to samples in destination project will transfer

### SETUP START ###
samples = @project.samples.pluck(:puid, :name)
namespace = groups(:subgroup1)
project25 = projects(:project25)

Expand All @@ -475,6 +487,12 @@ class SamplesTest < ApplicationSystemTestCase
click_button I18n.t(:'projects.samples.index.select_all_button')
click_link I18n.t('projects.samples.index.transfer_button')
within('#dialog') do
within('#list_selections') do
samples.each do |sample|
assert_text sample[0]
assert_text sample[1]
end
end
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{project25.full_path}']").click
click_on I18n.t('projects.samples.transfers.dialog.submit_button')
Expand Down Expand Up @@ -554,6 +572,10 @@ class SamplesTest < ApplicationSystemTestCase
# transfer sample
click_link I18n.t('projects.samples.index.transfer_button')
within('#dialog') do
within('#list_selections') do
assert_test @sample1.name
assert_text @sample1.puid
end
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{@project2.full_path}']").click
click_on I18n.t('projects.samples.transfers.dialog.submit_button')
Expand Down Expand Up @@ -1439,6 +1461,12 @@ class SamplesTest < ApplicationSystemTestCase
end
click_link I18n.t('projects.samples.index.clone_button')
within('#dialog') do
within('#list_selections') do
assert_text @sample1.puid
assert_text @sample1.name
assert_text @sample2.puid
assert_text @sample2.name
end
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{@project2.full_path}']").click
click_on I18n.t('projects.samples.clones.dialog.submit_button')
Expand All @@ -1465,6 +1493,7 @@ class SamplesTest < ApplicationSystemTestCase

test 'should not clone samples with session storage cleared' do
### SETUP START ###
samples = @project.samples.pluck(:puid, :name)

Check warning on line 1496 in test/system/projects/samples_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Useless assignment to variable - `samples`. Raw Output: test/system/projects/samples_test.rb:1496:7: W: Lint/UselessAssignment: Useless assignment to variable - `samples`.
visit namespace_project_samples_url(@namespace, @project)
### SETUP END ###

Expand All @@ -1490,9 +1519,10 @@ class SamplesTest < ApplicationSystemTestCase
end

test 'should not clone some samples' do
### SETUP START ###
namespace = groups(:subgroup1)
project25 = projects(:project25)
### SETUP START ###
samples = @project.samples.pluck(:puid, :name)
visit namespace_project_samples_url(namespace, project25)
# sample30's name already exists in project25 samples table, samples1 and 2 do not
within('#samples-table table tbody') do
Expand All @@ -1507,6 +1537,12 @@ class SamplesTest < ApplicationSystemTestCase
click_button I18n.t(:'projects.samples.index.select_all_button')
click_link I18n.t('projects.samples.index.clone_button')
within('#dialog') do
within('#list_selections') do
samples.each do |sample|
assert_text sample[0]
assert_text sample[1]
end
end
find('input#select2-input').click
find("button[data-viral--select2-primary-param='#{project25.full_path}']").click
click_on I18n.t('projects.samples.clones.dialog.submit_button')
Expand Down Expand Up @@ -1568,6 +1604,7 @@ class SamplesTest < ApplicationSystemTestCase

test 'updating sample selection during sample cloning' do
### SETUP START ###
samples = @project.samples.pluck(:puid, :name)

Check warning on line 1607 in test/system/projects/samples_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Useless assignment to variable - `samples`. Raw Output: test/system/projects/samples_test.rb:1607:7: W: Lint/UselessAssignment: Useless assignment to variable - `samples`.
visit namespace_project_samples_url(@namespace, @project2)
# verify no samples currently selected in destination project
within 'tfoot' do
Expand All @@ -1592,6 +1629,10 @@ class SamplesTest < ApplicationSystemTestCase
# clone sample
click_link I18n.t('projects.samples.index.clone_button')
within('#dialog') do
within('#list_selections') do
assert_text @sample1.name
assert_text @sample1.puid
end
fill_in placeholder: I18n.t('projects.samples.clones.dialog.select_project'), with: @project2.full_path
find("button[data-viral--select2-primary-param='#{@project2.full_path}']").click
click_on I18n.t('projects.samples.clones.dialog.submit_button')
Expand Down

0 comments on commit 2376ede

Please sign in to comment.