Wl@k)hEAu+O0_0cCe?RBlTR@CUCT|D4{5jF5qZvP*1f5@
z%+g!lU14s>tg*e86Mub`bWM4|zrUBKAN~2OZ1dU8SIu@uKfOL(GCt<))mEd_(63@V
zWjAg=SX92t`76igWSOGS_u4Hlm@6#%K2D#pe$COS@aFgx{y&c=3qJin^>O*n^H<8h
z^MV49JL7-cKVXhs1TLT$nM{}w^%Qd91*)fDU`Zp0MMIafz$EKz9*x7Dsi_2Xb9RVhM(D5hOt)Cv{NK0s~7LZ!T;nqF|n1PeQAT8B0$;dEK*U~)ELf6E=%u?4f*&<2T#K_zv
z)iO23JlWh*zqm9vH?gQvucV?xFTE->gq49Y%6M+Nd^gBcAYeW_>3rU81D^KxbzN^5
zQ#_}ooZMR($;UWLX?2v2wd58T^?QHv%P!rl{k5{4k=bZLJ5w}gla1hyx(D0$-mg3L
z-mJa-tm6H*`R1!@Z4-jacWj!zt+lXI>GzJf{55|CTyO6_?40;Hc4GbAo5ySQ?CSP)
zhAnhsu|N7J&DFoQyCnDewW~KQdt@(&-F?aQ#oNAa`PYbQ1=(}yR#~_IW(?IC@&7
z;?n2s2W^*cjXttR$NuRZJ5P~^tEBbPvlhxq=^RMsnLI`Cv8B2Zv!_?TN5!Jbmy*Fj
znWuOHy`+t{UNC8WdQ>-g&yMG=5rwRmf4bMy{A0GQ{Qlyksg;lLw$#mg&e%0e
zCNn>)y<|_xmNQP?D^r4mT1AC4Sp`-Y`L{fOADH{LPQH#juF(by?aAB&h?VsUY5ZcS_93^3~DvJL`LD<&&b4GXBDnlCrXLe#T1<6$w1`T`+uUm
z>8Aw(Q_OvA-YmG?bb6akn@ELE6657*9LE3Nuf7{l_-fM8!+O5=e&73j>;3goZbjb^
z?+bYopQW{g**we$(JNNl@-3{VBVbYH4BMQNg6*HL@;~S7l}HJyo^0xrUFxN(yz-Vo
zQUTLu=MBk|8MpQ9Yo1#mkZ^j7Zh^uk=i7mCS*z<@=3M5uv2Xqc6(x)2pa)ecQ#ZT%
ze4fg$+S2Or>CKahzkQzbK3XOUEPOt(=iA<^(lU=VgDtdwrw2s$lowd1WI>YI93*CTu%Lbg^AcZVuOzwM?~-Wy?%!c
z1P*+(^)FQB@sqjz(;!-_G$Dg=DaQ=0+j|{c>{i{FD5ZA9IOWO9Pby0|6k8ZJ-YHuC
z-+#L4Dyf{z#L64n=YEz*6Wl@k)hEAu+O0_0cCe?RBlTR@CUCT|D4{5jF5qZvP*1f5@
z%+g!lU14s>tg*e86Mub`bWM4|zrUBKAN~2OZ1dU8SIu@uKfOL(GCt<))mEd_(63@V
zWjAg=SX92t`76igWSOGS_u4Hlm@6#%K2D#pe$COS@aFgx{y&c=3qJin^>O*n^H<8h
z^MV49JL7-cKVXhs1TLT$nM{}w^%Qd91*)fDU`Zp0MMIafz$EKz9*x7Dsi_2Xb9RVhM(D5hOt)Cv{NK0s~7LZ!T;nqF|
Date: Thu, 6 Feb 2025 15:54:14 -0600
Subject: [PATCH 53/57] Create fixtures for export testing
---
test/fixtures/active_storage/attachments.yml | 15 ++++++
test/fixtures/active_storage/blobs.yml | 6 +++
test/fixtures/attachments.yml | 5 ++
test/fixtures/data_exports.yml | 23 ++++++++++
test/fixtures/samples_workflow_executions.yml | 9 ++++
test/fixtures/workflow_executions.yml | 46 +++++++++++++++++++
6 files changed, 104 insertions(+)
diff --git a/test/fixtures/active_storage/attachments.yml b/test/fixtures/active_storage/attachments.yml
index 3f4eb46613..4b846d4600 100644
--- a/test/fixtures/active_storage/attachments.yml
+++ b/test/fixtures/active_storage/attachments.yml
@@ -143,6 +143,11 @@ samples_workflow_execution_completed_output:
record: samples_workflow_execution_completed_output_attachment (Attachment)
blob: samples_workflow_execution_completed_output_blob
+samples_shared_workflow_execution_completed_output:
+ name: file
+ record: samples_shared_workflow_execution_completed_output_attachment (Attachment)
+ blob: samples_shared_workflow_execution_completed_output_blob
+
data_export_7_test_export:
name: file
record: data_export_seven (DataExport)
@@ -158,6 +163,16 @@ data_export_9_test_export:
record: data_export_nine (DataExport)
blob: data_export_9_test_export_blob
+data_export_11_test_export:
+ name: file
+ record: data_export_eleven (DataExport)
+ blob: data_export_11_test_export_blob
+
+data_export_12_test_export:
+ name: file
+ record: data_export_twelve (DataExport)
+ blob: data_export_12_test_export_blob
+
attachmentEndToEndFWD_file_test_file_fastq:
name: file
record: attachmentEndToEndFWD (Attachment)
diff --git a/test/fixtures/active_storage/blobs.yml b/test/fixtures/active_storage/blobs.yml
index ee0a1d90aa..7f5aaa7987 100644
--- a/test/fixtures/active_storage/blobs.yml
+++ b/test/fixtures/active_storage/blobs.yml
@@ -85,12 +85,18 @@ workflow_execution_completed_output_blob: <%= ActiveStorage::FixtureSet.blob fil
samples_workflow_execution_completed_output_blob: <%= ActiveStorage::FixtureSet.blob filename: "INXT_SAM_AAAAAAAABV.assembly.fa.gz", service_name: "test" %>
+samples_shared_workflow_execution_completed_output_blob: <%= ActiveStorage::FixtureSet.blob filename: "INXT_SAM_AAAAAAAABW.assembly.fa.gz", service_name: "test" %>
+
data_export_7_test_export_blob: <%= ActiveStorage::FixtureSet.blob filename: "data_export_7.zip", service_name: "test" %>
data_export_8_test_export_blob: <%= ActiveStorage::FixtureSet.blob filename: "data_export_8.csv", service_name: "test" %>
data_export_9_test_export_blob: <%= ActiveStorage::FixtureSet.blob filename: "data_export_9.xlsx", service_name: "test" %>
+data_export_11_test_export_blob: <%= ActiveStorage::FixtureSet.blob filename: "data_export_11.zip", service_name: "test" %>
+
+data_export_12_test_export_blob: <%= ActiveStorage::FixtureSet.blob filename: "data_export_12.zip", service_name: "test" %>
+
attachmentEndToEndFWD_file_test_file_fastq_blob: <%= ActiveStorage::FixtureSet.blob filename: "test_file_end_to_end_F.fastq", service_name: "test" %>
attachmentEndToEndREV_file_test_file_fastq_blob: <%= ActiveStorage::FixtureSet.blob filename: "test_file_end_to_end_R.fastq", service_name: "test" %>
diff --git a/test/fixtures/attachments.yml b/test/fixtures/attachments.yml
index 4180d6a9bb..81f15f58b8 100644
--- a/test/fixtures/attachments.yml
+++ b/test/fixtures/attachments.yml
@@ -232,6 +232,11 @@ samples_workflow_execution_completed_output_attachment:
attachable: sample46_irida_next_example_completed_with_output (SamplesWorkflowExecution)
puid: INXT_ATT_AAAAAAAAAU
+samples_shared_workflow_execution_completed_output_attachment:
+ metadata: {"type": "assembly", "format": "fasta", "compression": "gzip"}
+ attachable: sample47_workflow_execution_completed_shared2 (SamplesWorkflowExecution)
+ puid: INXT_ATT_AAAAAAAAAV
+
attachmentEndToEndFWD:
metadata:
{
diff --git a/test/fixtures/data_exports.yml b/test/fixtures/data_exports.yml
index 9086523876..ce5d73557a 100644
--- a/test/fixtures/data_exports.yml
+++ b/test/fixtures/data_exports.yml
@@ -139,3 +139,26 @@ data_export_ten:
expires_at: <%= 5.days.from_now %>
manifest: '{"type":"Samples Export","date": "2024-01-01","children":[{"name":"INXT_PRJ_AAAAAAAAAB","type":"folder","irida-next-type":"project","irida-next-name":"Project 2","children":[{"name":"INXT_SAM_AAAAAAAAAV","type":"folder","irida-next-type":"sample","irida-next-name":"Project 2 Sample 22","children":[{"name":"INXT_ATT_ABAAAAAAAI","type":"folder","irida-next-type":"attachment","children":[{"name":"test_file_14.txt","type":"file","metadata":{"format":"text"}}]},{"name":"INXT_ATT_ABAAAAAAAH","type":"folder","irida-next-type":"attachment","children":[{"name":"test_file_5.fasta","type":"file","metadata":{"format":"fasta","type":"assembly"}}]}]}]}]}'
+data_export_eleven:
+ name: Data Export 11
+ export_type: analysis
+ status: ready
+ export_parameters: {ids: [<%= ActiveRecord::FixtureSet.identify(:workflow_execution_completed_shared2, :uuid) %>], analysis_type: 'user'}
+ email_notification: true
+ created_at: <%= 1.week.ago %>
+ updated_at: <%= 1.day.ago %>
+ user_id: <%= ActiveRecord::FixtureSet.identify(:micha_doe, :uuid) %>
+ expires_at: <%= 5.days.from_now %>
+ manifest: '{"type":"Analysis Export","date":"2024-01-01","children":[{"name":"<%= ActiveRecord::FixtureSet.identify(:workflow_execution_completed_shared2, :uuid) %>", "type":"folder","irida-next-type":"workflow_execution","irida-next-name":"<%= ActiveRecord::FixtureSet.identify(:workflow_execution_completed_shared2, :uuid) %>","children":[{"name":"summary.txt.gz","type":"file"},{"name":"INXT_SAM_AAAAAAAABW","type":"folder","irida-next-type":"sample","irida-next-name":"Sample 47","children":[{"name":"INXT_SAM_AAAAAAAABW.assembly.fa.gz","type":"file"}]}]}]}'
+
+data_export_twelve:
+ name: Data Export 12
+ export_type: analysis
+ status: ready
+ export_parameters: {ids: [<%= ActiveRecord::FixtureSet.identify(:workflow_execution_completed_shared2, :uuid) %>], analysis_type: 'user'}
+ email_notification: true
+ created_at: <%= 1.week.ago %>
+ updated_at: <%= 1.day.ago %>
+ user_id: <%= ActiveRecord::FixtureSet.identify(:james_doe, :uuid) %>
+ expires_at: <%= 5.days.from_now %>
+ manifest: '{"type":"Analysis Export","date":"2024-01-01","children":[{"name":"<%= ActiveRecord::FixtureSet.identify(:workflow_execution_completed_shared2, :uuid) %>", "type":"folder","irida-next-type":"workflow_execution","irida-next-name":"<%= ActiveRecord::FixtureSet.identify(:workflow_execution_completed_shared2, :uuid) %>","children":[{"name":"summary.txt.gz","type":"file"},{"name":"INXT_SAM_AAAAAAAABW","type":"folder","irida-next-type":"sample","irida-next-name":"Sample 47","children":[{"name":"INXT_SAM_AAAAAAAABW.assembly.fa.gz","type":"file"}]}]}]}'
diff --git a/test/fixtures/samples_workflow_executions.yml b/test/fixtures/samples_workflow_executions.yml
index fa0059b5eb..f6204da207 100644
--- a/test/fixtures/samples_workflow_executions.yml
+++ b/test/fixtures/samples_workflow_executions.yml
@@ -184,6 +184,15 @@ sample46_irida_next_example_completed_with_output:
"fastq_2": ""
}
+sample47_workflow_execution_completed_shared2:
+ sample_id: <%= ActiveRecord::FixtureSet.identify(:sample47, :uuid) %>
+ workflow_execution_id: <%= ActiveRecord::FixtureSet.identify(:workflow_execution_completed_shared2, :uuid) %>
+ samplesheet_params: {
+ "sample": <%= "Sample_#{ActiveRecord::FixtureSet.identify(:sample47, :uuid)}" %>,
+ "fastq_1": <%= "gid://irida/Attachment/#{ActiveRecord::FixtureSet.identify(:samples_shared_workflow_execution_completed_output, :uuid)}" %>,
+ "fastq_2": ""
+ }
+
sample1_automated_example_submitted:
sample_id: <%= ActiveRecord::FixtureSet.identify(:sample1, :uuid) %>
workflow_execution_id: <%= ActiveRecord::FixtureSet.identify(:automated_example_submitted, :uuid) %>
diff --git a/test/fixtures/workflow_executions.yml b/test/fixtures/workflow_executions.yml
index 7e82aa32fc..58b18e2bb7 100644
--- a/test/fixtures/workflow_executions.yml
+++ b/test/fixtures/workflow_executions.yml
@@ -896,3 +896,49 @@ workflow_execution_shared3:
submitter_id: <%= ActiveRecord::FixtureSet.identify(:james_doe, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:project2_namespace, :uuid) %>
shared_with_namespace: true
+
+workflow_execution_completed_shared1:
+ <<: *DEFAULTS
+ metadata:
+ {
+ "workflow_name": "phac-nml/iridanextexample",
+ "workflow_version": "1.0.2",
+ }
+ workflow_params:
+ {
+ "input": "/blah/samplesheet.csv",
+ "outdir": "/blah/output",
+ }
+ workflow_engine_parameters: { "-r": "dev" }
+ workflow_url: "https://github.com/phac-nml/irida_next_shared_example_completed_with_output"
+ run_id: "my_run_id_shared_1"
+ submitter_id: <%= ActiveRecord::FixtureSet.identify(:james_doe, :uuid) %>
+ namespace_id: <%= ActiveRecord::FixtureSet.identify(:project22_namespace, :uuid) %>
+ name: "irida_next_user_shared_example_completed_with_output"
+ state: "completed"
+ blob_run_directory: "not a run dir"
+ cleaned: false
+ shared_with_namespace: true
+
+workflow_execution_completed_shared2:
+ <<: *DEFAULTS
+ metadata:
+ {
+ "workflow_name": "phac-nml/iridanextexample",
+ "workflow_version": "1.0.2",
+ }
+ workflow_params:
+ {
+ "input": "/blah/samplesheet.csv",
+ "outdir": "/blah/output",
+ }
+ workflow_engine_parameters: { "-r": "dev" }
+ workflow_url: "https://github.com/phac-nml/irida_next_shared_example_completed_with_output"
+ run_id: "my_run_id_shared_2"
+ submitter_id: <%= ActiveRecord::FixtureSet.identify(:micha_doe, :uuid) %>
+ namespace_id: <%= ActiveRecord::FixtureSet.identify(:project22_namespace, :uuid) %>
+ name: "irida_next_member_shared_example_completed_with_output"
+ state: "completed"
+ blob_run_directory: "not a run dir"
+ cleaned: false
+ shared_with_namespace: true
From 667162d9a3e3d2f340c6d74022c86d55d740f644 Mon Sep 17 00:00:00 2001
From: Meghan Chua <17057809+malchua@users.noreply.github.com>
Date: Thu, 6 Feb 2025 15:56:33 -0600
Subject: [PATCH 54/57] Fix policy bug when user is not submitter or bot
---
app/policies/workflow_execution_policy.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/policies/workflow_execution_policy.rb b/app/policies/workflow_execution_policy.rb
index 7cd716796d..2c2257f77e 100644
--- a/app/policies/workflow_execution_policy.rb
+++ b/app/policies/workflow_execution_policy.rb
@@ -36,12 +36,12 @@ def destroy? # rubocop:disable Metrics/AbcSize
false
end
- def read? # rubocop:disable Metrics/AbcSize
+ def read? # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
return true if record.submitter.id == user.id
# submitted by automation bot and user has access
if (record.namespace.type == Namespaces::ProjectNamespace.sti_name) &&
- (record.submitter.id == record.namespace.automation_bot.id) &&
+ record.namespace.automation_bot && (record.submitter.id == record.namespace.automation_bot.id) &&
(effective_access_level > Member::AccessLevel::NO_ACCESS)
return true
end
@@ -66,7 +66,7 @@ def cancel? # rubocop:disable Metrics/AbcSize
# submitted by automation bot and user has managable access
if (record.namespace.type == Namespaces::ProjectNamespace.sti_name) &&
- (record.submitter.id == record.namespace.automation_bot.id) &&
+ record.namespace.automation_bot && (record.submitter.id == record.namespace.automation_bot.id) &&
Member::AccessLevel.manageable.include?(effective_access_level)
return true
end
@@ -81,7 +81,7 @@ def edit? # rubocop:disable Metrics/AbcSize
# submitted by automation bot and user is analyst or higher
if (record.namespace.type == Namespaces::ProjectNamespace.sti_name) &&
- (record.submitter.id == record.namespace.automation_bot.id) &&
+ record.namespace.automation_bot && (record.submitter.id == record.namespace.automation_bot.id) &&
(effective_access_level >= Member::AccessLevel::ANALYST)
return true
end
@@ -95,7 +95,7 @@ def update? # rubocop:disable Metrics/AbcSize
# submitted by automation bot and user is analyst or higher
if (record.namespace.type == Namespaces::ProjectNamespace.sti_name) &&
- (record.submitter.id == record.namespace.automation_bot.id) &&
+ record.namespace.automation_bot && (record.submitter.id == record.namespace.automation_bot.id) &&
(effective_access_level >= Member::AccessLevel::ANALYST)
return true
end
From ecfcfd6b7752184d087e29e83bf0f3434d734cc2 Mon Sep 17 00:00:00 2001
From: Meghan Chua <17057809+malchua@users.noreply.github.com>
Date: Thu, 6 Feb 2025 15:58:39 -0600
Subject: [PATCH 55/57] Add shared workflow tests to data_exports_test
---
test/system/data_exports_test.rb | 280 +++++++++++++++++++++++++++++++
1 file changed, 280 insertions(+)
diff --git a/test/system/data_exports_test.rb b/test/system/data_exports_test.rb
index 8bc4d4e122..4d0c46cb69 100644
--- a/test/system/data_exports_test.rb
+++ b/test/system/data_exports_test.rb
@@ -15,7 +15,9 @@ def setup # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
@data_export9 = data_exports(:data_export_nine)
@data_export10 = data_exports(:data_export_ten)
@group1 = groups(:group_one)
+ @group5 = groups(:group_five)
@project1 = projects(:project1)
+ @project22 = projects(:project22)
@sample1 = samples(:sample1)
@sample2 = samples(:sample2)
@sample30 = samples(:sample30)
@@ -24,6 +26,8 @@ def setup # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
@workflow_execution3 = workflow_executions(:irida_next_example_error)
@workflow_execution4 = workflow_executions(:automated_workflow_execution)
@workflow_execution5 = workflow_executions(:automated_example_error)
+ @shared_workflow_execution1 = workflow_executions(:workflow_execution_completed_shared1)
+ @shared_workflow_execution2 = workflow_executions(:workflow_execution_completed_shared2)
Project.reset_counters(@project1.id, :samples_count)
@@ -529,6 +533,173 @@ def end
assert_selector 'div:nth-child(2) dd', text: 'test data export'
end
+ test 'create analysis export using users shared workflow execution from user workflow execution show page' do
+ login_as users(:james_doe)
+ visit workflow_execution_path(@shared_workflow_execution1)
+
+ click_link I18n.t('workflow_executions.show.create_export_button'), match: :first
+
+ within 'dialog[open].dialog--size-lg' do
+ assert_accessible
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.title')
+ assert_text I18n.t('data_exports.new_single_analysis_export_dialog.single_selection')
+ assert_text I18n.t('data_exports.new.name_label')
+ assert_text I18n.t('data_exports.new.email_label')
+
+ assert_no_selector 'turbo-frame[id="list_selections"]'
+ assert_no_text @shared_workflow_execution1.id
+ assert_no_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_no_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+
+ click_button I18n.t('data_exports.new_single_analysis_export_dialog.single_selection')
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+ assert_text @shared_workflow_execution1.id
+ assert_text @shared_workflow_execution1.run_id
+ assert_text @shared_workflow_execution1.metadata['workflow_name']
+ assert_text @shared_workflow_execution1.metadata['workflow_version']
+
+ find('input#data_export_name').fill_in with: 'test data export'
+ find("input[type='checkbox'][id='data_export_email_notification']").click
+ click_button I18n.t('data_exports.new.submit_button')
+ end
+
+ assert_selector 'dl', count: 1
+ assert_selector 'div:nth-child(2) dd', text: 'test data export'
+ end
+
+ test 'create analysis export using users shared workflow execution from project workflow execution show page' do
+ login_as users(:james_doe)
+ visit namespace_project_workflow_execution_path(@group5, @project22, @shared_workflow_execution1)
+
+ click_link I18n.t('workflow_executions.show.create_export_button'), match: :first
+
+ within 'dialog[open].dialog--size-lg' do
+ assert_accessible
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.title')
+ assert_text I18n.t('data_exports.new_single_analysis_export_dialog.single_selection')
+ assert_text I18n.t('data_exports.new.name_label')
+ assert_text I18n.t('data_exports.new.email_label')
+
+ assert_no_selector 'turbo-frame[id="list_selections"]'
+ assert_no_text @shared_workflow_execution1.id
+ assert_no_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_no_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+
+ click_button I18n.t('data_exports.new_single_analysis_export_dialog.single_selection')
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+ assert_text @shared_workflow_execution1.id
+ assert_text @shared_workflow_execution1.run_id
+ assert_text @shared_workflow_execution1.metadata['workflow_name']
+ assert_text @shared_workflow_execution1.metadata['workflow_version']
+
+ find('input#data_export_name').fill_in with: 'test data export'
+ find("input[type='checkbox'][id='data_export_email_notification']").click
+ click_button I18n.t('data_exports.new.submit_button')
+ end
+
+ assert_selector 'dl', count: 1
+ assert_selector 'div:nth-child(2) dd', text: 'test data export'
+ end
+
+ test 'create analysis export from project shared workflow execution from project workflow execution show page' do
+ login_as users(:james_doe)
+ visit namespace_project_workflow_execution_path(@group5, @project22, @shared_workflow_execution2)
+
+ click_link I18n.t('workflow_executions.show.create_export_button'), match: :first
+
+ within 'dialog[open].dialog--size-lg' do
+ assert_accessible
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.title')
+ assert_text I18n.t('data_exports.new_single_analysis_export_dialog.single_selection')
+ assert_text I18n.t('data_exports.new.name_label')
+ assert_text I18n.t('data_exports.new.email_label')
+
+ assert_no_selector 'turbo-frame[id="list_selections"]'
+ assert_no_text @shared_workflow_execution2.id
+ assert_no_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_no_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+
+ click_button I18n.t('data_exports.new_single_analysis_export_dialog.single_selection')
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+ assert_text @shared_workflow_execution2.id
+ assert_text @shared_workflow_execution2.run_id
+ assert_text @shared_workflow_execution2.metadata['workflow_name']
+ assert_text @shared_workflow_execution2.metadata['workflow_version']
+
+ find('input#data_export_name').fill_in with: 'test data export'
+ find("input[type='checkbox'][id='data_export_email_notification']").click
+ click_button I18n.t('data_exports.new.submit_button')
+ end
+
+ assert_selector 'dl', count: 1
+ assert_selector 'div:nth-child(2) dd', text: 'test data export'
+ end
+
+ test 'clicking links in preview tab for analysis data export from user shared workflow execution' do
+ login_as users(:micha_doe)
+ sample47 = samples(:sample47)
+ data_export11 = data_exports(:data_export_eleven)
+ visit data_export_path(data_export11, tab: 'preview')
+
+ click_link @shared_workflow_execution2.id
+
+ assert_current_path(workflow_execution_path(@shared_workflow_execution2))
+ assert_text @shared_workflow_execution2.id
+
+ within first('dl') do
+ assert_text @shared_workflow_execution2.run_id
+ assert_text @shared_workflow_execution2.metadata['workflow_name']
+ assert_text @shared_workflow_execution2.metadata['workflow_version']
+ end
+
+ visit data_export_path(data_export11, tab: 'preview')
+
+ click_link sample47.puid
+
+ assert_text sample47.name
+ assert_text sample47.puid
+ end
+
+ test 'clicking links in preview tab for analysis data export from project shared workflow execution' do
+ login_as users(:james_doe)
+ sample47 = samples(:sample47)
+ data_export11 = data_exports(:data_export_twelve)
+ visit data_export_path(data_export11, tab: 'preview')
+
+ click_link @shared_workflow_execution2.id
+
+ assert_current_path(namespace_project_workflow_execution_path(@group5, @project22, @shared_workflow_execution2))
+ assert_text @shared_workflow_execution2.id
+
+ within first('dl') do
+ assert_text @shared_workflow_execution2.run_id
+ assert_text @shared_workflow_execution2.metadata['workflow_name']
+ assert_text @shared_workflow_execution2.metadata['workflow_version']
+ end
+
+ visit data_export_path(data_export11, tab: 'preview')
+
+ click_link sample47.puid
+
+ assert_text sample47.name
+ assert_text sample47.puid
+ end
+
test 'create export state between completed and non-completed workflow executions' do
submitted_workflow_execution = workflow_executions(:irida_next_example_submitted)
visit workflow_execution_path(submitted_workflow_execution)
@@ -989,6 +1160,115 @@ def end
assert_selector 'div:nth-child(2) dd', text: 'test data export'
end
+ test 'create analysis export with a workflow execution from user workflow executions index page' do
+ login_as users(:james_doe)
+ visit workflow_executions_path
+ assert_selector 'a.pointer-events-none.cursor-not-allowed.bg-slate-100.text-slate-600',
+ text: I18n.t('workflow_executions.index.create_export_button')
+
+ within %(#workflow-executions-table) do
+ find("input[type='checkbox'][value='#{@shared_workflow_execution1.id}']").click
+ end
+
+ assert_no_selector 'a.pointer-events-none.cursor-not-allowed.bg-slate-100.text-slate-600',
+ text: I18n.t('workflow_executions.index.create_export_button')
+ click_link I18n.t('workflow_executions.index.create_export_button')
+
+ within 'dialog[open].dialog--size-lg' do
+ assert_accessible
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.title')
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.selection_count.non_zero').gsub! 'COUNT_PLACEHOLDER',
+ '1'
+ assert_text I18n.t('data_exports.new.name_label')
+ assert_text I18n.t('data_exports.new.email_label')
+
+ assert_no_selector 'turbo-frame[id="list_selections"]'
+ assert_no_text @shared_workflow_execution1.id
+ assert_no_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_no_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+ click_button I18n.t('data_exports.new_analysis_export_dialog.selection_count.non_zero').gsub! 'COUNT_PLACEHOLDER',
+ '1'
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.description.singular')
+ assert_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+ assert_selector 'turbo-frame[id="list_selections"]'
+ within %(turbo-frame[id="list_selections"]) do
+ assert_text @shared_workflow_execution1.id
+ assert_text @shared_workflow_execution1.run_id
+ assert_text @shared_workflow_execution1.metadata['workflow_name']
+ assert_text @shared_workflow_execution1.metadata['workflow_version']
+ end
+
+ find('input#data_export_name').fill_in with: 'test data export'
+ find("input[type='checkbox'][id='data_export_email_notification']").click
+ click_button I18n.t('data_exports.new.submit_button')
+ end
+
+ assert_selector 'dl', count: 1
+ assert_selector 'div:nth-child(2) dd', text: 'test data export'
+ assert_selector 'div#data-export-tabs'
+ end
+
+ test 'create analysis export with multiple shared workflow executions from project workflow executions index page' do
+ login_as users(:james_doe)
+ visit namespace_project_workflow_executions_path(@group5, @project22)
+ assert_selector 'a.pointer-events-none.cursor-not-allowed.bg-slate-100.text-slate-600',
+ text: I18n.t('projects.workflow_executions.index.create_export_button')
+
+ within %(#workflow-executions-table) do
+ find("input[type='checkbox'][value='#{@shared_workflow_execution1.id}']").click
+ find("input[type='checkbox'][value='#{@shared_workflow_execution2.id}']").click
+ end
+
+ assert_no_selector 'a.pointer-events-none.cursor-not-allowed.bg-slate-100.text-slate-600',
+ text: I18n.t('projects.workflow_executions.index.create_export_button')
+ click_link I18n.t('projects.workflow_executions.index.create_export_button')
+
+ within 'dialog[open].dialog--size-lg' do
+ assert_accessible
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.title')
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.selection_count.non_zero').gsub! 'COUNT_PLACEHOLDER',
+ '2'
+ assert_text I18n.t('data_exports.new.name_label')
+ assert_text I18n.t('data_exports.new.email_label')
+
+ assert_no_selector 'turbo-frame[id="list_selections"]'
+ assert_no_text @shared_workflow_execution1.id
+ assert_no_text @shared_workflow_execution2.id
+ assert_no_text I18n.t('data_exports.new_analysis_export_dialog.description.plural').gsub! 'COUNT_PLACEHOLDER', '2'
+ assert_no_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+ click_button I18n.t('data_exports.new_analysis_export_dialog.selection_count.non_zero').gsub! 'COUNT_PLACEHOLDER',
+ '2'
+ assert_text I18n.t('data_exports.new_analysis_export_dialog.description.plural').gsub! 'COUNT_PLACEHOLDER', '2'
+ assert_text ActionController::Base.helpers.strip_tags(
+ I18n.t('data_exports.new.after_submission_description_html')
+ )
+ assert_selector 'turbo-frame[id="list_selections"]'
+ within %(turbo-frame[id="list_selections"]) do
+ assert_text @shared_workflow_execution1.id
+ assert_text @shared_workflow_execution1.run_id
+ assert_text @shared_workflow_execution1.metadata['workflow_name']
+ assert_text @shared_workflow_execution1.metadata['workflow_version']
+ assert_text @shared_workflow_execution2.id
+ assert_text @shared_workflow_execution2.run_id
+ assert_text @shared_workflow_execution2.metadata['workflow_name']
+ assert_text @shared_workflow_execution2.metadata['workflow_version']
+ end
+
+ find('input#data_export_name').fill_in with: 'test data export'
+ find("input[type='checkbox'][id='data_export_email_notification']").click
+ click_button I18n.t('data_exports.new.submit_button')
+ end
+
+ assert_selector 'dl', count: 1
+ assert_selector 'div:nth-child(2) dd', text: 'test data export'
+ end
+
test 'cannot create analysis export with non-completed workflow executions from user WE index page' do
visit workflow_executions_path
assert_selector 'a.pointer-events-none.cursor-not-allowed.bg-slate-100.text-slate-600',
From 7c93893609ca4aa55932cbf8d111ea450968b07e Mon Sep 17 00:00:00 2001
From: Meghan Chua <17057809+malchua@users.noreply.github.com>
Date: Thu, 6 Feb 2025 15:59:57 -0600
Subject: [PATCH 56/57] Fix bug where incorrect redirect path is used
---
app/controllers/data_exports_controller.rb | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/controllers/data_exports_controller.rb b/app/controllers/data_exports_controller.rb
index 1e22ea86c5..924958154c 100644
--- a/app/controllers/data_exports_controller.rb
+++ b/app/controllers/data_exports_controller.rb
@@ -176,11 +176,16 @@ def redirect_to_project
redirect_to namespace_project_path(project.parent, project)
end
- def redirect_to_workflow_execution
+ def redirect_to_workflow_execution # rubocop:disable Metrics/AbcSize
workflow_execution = WorkflowExecution.find_by(id: params['identifier'])
submitter = workflow_execution.submitter
if submitter.user_type == 'human'
- redirect_to workflow_execution_path(workflow_execution)
+ if workflow_execution.submitter == current_user
+ redirect_to workflow_execution_path(workflow_execution)
+ else
+ namespace = workflow_execution.namespace
+ redirect_to namespace_project_workflow_execution_path(namespace.parent, namespace.project, workflow_execution)
+ end
else
namespace = Namespace.find_by(puid: submitter.first_name)
redirect_to namespace_project_workflow_execution_path(namespace.parent, namespace.project, workflow_execution)
From 73daa197ef3adbeef83c26bbb15a0f01cccab9f9 Mon Sep 17 00:00:00 2001
From: Meghan Chua <17057809+malchua@users.noreply.github.com>
Date: Fri, 7 Feb 2025 10:14:51 -0600
Subject: [PATCH 57/57] Simplify redirect_to_project method
---
app/controllers/data_exports_controller.rb | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/app/controllers/data_exports_controller.rb b/app/controllers/data_exports_controller.rb
index 924958154c..9c02151cb9 100644
--- a/app/controllers/data_exports_controller.rb
+++ b/app/controllers/data_exports_controller.rb
@@ -176,18 +176,12 @@ def redirect_to_project
redirect_to namespace_project_path(project.parent, project)
end
- def redirect_to_workflow_execution # rubocop:disable Metrics/AbcSize
+ def redirect_to_workflow_execution
workflow_execution = WorkflowExecution.find_by(id: params['identifier'])
- submitter = workflow_execution.submitter
- if submitter.user_type == 'human'
- if workflow_execution.submitter == current_user
- redirect_to workflow_execution_path(workflow_execution)
- else
- namespace = workflow_execution.namespace
- redirect_to namespace_project_workflow_execution_path(namespace.parent, namespace.project, workflow_execution)
- end
+ if workflow_execution.submitter == current_user
+ redirect_to workflow_execution_path(workflow_execution)
else
- namespace = Namespace.find_by(puid: submitter.first_name)
+ namespace = workflow_execution.namespace
redirect_to namespace_project_workflow_execution_path(namespace.parent, namespace.project, workflow_execution)
end
end