Skip to content

Commit

Permalink
Expand change stack UI testing...
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Dec 8, 2024
1 parent 9049a85 commit 7e2d581
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 27 deletions.
33 changes: 30 additions & 3 deletions client/src/components/Workflow/Editor/Actions/workflowActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ export class LazySetValueAction<T> extends LazyUndoRedoAction {
showAttributesCallback;
fromValue;
toValue;
what: string | null;

constructor(fromValue: T, toValue: T, setValueHandler: (value: T) => void, showCanvasCallback: () => void) {
constructor(
fromValue: T,
toValue: T,
setValueHandler: (value: T) => void,
showCanvasCallback: () => void,
what: string | null = null
) {
super();
this.fromValue = structuredClone(fromValue);
this.toValue = structuredClone(toValue);
this.setValueHandler = setValueHandler;
this.showAttributesCallback = showCanvasCallback;
this.what = what;
}

queued() {
Expand All @@ -46,6 +54,16 @@ export class LazySetValueAction<T> extends LazyUndoRedoAction {
this.setValueHandler(this.toValue);
}

get dataAttributes(): Record<string, string> {
if (this.what) {
return {
type: `set-${this.what}`,
};
} else {
return {};
}
}

get name() {
return this.internalName ?? "modify workflow";
}
Expand All @@ -61,24 +79,33 @@ export class SetValueActionHandler<T> {
showAttributesCallback;
lazyAction: LazySetValueAction<T> | null = null;
name?: string;
what: string | null;

constructor(
undoRedoStore: UndoRedoStore,
setValueHandler: (value: T) => void,
showCanvasCallback: () => void,
name?: string
name?: string,
what: string | null = null
) {
this.undoRedoStore = undoRedoStore;
this.setValueHandler = setValueHandler;
this.showAttributesCallback = showCanvasCallback;
this.name = name;
this.what = what;
}

set(from: T, to: T) {
if (this.lazyAction && this.undoRedoStore.isQueued(this.lazyAction)) {
this.lazyAction.changeValue(to);
} else {
this.lazyAction = new LazySetValueAction<T>(from, to, this.setValueHandler, this.showAttributesCallback);
this.lazyAction = new LazySetValueAction<T>(
from,
to,
this.setValueHandler,
this.showAttributesCallback,
this.what
);
this.lazyAction.name = this.name;
this.undoRedoStore.applyLazyAction(this.lazyAction);
}
Expand Down
9 changes: 6 additions & 3 deletions client/src/components/Workflow/Editor/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ export default {
undoRedoStore,
(value) => (license.value = value),
showAttributes,
"set license"
"set license",
"license"
);
/** user set license. queues an undo/redo action */
function setLicense(newLicense) {
Expand All @@ -347,7 +348,8 @@ export default {
undoRedoStore,
(value) => (creator.value = value),
showAttributes,
"set creator"
"set creator",
"creator"
);
/** user set creator. queues an undo/redo action */
function setCreator(newCreator) {
Expand All @@ -359,7 +361,8 @@ export default {
undoRedoStore,
(value) => (annotation.value = value),
showAttributes,
"modify annotation"
"modify annotation",
"annotation"
);
/** user set annotation. queues an undo/redo action */
function setAnnotation(newAnnotation) {
Expand Down
3 changes: 3 additions & 0 deletions client/src/utils/navigation/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ workflow_editor:
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']"
action_set_license: ".action[data-type='set-license']"
action_set_annotation: ".action[data-type='set-annotation']"

tool_bar:
selectors:
Expand All @@ -745,6 +747,7 @@ workflow_editor:
duplicate_selection: "[title='duplicate selected']"
delete_selection: "[title='delete selected']"
auto_layout: "#auto-layout-button"
attributes: "#activity-workflow-editor-attributes"
changes: "#activity-workflow-undo-redo"
upgrade_all: "#activity-workflow-upgrade"
comment:
Expand Down
21 changes: 12 additions & 9 deletions lib/galaxy/selenium/navigates_galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,14 +1224,14 @@ def workflow_editor_set_license(self, license: str) -> None:
license_selector_option = self.components.workflow_editor.license_selector_option
license_selector_option.wait_for_and_click()

def workflow_editor_license_text(self) -> str:
editor = self.components.workflow_editor
editor.license_selector.wait_for_visible()
return editor.license_current_value.wait_for_text()

def workflow_editor_add_tool_step(self, tool_id: str):
self.tool_open(tool_id)

def workflow_editor_set_label(self, label: str, node: Optional[EditorNodeReference] = None):
editor = self.components.workflow_editor
self.workflow_editor_ensure_tool_form_open(node)
self.set_text_element(editor.label_input, label)

def workflow_editor_set_tool_vesrion(self, version: str, node: Optional[EditorNodeReference] = None) -> None:
editor = self.components.workflow_editor
self.workflow_editor_ensure_tool_form_open(node)
Expand All @@ -1243,10 +1243,10 @@ def workflow_editor_ensure_tool_form_open(self, node: Optional[EditorNodeReferen
editor = self.components.workflow_editor
if node is not None:
if isinstance(node, int):
node = editor.node.by_id(id=node)
node_component = editor.node.by_id(id=node)
else:
node = editor.node._(label=node)
node.wait_for_and_click()
node_component = editor.node._(label=node)
node_component.wait_for_and_click()
editor.node_inspector.wait_for_visible()

def workflow_editor_click_option(self, option_label):
Expand Down Expand Up @@ -1696,7 +1696,7 @@ def workflow_create_new(
name_component.wait_for_visible().clear()
name_component.wait_for_and_send_keys(name)
annotation = annotation or self._get_random_name()
self.components.workflow_editor.edit_annotation.wait_for_and_send_keys(annotation)
self.workflow_editor_set_annotation(annotation)
if save_workflow:
save_button = self.components.workflow_editor.save_button
save_button.wait_for_visible()
Expand All @@ -1705,6 +1705,9 @@ def workflow_create_new(
self.sleep_for(self.wait_types.UX_RENDER)
return name

def workflow_editor_set_annotation(self, annotation: str):
self.components.workflow_editor.edit_annotation.wait_for_and_clear_and_send_keys(annotation)

def invocation_index_table_elements(self):
invocations = self.components.invocations
invocations.invocations_table.wait_for_visible()
Expand Down
52 changes: 40 additions & 12 deletions lib/galaxy_test/selenium/test_workflow_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@ def test_edit_name(self):
def test_edit_license(self):
editor = self.components.workflow_editor
name = self.create_and_wait_for_new_workflow_in_editor()
editor.license_selector.wait_for_visible()
assert "Do not specify" in editor.license_current_value.wait_for_text()
editor.canvas_body.wait_for_visible()
assert "Do not specify" in self.workflow_editor_license_text()

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

self.workflow_index_open_with_name(name)
editor.license_selector.wait_for_visible()
assert "MIT" in editor.license_current_value.wait_for_text()
assert "MIT" in self.workflow_editor_license_text()

@selenium_test
def test_parameter_regex_validation(self):
Expand Down Expand Up @@ -442,13 +441,10 @@ def test_reconnecting_nodes(self):
self.assert_connected("input1#output", "first_cat#input1")

@selenium_test
def test_editor_change_stack(self):
def test_editor_change_stack_inserting_inputs(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()
annotation = "change_stack_test_inserting_inputs"
self.workflow_create_new(annotation=annotation)

self.workflow_editor_add_input(item_name="data_input")
self.workflow_editor_add_input(item_name="data_collection_input")
Expand Down Expand Up @@ -487,6 +483,38 @@ def test_editor_change_stack(self):
editor.node.by_id(id=1).wait_for_present()
editor.node.by_id(id=2).wait_for_present()

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

assert "Do not specify" in self.workflow_editor_license_text()
self.workflow_editor_set_license("MIT")
assert "MIT" in self.workflow_editor_license_text()

editor.tool_bar.changes.wait_for_and_click()

changes = editor.changes
changes.action_set_license.wait_for_and_click()
# it switches back so this isn't needed per se
# editor.tool_bar.attributes.wait_for_and_click()
assert "Do not specify" in self.workflow_editor_license_text()

# for annotation we want to reset the change stack to dismiss
# the original setting of the annotation
name = self.workflow_index_open_with_name(name)

annotation_modified = "change_stack_test_set_attributes modified!!!"

self.workflow_editor_set_annotation(annotation_modified)
self.assert_wf_annotation_is(annotation_modified)

editor.tool_bar.changes.wait_for_and_click()
changes.action_set_annotation.wait_for_and_click()

self.assert_wf_annotation_is(annotation)

@selenium_test
def test_rendering_output_collection_connections(self):
self.open_in_workflow_editor(WORKFLOW_WITH_OUTPUT_COLLECTION)
Expand Down Expand Up @@ -625,7 +653,7 @@ def test_editor_tool_upgrade_all_tools(self):
annotation = "upgarde_all_test"
self.workflow_create_new(annotation=annotation)
self.workflow_editor_add_tool_step("multiple_versions")
self.workflow_editor_set_label(label="target label")
self.workflow_editor_set_node_label(label="target label")
self.workflow_editor_set_tool_vesrion("0.1")
self.assert_workflow_has_changes_and_save()

Expand Down Expand Up @@ -807,7 +835,7 @@ def test_editor_duplicate_node(self):
self.workflow_index_open()
self.components.workflows.edit_button.wait_for_and_click()
editor = self.components.workflow_editor
self.workflow_editor_set_label(label="source label", node="first_cat")
self.workflow_editor_set_node_label(label="source label", node="first_cat")
# Select node using new label, ensures labels are synced between side panel and node
cat_node = editor.node._(label="source label")
self.assert_workflow_has_changes_and_save()
Expand Down

0 comments on commit 7e2d581

Please sign in to comment.