Skip to content

Commit

Permalink
add filter to workflow execution pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHuynh333 committed Oct 18, 2024
1 parent 6a58660 commit 44c05ec
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 58 deletions.
4 changes: 4 additions & 0 deletions app/models/workflow_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def as_wes_params
}.compact
end

ransacker :id do
Arel.sql('id::varchar')
end

def self.ransackable_attributes(_auth_object = nil)
%w[id name run_id state created_at updated_at]
end
Expand Down
13 changes: 12 additions & 1 deletion app/views/projects/workflow_executions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<% end %>
<% end %>
<div class="flow-root">
<div class="flex mb-2">
<% if allowed_to?(:export_data?, @project.namespace) %>
<div class="float-left inline-flex space-x-2 mb-4">
<div class="inline-flex grow space-x-2 mb-4">
<%= search_form_for(
@q,
url: select_namespace_project_workflow_executions_url(**request.query_parameters),
Expand All @@ -51,7 +52,17 @@
<% end %>
</div>
<% end %>
<div class="grow-0">
<%= render SearchComponent.new(
query: @q,
url: namespace_project_workflow_executions_path(**request.query_parameters),
search_attribute: :name_or_id_cont,
placeholder: t('.search.placeholder')
) %>
</div>
</div>
</div>

<%= render partial: "table",
locals: {
workflow_executions: @workflow_executions,
Expand Down
54 changes: 32 additions & 22 deletions app/views/workflow_executions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,38 @@
<% end %>
<% end %>
<div class="flow-root">
<div class="float-left inline-flex space-x-2 mb-4">
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "select-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<input type="hidden" name="select" value="on"/>
<%= f.submit t(".select_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "deselect-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<%= f.submit t(".deselect_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
<div class="flex mb-2">
<div class="inline-flex grow space-x-2">
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "select-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<input type="hidden" name="select" value="on"/>
<%= f.submit t(".select_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
<%= search_form_for(
@q,
url: select_workflow_executions_url(**request.query_parameters),
html: { id: "deselect-all-form" },
class: "filters align-middle"
) do |f| %>
<input type="hidden" name="format" value="turbo_stream"/>
<%= f.submit t(".deselect_all_button"),
class: "button button--state-default button--size-default" %>
<% end %>
</div>
<div class="grow-0">
<%= render SearchComponent.new(
query: @q,
url: workflow_executions_path,
search_attribute: :name_or_id_cont,
placeholder: t('.search.placeholder')
) %>
</div>
</div>
</div>
<%= render partial: "table",
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,8 @@ en:
index:
create_export_button: Create Export
deselect_all_button: Deselect All
search:
placeholder: Filter by ID or name
select_all_button: Select All
subtitle: These are the workflow executions that have been automatically launched for this project
title: Workflow Executions
Expand Down Expand Up @@ -1686,6 +1688,8 @@ en:
delete_confirm: Are you sure you want to delete this workflow execution?
create_export_button: Create Export
deselect_all_button: Deselect All
search:
placeholder: Filter by ID or name
select_all_button: Select All
title: Workflow Executions
samples:
Expand Down
4 changes: 3 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,9 @@ def seed_exports # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metric
# prevent workflow and workflow attachment broadcasts
Attachment.suppressing_turbo_broadcasts do
WorkflowExecution.suppressing_turbo_broadcasts do
seed_workflow_executions
100.times do
seed_workflow_executions
end
end
end
# prevent data export broadcasts
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/workflow_executions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ irida_next_example_completed_2_files:
run_id: "my_run_id_6"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:john_doe, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:project1_namespace, :uuid) %>
name: 'irida_next_example_completed_2_files'
state: "completed"
blob_run_directory: "not a run dir"
cleaned: true
Expand Down Expand Up @@ -479,6 +480,7 @@ irida_next_example_completed_with_output:
run_id: "my_run_id_13"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:john_doe, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:projectA_namespace, :uuid) %>
name: "irida_next_example_completed_with_output"
state: "completed"
blob_run_directory: "not a run dir"
cleaned: false
Expand Down Expand Up @@ -602,6 +604,7 @@ automated_example_completed:
run_id: "my_run_id_6"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:project1_automation_bot, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:project1_namespace, :uuid) %>
name: "autmoated_example_completed"
state: "completed"
blob_run_directory: "not a run dir"
cleaned: true
Expand Down Expand Up @@ -663,6 +666,7 @@ automated_example_canceled:
run_id: "my_run_id_9"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:project1_automation_bot, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:project1_namespace, :uuid) %>
name: "automated_example_canceled"
state: "canceled"
cleaned: true

Expand Down
82 changes: 64 additions & 18 deletions test/system/projects/workflow_executions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase
login_as @user
@namespace = groups(:group_one)
@project = projects(:project1)
@workflow_execution1 = workflow_executions(:automated_example_completed)
@workflow_execution2 = workflow_executions(:automated_example_canceled)

@id_col = '1'
@name_col = '2'
Expand All @@ -30,8 +32,7 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase

test 'should sort a list of workflow executions' do
workflow_execution1 = workflow_executions(:automated_workflow_execution)
workflow_execution2 = workflow_executions(:automated_example_canceling)
workflow_execution3 = workflow_executions(:automated_example_canceled)
workflow_execution3 = workflow_executions(:automated_example_canceling)
workflow_execution4 = workflow_executions(:automated_workflow_execution_existing)

visit namespace_project_workflow_executions_path(@namespace, @project)
Expand All @@ -46,16 +47,16 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase
assert_selector 'tr', count: 10
assert_selector "tr:first-child td:nth-child(#{@run_id_col})", text: workflow_execution4.run_id
assert_selector "tr:nth-child(#{@run_id_col}) td:nth-child(#{@run_id_col})", text: workflow_execution1.run_id
assert_selector "tr:last-child td:nth-child(#{@run_id_col})", text: workflow_execution3.run_id
assert_selector "tr:last-child td:nth-child(#{@run_id_col})", text: @workflow_execution2.run_id
end

click_on 'Run ID'
assert_selector "#workflow-executions-table table thead th:nth-child(#{@run_id_col}) svg.icon-arrow_down"

within('#workflow-executions-table table tbody') do
assert_selector 'tr', count: 10
assert_selector "tr:first-child td:nth-child(#{@run_id_col})", text: workflow_execution3.run_id
assert_selector "tr:nth-child(2) td:nth-child(#{@run_id_col})", text: workflow_execution2.run_id
assert_selector "tr:first-child td:nth-child(#{@run_id_col})", text: @workflow_execution2.run_id
assert_selector "tr:nth-child(2) td:nth-child(#{@run_id_col})", text: workflow_execution3.run_id
assert_selector "tr:last-child td:nth-child(#{@run_id_col})", text: workflow_execution4.run_id
end

Expand All @@ -65,9 +66,9 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase
within('#workflow-executions-table table tbody') do
assert_selector 'tr', count: 10
assert_selector "tr:first-child td:nth-child(#{@workflow_name_col})",
text: workflow_execution3.metadata['workflow_name']
text: @workflow_execution2.metadata['workflow_name']
assert_selector "tr:nth-child(2) td:nth-child(#{@workflow_name_col})",
text: workflow_execution2.metadata['workflow_name']
text: workflow_execution3.metadata['workflow_name']
assert_selector "tr:last-child td:nth-child(#{@workflow_name_col})",
text: workflow_execution4.metadata['workflow_name']
end
Expand All @@ -82,7 +83,7 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase
assert_selector "tr:nth-child(2) td:nth-child(#{@workflow_name_col})",
text: workflow_execution1.metadata['workflow_name']
assert_selector "tr:last-child td:nth-child(#{@workflow_name_col})",
text: workflow_execution3.metadata['workflow_name']
text: @workflow_execution2.metadata['workflow_name']
end
end

Expand Down Expand Up @@ -152,18 +153,16 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase
end

test 'should delete a completed workflow' do
workflow_execution = workflow_executions(:automated_example_completed)

visit namespace_project_workflow_executions_path(@namespace, @project)

assert_selector 'h1', text: I18n.t(:'projects.workflow_executions.index.title')
assert_selector 'p', text: I18n.t(:'projects.workflow_executions.index.subtitle')

tr = find('a', text: workflow_execution.id).ancestor('tr')
tr = find('a', text: @workflow_execution1.id).ancestor('tr')

within tr do
assert_selector "td:nth-child(#{@state_col})",
text: I18n.t(:"workflow_executions.state.#{workflow_execution.state}")
text: I18n.t(:"workflow_executions.state.#{@workflow_execution1.state}")
assert_link 'Delete', count: 1
click_link 'Delete'
end
Expand All @@ -174,11 +173,11 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase
within %(div[data-controller='viral--flash']) do
assert_text I18n.t(
:'concerns.workflow_execution_actions.destroy.success',
workflow_name: workflow_execution.metadata['workflow_name']
workflow_name: @workflow_execution1.metadata['workflow_name']
)
end

assert_no_text workflow_execution.id
assert_no_text @workflow_execution1.id
end

test 'should delete an errored workflow' do
Expand Down Expand Up @@ -307,9 +306,7 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase
end

test 'can remove workflow execution from workflow execution page' do
workflow_execution = workflow_executions(:automated_example_completed)

visit namespace_project_workflow_execution_path(@namespace, @project, workflow_execution)
visit namespace_project_workflow_execution_path(@namespace, @project, @workflow_execution1)

click_link I18n.t(:'projects.workflow_executions.show.remove_button')

Expand All @@ -319,7 +316,56 @@ class WorkflowExecutionsTest < ApplicationSystemTestCase

within %(#workflow-executions-table table tbody) do
assert_selector 'tr', count: 9
assert_no_text workflow_execution.id
assert_no_text @workflow_execution1.id
end
end

test 'can filter by ID and name on projects workflow execution index page' do
visit namespace_project_workflow_executions_path(@namespace, @project)

assert_text 'Displaying 10 items'
assert_selector 'table tbody tr', count: 10

within('table tbody') do
assert_text @workflow_execution1.id
assert_text @workflow_execution1.name
assert_text @workflow_execution2.id
assert_text @workflow_execution2.name
end

fill_in placeholder: I18n.t(:'workflow_executions.index.search.placeholder'),
with: @workflow_execution1.id
find('input.t-search-component').native.send_keys(:return)

assert_text 'Displaying 1 item'
assert_selector 'table tbody tr', count: 1

within('table tbody') do
assert_text @workflow_execution1.id
assert_text @workflow_execution1.name
assert_no_text @workflow_execution2.id
assert_no_text @workflow_execution2.name
end

fill_in placeholder: I18n.t(:'workflow_executions.index.search.placeholder'),
with: ''
find('input.t-search-component').native.send_keys(:return)

assert_text 'Displaying 10 items'
assert_selector 'table tbody tr', count: 10

fill_in placeholder: I18n.t(:'workflow_executions.index.search.placeholder'),
with: @workflow_execution2.name
find('input.t-search-component').native.send_keys(:return)

assert_text 'Displaying 1 item'
assert_selector 'table tbody tr', count: 1

within('table tbody') do
assert_no_text @workflow_execution1.id
assert_no_text @workflow_execution1.name
assert_text @workflow_execution2.id
assert_text @workflow_execution2.name
end
end
end
Expand Down
Loading

0 comments on commit 44c05ec

Please sign in to comment.