Skip to content

Commit

Permalink
Selenium tests for workflow editor changes stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Nov 27, 2024
1 parent 1e15e48 commit 5a5b7ce
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 3 deletions.
13 changes: 12 additions & 1 deletion client/src/components/UndoRedo/UndoRedoStack.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { useUndoRedoStore } from "@/stores/undoRedoStore";
import { type UndoRedoAction, useUndoRedoStore } from "@/stores/undoRedoStore";
import ActivityPanel from "../Panels/ActivityPanel.vue";
Expand All @@ -16,6 +16,15 @@ watch(
(id) => (currentStore.value = useUndoRedoStore(id))
);
function dataAttributes(action: UndoRedoAction): Record<string, string> {
const result: Record<string, string> = {};
for (const [key, value] of Object.entries(action.dataAttributes)) {
result[`data-${key}`] = value;
}
return result;
}
function onInput(event: Event) {
const value = (event.target as HTMLInputElement).value;
const valueNumber = parseFloat(value);
Expand All @@ -37,6 +46,7 @@ function updateSavedUndoActions() {
<div class="scroll-list">
<button
v-for="action in currentStore.redoActionStack"
v-bind="dataAttributes(action)"
:key="action.id"
class="action future"
@click="currentStore.rollForwardTo(action)">
Expand All @@ -51,6 +61,7 @@ function updateSavedUndoActions() {

<button
v-for="action in [...currentStore.undoActionStack].reverse()"
v-bind="dataAttributes(action)"
:key="action.id"
class="action past"
@click="currentStore.rollBackTo(action)">
Expand Down
7 changes: 7 additions & 0 deletions client/src/components/Workflow/Editor/Actions/stepActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ export class InsertStepAction extends UndoRedoAction {
return `insert ${this.stepData.name}`;
}

get dataAttributes(): Record<string, string> {
return {
type: "step-insert",
"step-type": this.stepData.type as string,
};
}

stepDataToTuple() {
return Object.values(this.stepData) as Parameters<WorkflowStepStore["insertNewStep"]>;
}
Expand Down
4 changes: 4 additions & 0 deletions client/src/stores/undoRedoStore/undoRedoAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class UndoRedoAction {
destroy() {
return;
}

get dataAttributes(): Record<string, string> {
return {};
}
}

export class LazyUndoRedoAction extends UndoRedoAction {
Expand Down
7 changes: 7 additions & 0 deletions client/src/utils/navigation/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,12 @@ workflow_editor:
connector_destroy_callout: "${_} [input-name='${name}'] + .delete-terminal-button"
workflow_output_toggle: "${_} [data-output-name='${name}'] .callout-terminal "
workflow_output_toggle_active: "${_} [data-output-name='${name}'] .mark-terminal-active"
changes:
selectors:
action_insert_data_input: ".action[data-type='step-insert'][data-step-type='data_input']"
action_insert_data_collection_input: ".action[data-type='step-insert'][data-step-type='data_collection_input']"
action_insert_parameter: ".action[data-type='step-insert'][data-step-type='parameter_input']"

tool_bar:
selectors:
_: ".workflow-editor-toolbar"
Expand All @@ -736,6 +742,7 @@ workflow_editor:
duplicate_selection: "[title='duplicate selected']"
delete_selection: "[title='delete selected']"
auto_layout: "#auto-layout-button"
changes: "#activity-workflow-undo-redo"
comment:
selectors:
_: ".workflow-editor-comment"
Expand Down
53 changes: 51 additions & 2 deletions lib/galaxy_test/selenium/test_workflow_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,52 @@ def test_reconnecting_nodes(self):
self.workflow_index_open_with_name(name)
self.assert_connected("input1#output", "first_cat#input1")

@selenium_test
def test_editor_change_stack(self):
editor = self.components.workflow_editor
annotation = "change_stack_test"
name = self.workflow_create_new(annotation=annotation)

self.workflow_editor_set_license("MIT")
self.workflow_editor_click_save()

self.workflow_editor_add_input(item_name="data_input")
self.workflow_editor_add_input(item_name="data_collection_input")
self.workflow_editor_add_input(item_name="parameter_input")

editor.node.by_id(id=0).wait_for_present()
editor.node.by_id(id=1).wait_for_present()
editor.node.by_id(id=2).wait_for_present()

editor.tool_bar.changes.wait_for_and_click()
changes = editor.changes

changes.action_insert_data_input.wait_for_present()
changes.action_insert_data_collection_input.wait_for_present()
changes.action_insert_parameter.wait_for_present()

# Undo all of it by clicking the first node.
changes.action_insert_data_input.wait_for_and_click()
editor.node.by_id(id=0).assert_absent_or_hidden_after_transitions()
editor.node.by_id(id=1).assert_absent_or_hidden_after_transitions()
editor.node.by_id(id=2).assert_absent_or_hidden_after_transitions()

# now that same action has become a redo, so we should have a node back afterward.
changes.action_insert_data_input.wait_for_and_click()
editor.node.by_id(id=0).wait_for_present()
editor.node.by_id(id=1).assert_absent_or_hidden_after_transitions()
editor.node.by_id(id=2).assert_absent_or_hidden_after_transitions()

changes.action_insert_data_collection_input.wait_for_and_click()
editor.node.by_id(id=0).wait_for_present()
editor.node.by_id(id=1).wait_for_present()
editor.node.by_id(id=2).assert_absent_or_hidden_after_transitions()

changes.action_insert_parameter.wait_for_and_click()
editor.node.by_id(id=0).wait_for_present()
editor.node.by_id(id=1).wait_for_present()
editor.node.by_id(id=2).wait_for_present()

@selenium_test
def test_rendering_output_collection_connections(self):
self.open_in_workflow_editor(WORKFLOW_WITH_OUTPUT_COLLECTION)
Expand Down Expand Up @@ -1417,8 +1463,11 @@ def workflow_editor_add_input(self, item_name="data_input"):
editor.canvas_body.wait_for_visible()

self.open_toolbox()
editor.tool_menu_section_link(section_name="inputs").wait_for_and_click()
editor.tool_menu_item_link(item_name=item_name).wait_for_and_click()
input_item = editor.tool_menu_item_link(item_name=item_name)
if input_item.is_absent or not input_item.is_displayed:
editor.tool_menu_section_link(section_name="inputs").wait_for_and_click()

input_item.wait_for_and_click()

def workflow_editor_destroy_connection(self, sink):
editor = self.components.workflow_editor
Expand Down

0 comments on commit 5a5b7ce

Please sign in to comment.