Skip to content

Commit

Permalink
Fix flaky projects samples and attachments tests (#812)
Browse files Browse the repository at this point in the history
* test: 🚧 Added check to make sure that no samples remaining in the project

* test: 🐛 Added and id to upload button to ensure the correct button was being inspected

* test: 🐛 Fixed issue with groups file attachment test
  • Loading branch information
joshsadam authored Oct 15, 2024
1 parent 6d8ea56 commit 633ca84
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
data-file-upload-error-value="<%= t('.files_ignored') %>"
>
<%= form.label :files,
t(".files"),
class:
"block mb-2 text-sm font-medium text-slate-900 dark:text-white" %>
t(".files"),
class:
"block mb-2 text-sm font-medium text-slate-900 dark:text-white" %>
<%= form.file_field :files,
multiple: true,
direct_upload: true,
Expand All @@ -43,6 +43,7 @@

<div>
<%= form.submit t(".upload"),
id: "t-upload-button",
class: "button button--state-primary button--size-default",
data: {
"attachment-upload-target": "submitButton",
Expand Down
4 changes: 2 additions & 2 deletions test/system/groups/attachments_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class AttachmentsTest < ApplicationSystemTestCase
within('dialog') do
attach_file 'attachment[files][]', Rails.root.join('test/fixtures/files/test_file_2.fastq.gz')
# check that button goes from being enabled to disabled when clicked
assert_selector 'input[type=submit]:not(:disabled)'
assert_selector '#t-upload-button:not(:disabled)'
click_on I18n.t('attachments.dialogs.new_attachment_component.upload')
assert_selector 'input[type=submit]:disabled'
assert_selector '#t-upload-button:disabled'
end

assert_selector '#attachments-table table tbody tr', count: 3
Expand Down
4 changes: 2 additions & 2 deletions test/system/projects/attachments_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class AttachmentsTest < ApplicationSystemTestCase
within('dialog') do
attach_file 'attachment[files][]', Rails.root.join('test/fixtures/files/test_file_2.fastq.gz')
# check that button goes from being enabled to disabled when clicked
assert_selector 'input[type=submit]:not(:disabled)'
assert_selector '#t-upload-button:not(:disabled)'
click_on I18n.t('attachments.dialogs.new_attachment_component.upload')
assert_selector 'input[type=submit]:disabled'
assert_selector '#t-upload-button:disabled'
end

assert_selector '#attachments-table table tbody tr', count: 3
Expand Down
15 changes: 4 additions & 11 deletions test/system/projects/samples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,26 +507,19 @@ class SamplesTest < ApplicationSystemTestCase
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')
end

# Check samples selected are [] and has the proper number of samples
assert_text I18n.t(:'projects.samples.index.no_samples')

Project.reset_counters(project2.id, :samples_count)
visit namespace_project_samples_url(namespace1, project2)

assert_text strip_tags(I18n.t(:'viral.pagy.limit_component.summary', from: 1, to: 20, count: 220,
locale: @user.locale))

click_button I18n.t(:'projects.samples.index.select_all_button')

within 'tbody' do
assert_selector 'input[name="sample_ids[]"]:checked', count: 20
end
within 'tfoot' do
assert_text 'Samples: 220'
assert_selector 'strong[data-selection-target="selected"]', text: '220'
end
end

test 'empty state of transfer sample project selection' do
Expand Down

0 comments on commit 633ca84

Please sign in to comment.