From 633ca84c31a5256ddffc6cb8ec4824a6cdca1eed Mon Sep 17 00:00:00 2001 From: Josh Adam Date: Tue, 15 Oct 2024 12:10:11 -0500 Subject: [PATCH] Fix flaky projects samples and attachments tests (#812) * test: :construction: Added check to make sure that no samples remaining in the project * test: :bug: Added and id to upload button to ensure the correct button was being inspected * test: :bug: Fixed issue with groups file attachment test --- .../dialogs/new_attachment_component.html.erb | 7 ++++--- test/system/groups/attachments_test.rb | 4 ++-- test/system/projects/attachments_test.rb | 4 ++-- test/system/projects/samples_test.rb | 15 ++++----------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app/components/attachments/dialogs/new_attachment_component.html.erb b/app/components/attachments/dialogs/new_attachment_component.html.erb index 7ea8bf7d44..30eb7fdf6d 100644 --- a/app/components/attachments/dialogs/new_attachment_component.html.erb +++ b/app/components/attachments/dialogs/new_attachment_component.html.erb @@ -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, @@ -43,6 +43,7 @@
<%= form.submit t(".upload"), + id: "t-upload-button", class: "button button--state-primary button--size-default", data: { "attachment-upload-target": "submitButton", diff --git a/test/system/groups/attachments_test.rb b/test/system/groups/attachments_test.rb index 2a0400a853..68e4065e3d 100644 --- a/test/system/groups/attachments_test.rb +++ b/test/system/groups/attachments_test.rb @@ -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 diff --git a/test/system/projects/attachments_test.rb b/test/system/projects/attachments_test.rb index 39e240294c..7fb27273a5 100644 --- a/test/system/projects/attachments_test.rb +++ b/test/system/projects/attachments_test.rb @@ -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 diff --git a/test/system/projects/samples_test.rb b/test/system/projects/samples_test.rb index 96187a6e88..91d8907c14 100644 --- a/test/system/projects/samples_test.rb +++ b/test/system/projects/samples_test.rb @@ -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