-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtest_workflow_editor.py
More file actions
2010 lines (1793 loc) · 86.1 KB
/
Copy pathtest_workflow_editor.py
File metadata and controls
2010 lines (1793 loc) · 86.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import json
from typing import (
cast,
TYPE_CHECKING,
)
if TYPE_CHECKING:
from galaxy.selenium.has_playwright_driver import HasPlaywrightDriver
import yaml
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote.webelement import WebElement
from galaxy.selenium.navigates_galaxy import ColumnDefinition
from galaxy.selenium.web_element_protocol import WebElementProtocol
from galaxy_test.base.workflow_fixtures import (
WORKFLOW_NESTED_SIMPLE,
WORKFLOW_OPTIONAL_TRUE_INPUT_COLLECTION,
WORKFLOW_SELECT_FROM_OPTIONAL_DATASET,
WORKFLOW_SIMPLE_CAT_TWICE,
WORKFLOW_SIMPLE_MAPPING,
WORKFLOW_WITH_INVALID_STATE,
WORKFLOW_WITH_OLD_TOOL_VERSION,
WORKFLOW_WITH_OUTPUT_COLLECTION,
WORKFLOW_WITH_RULES_1,
WORKFLOW_WITH_RULES_2,
)
from .framework import (
retry_assertion_during_transitions,
RunsWorkflows,
selenium_only,
selenium_test,
SeleniumTestCase,
UsesWorkflowAssertions,
)
CHIPSEQ_COLUMNS = [
ColumnDefinition(
"Condition",
"The column is used to specify the specific experimental condition that each sample represents. There is no formal restriction on this column, but values should be kept short for readable reports.",
"Text",
),
ColumnDefinition(
"Replicate",
"This column is used to specify a replicate number for the experiment.",
"Integer",
optional=True,
default_value="",
),
ColumnDefinition(
"Control",
"If set, this should reference the element identifier corresponding to the control for this sample.",
"Element Identifier",
optional=True,
),
]
class TestWorkflowEditor(SeleniumTestCase, RunsWorkflows, UsesWorkflowAssertions):
ensure_registered = True
@selenium_test
def test_basics(self):
editor = self.components.workflow_editor
annotation = "basic_test"
name = self.workflow_create_new(annotation=annotation)
self.assert_wf_name_is(name)
self.assert_wf_annotation_is(annotation)
editor.canvas_body.wait_for_visible()
# shouldn't have changes on fresh load
save_button = self.components.workflow_editor.save_button
save_button.assert_disabled()
self.screenshot("workflow_editor_blank")
self.hover_over(self.components._.left_panel_drag.wait_for_visible())
self.workflow_editor_maximize_center_pane()
self.screenshot("workflow_editor_center_pane_maximized")
@selenium_test
def test_edit_annotation(self):
editor = self.components.workflow_editor
annotation = "new_annotation_test"
name = self.create_and_wait_for_new_workflow_in_editor(annotation=annotation)
edit_annotation = self.components.workflow_editor.edit_annotation
self.assert_wf_annotation_is(annotation)
editor.canvas_body.wait_for_visible()
new_annotation = "look new annotation"
edit_annotation.wait_for_and_send_keys(new_annotation)
self.assert_workflow_has_changes_and_save()
self.workflow_index_open_with_name(name)
self.assert_wf_annotation_is(new_annotation)
@selenium_test
def test_edit_name(self):
name = self.create_and_wait_for_new_workflow_in_editor()
new_name = self._get_random_name()
edit_name = self.components.workflow_editor.edit_name
edit_name.wait_for_and_send_keys(new_name)
self.assert_workflow_has_changes_and_save()
self.workflow_index_open_with_name(new_name)
self.assert_wf_name_is(name)
@selenium_test
def test_edit_license(self):
editor = self.components.workflow_editor
name = self.create_and_wait_for_new_workflow_in_editor()
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)
assert "MIT" in self.workflow_editor_license_text()
@selenium_test
def test_parameter_regex_validation(self):
editor = self.components.workflow_editor
workflow_run = self.components.workflow_run
parameter_name = "text_param"
name = self.create_and_wait_for_new_workflow_in_editor()
self.workflow_editor_add_input("parameter_input")
editor.label_input.wait_for_and_send_keys(parameter_name)
# this really should be parameterized with the repeat name
self.components.tool_form.repeat_insert.wait_for_and_click()
self.components.tool_form.parameter_input(
parameter="parameter_definition|validators_0|regex_match"
).wait_for_and_send_keys("moocow.*")
self.components.tool_form.parameter_input(
parameter="parameter_definition|validators_0|regex_doc"
).wait_for_and_send_keys("input must start with moocow")
self.save_after_node_form_changes()
self.workflow_run_with_name(name)
self.sleep_for(self.wait_types.UX_TRANSITION)
input_element = workflow_run.simplified_input(label=parameter_name).wait_for_and_click()
input_element.send_keys("startswrong")
workflow_run.run_workflow_disabled.wait_for_absent()
workflow_run.run_error.assert_absent_or_hidden()
self.workflow_run_submit()
element = workflow_run.run_error.wait_for_present()
assert "input must start with moocow" in element.text
@selenium_test
def test_int_parameter_minimum_validation(self):
editor = self.components.workflow_editor
workflow_run = self.components.workflow_run
parameter_name = "int_param"
name = self.create_and_wait_for_new_workflow_in_editor()
self.workflow_editor_add_input("parameter_input")
editor.label_input.wait_for_and_send_keys(parameter_name)
select_field = self.components.tool_form.parameter_select(parameter="parameter_definition|parameter_type")
self.select_set_value(select_field, "integer")
self.components.tool_form.parameter_input(parameter="parameter_definition|min").wait_for_and_send_keys("4")
self.save_after_node_form_changes()
self.workflow_run_with_name(name)
self.sleep_for(self.wait_types.UX_TRANSITION)
input_element = workflow_run.simplified_input(label=parameter_name).wait_for_and_click()
input_element.send_keys("3")
workflow_run.run_workflow_disabled.wait_for_absent()
workflow_run.run_error.assert_absent_or_hidden()
self.workflow_run_submit()
element = workflow_run.run_error.wait_for_present()
# follow up with a bigger PR to just make this (4 <= value) right? need to set default message
# in parameter validators
assert "Value ('3') must fulfill (4 <= value <= +infinity)" in element.text, element.text
@selenium_test
def test_float_parameter_maximum_validation(self):
editor = self.components.workflow_editor
workflow_run = self.components.workflow_run
parameter_name = "float_param"
name = self.create_and_wait_for_new_workflow_in_editor()
self.workflow_editor_add_input("parameter_input_float")
editor.label_input.wait_for_and_send_keys(parameter_name)
self.components.tool_form.parameter_input(parameter="parameter_definition|max").wait_for_and_send_keys("3.14")
self.save_after_node_form_changes()
self.workflow_run_with_name(name)
self.sleep_for(self.wait_types.UX_TRANSITION)
input_element = workflow_run.simplified_input(label=parameter_name).wait_for_and_click()
input_element.send_keys("3.2")
workflow_run.run_workflow_disabled.wait_for_absent()
workflow_run.run_error.assert_absent_or_hidden()
self.workflow_run_submit()
element = workflow_run.run_error.wait_for_present()
# see message in test test_int_parameter_minimum_validation about making this a little more human
# friendly.
assert "Value ('3.2') must fulfill (-infinity <= value <= 3.14)" in element.text, element.text
@selenium_test
def test_optional_select_data_field(self):
editor = self.components.workflow_editor
workflow_id = self.workflow_populator.upload_yaml_workflow(WORKFLOW_SELECT_FROM_OPTIONAL_DATASET)
self.workflow_index_open()
self.components.workflows.edit_button.wait_for_and_click()
editor = self.components.workflow_editor
node = editor.node._(label="select_from_dataset_optional")
node.title.wait_for_and_click()
self.components.tool_form.parameter_checkbox(parameter="select_single").wait_for_and_click()
self.components.tool_form.parameter_input(parameter="select_single").wait_for_and_send_keys("parameter value")
self.save_after_node_form_changes()
workflow = self.workflow_populator.download_workflow(workflow_id)
tool_state = json.loads(workflow["steps"]["0"]["tool_state"])
assert tool_state["select_single"] == "parameter value"
# Disable optional button, resets value to null
self.components.tool_form.parameter_checkbox(parameter="select_single").wait_for_and_click()
self.assert_workflow_has_changes_and_save()
workflow = self.workflow_populator.download_workflow(workflow_id)
tool_state = json.loads(workflow["steps"]["0"]["tool_state"])
assert tool_state["select_single"] is None
# Enable button but don't provide a value
self.components.tool_form.parameter_checkbox(parameter="select_single").wait_for_and_click()
self.assert_workflow_has_changes_and_save()
workflow = self.workflow_populator.download_workflow(workflow_id)
tool_state = json.loads(workflow["steps"]["0"]["tool_state"])
assert tool_state["select_single"] == ""
@selenium_test
def test_data_input(self):
editor = self.components.workflow_editor
name = self.workflow_create_new()
self.workflow_editor_add_input(item_name="data_input")
self.screenshot("workflow_editor_data_input_new")
self.workflow_editor_set_node_label("input1")
self.workflow_editor_set_node_annotation("my cool annotation")
self.sleep_for(self.wait_types.UX_RENDER)
self.screenshot("workflow_editor_data_input_filled_in")
self.workflow_editor_click_save()
self.workflow_index_open_with_name(name)
data_input_node = editor.node._(label="input1")
data_input_node.title.wait_for_and_click()
label = editor.label_input.wait_for_value()
assert label == "input1", label
annotation = editor.annotation_input.wait_for_value()
assert annotation == "my cool annotation", annotation
data_input_node.destroy.wait_for_and_click()
data_input_node.wait_for_absent()
self.screenshot("workflow_editor_data_input_deleted")
@selenium_test
def test_collection_input(self):
editor = self.components.workflow_editor
name = self.workflow_create_new()
self.workflow_editor_add_input(item_name="data_collection_input")
self.screenshot("workflow_editor_data_collection_input_new")
editor.label_input.wait_for_and_send_keys("input1")
editor.annotation_input.wait_for_and_send_keys("my cool annotation")
self.sleep_for(self.wait_types.UX_RENDER)
self.screenshot("workflow_editor_data_collection_input_filled_in")
self.workflow_editor_click_save()
self.workflow_index_open_with_name(name)
data_input_node = editor.node._(label="input1")
data_input_node.title.wait_for_and_click()
label = editor.label_input.wait_for_value()
assert label == "input1", label
annotation = editor.annotation_input.wait_for_value()
assert annotation == "my cool annotation", annotation
data_input_node.destroy.wait_for_and_click()
data_input_node.wait_for_absent()
self.sleep_for(self.wait_types.UX_RENDER)
self.screenshot("workflow_editor_data_collection_input_deleted")
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
def test_collection_input_sample_sheet_chipseq_example(self):
editor = self.components.workflow_editor
self.workflow_create_new()
self.workflow_editor_add_input(item_name="data_collection_input")
self.screenshot("workflow_editor_data_collection_sample_sheet_input_new")
editor.label_input.wait_for_and_send_keys("input1")
editor.annotation_input.wait_for_and_send_keys("chipseq example input")
self.sleep_for(self.wait_types.UX_RENDER)
editor.collection_type_input.wait_for_and_clear_and_send_keys("sample_sheet:paired")
self.workflow_editor_enter_column_definitions(CHIPSEQ_COLUMNS)
self.screenshot("workflow_editor_data_collection_sample_sheet_input_filled_in")
self.workflow_editor_click_save()
workflow = self._download_current_workflow()
tool_state = json.loads(workflow["steps"]["0"]["tool_state"])
assert tool_state["collection_type"] == "sample_sheet:paired"
column_definitions = tool_state["column_definitions"]
assert len(column_definitions) == len(CHIPSEQ_COLUMNS)
condition = column_definitions[0]
assert condition["name"] == "Condition"
assert condition["description"] == CHIPSEQ_COLUMNS[0].description
assert condition["type"] == "string"
assert condition["optional"] is False
replicate = column_definitions[1]
assert replicate["name"] == "Replicate"
assert replicate["type"] == "int"
assert replicate["optional"] is True
assert replicate["default_value"] is None
control = column_definitions[2]
assert control["name"] == "Control"
assert control["type"] == "element_identifier"
assert control["optional"] is True
@selenium_test
def test_data_column_input_editing(self):
self.open_in_workflow_editor("""
class: GalaxyWorkflow
steps:
column_param_list:
tool_id: column_param_list
state:
col: ["1","2","3"]
col_names: ["a", "b", "c"]
""")
editor = self.components.workflow_editor
node = editor.node._(label="column_param_list")
node.title.wait_for_and_click()
columns = self.components.tool_form.parameter_textarea(parameter="col")
textarea_columns = columns.wait_for_visible()
assert textarea_columns.get_attribute("value") == "1\n2\n3"
column_names = self.components.tool_form.parameter_textarea(parameter="col_names")
textarea_column_names = column_names.wait_for_visible()
assert textarea_column_names.get_attribute("value") == "a\nb\nc"
self.sleep_for(self.wait_types.UX_RENDER)
self.set_text_element(columns, "4\n5\n6")
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_workflow_has_changes_and_save()
self.refresh()
node.title.wait_for_and_click()
textarea_columns = columns.wait_for_visible()
assert textarea_columns.get_attribute("value") == "4\n5\n6"
@selenium_test
def test_integer_input(self):
editor = self.components.workflow_editor
name = self.workflow_create_new(save_workflow=False)
self.workflow_editor_add_input(item_name="parameter_input")
self.screenshot("workflow_editor_parameter_input_new")
editor.label_input.wait_for_and_send_keys("input1")
editor.annotation_input.wait_for_and_send_keys("my cool annotation")
self.sleep_for(self.wait_types.UX_RENDER)
self.screenshot("workflow_editor_parameter_input_filled_in")
self.workflow_editor_click_save()
self.workflow_index_open_with_name(name)
data_input_node = editor.node._(label="input1")
data_input_node.title.wait_for_and_click()
label = editor.label_input.wait_for_value()
assert label == "input1", label
annotation = editor.annotation_input.wait_for_value()
assert annotation == "my cool annotation", annotation
data_input_node.destroy.wait_for_and_click()
data_input_node.wait_for_absent()
self.sleep_for(self.wait_types.UX_RENDER)
self.screenshot("workflow_editor_parameter_input_deleted")
@selenium_test
def test_non_data_connections(self):
self.open_in_workflow_editor("""
class: GalaxyWorkflow
inputs:
input_int: integer
steps:
simple_constructs:
tool_id: simple_constructs
label: tool_exec
in:
inttest: input_int
cat1:
# regression test, ensures connecting works in the presence of data input terminals
tool_id: cat1
""")
self.screenshot("workflow_editor_parameter_connection_simple")
self.assert_connected("input_int#output", "tool_exec#inttest")
editor = self.components.workflow_editor
tool_node = editor.node._(label="tool_exec")
tool_node.wait_for_and_click()
tool_input = tool_node.input_terminal(name="inttest")
self.hover_over(tool_input.wait_for_visible())
tool_node.connector_destroy_callout(name="inttest").wait_for_and_click()
self.assert_not_connected("input_int#output", "tool_exec#inttest")
self.screenshot("workflow_editor_parameter_connection_destroyed")
# When connected, cannot turn it into a RuntimeValue..
collapse_input = editor.collapse_icon(name="inttest")
collapse_input.wait_for_absent_or_hidden()
# If it is disconnected, then can specify as RuntimeValue
connect_icon = editor.connect_icon(name="inttest")
connect_icon.wait_for_visible()
connect_icon.wait_for_and_click()
collapse_input.wait_for_visible()
# Also the connector should disappear
tool_input.wait_for_absent_or_hidden()
# Now make it connected again and watch the requests
connect_icon.wait_for_and_click()
tool_input.wait_for_visible()
collapse_input.wait_for_absent_or_hidden()
self.workflow_editor_connect(
"input_int#output", "tool_exec#inttest", screenshot_partial="workflow_editor_parameter_connection_dragging"
)
self.assert_connected("input_int#output", "tool_exec#inttest")
@selenium_test
def test_non_data_map_over_carried_through(self):
# Use auto_layout=false, which prevents placing any
# step outside of the scroll area
# xref: https://github.com/galaxyproject/galaxy/issues/13211
self.open_in_workflow_editor(
"""
class: GalaxyWorkflow
inputs:
input_collection:
type: collection
collection_type: "list"
steps:
param_value_from_file:
tool_id: param_value_from_file
in:
input1: input_collection
text_input_step:
tool_id: param_text_option
in:
text_param: param_value_from_file/text_param
collection_input:
tool_id: identifier_collection
""",
auto_layout=False,
)
self.workflow_editor_connect("text_input_step#out_file1", "collection_input#input1")
self.assert_connected("text_input_step#out_file1", "collection_input#input1")
@selenium_test
def test_connecting_display_in_upload_false_connections(self):
self.open_in_workflow_editor("""
class: GalaxyWorkflow
steps:
step1:
tool_id: test_sam_to_bam_conversions
step2:
tool_id: test_sam_to_bam_conversions
""")
self.workflow_editor_connect("step1#qname_input_sorted_bam_output", "step2#input5")
self.assert_connected("step1#qname_input_sorted_bam_output", "step2#input5")
@selenium_test
def test_existing_connections(self):
self.open_in_workflow_editor(WORKFLOW_SIMPLE_CAT_TWICE)
editor = self.components.workflow_editor
self.assert_connected("input1#output", "first_cat#input1")
self.screenshot("workflow_editor_connection_simple")
cat_node = editor.node._(label="first_cat")
cat_input = cat_node.input_terminal(name="input1")
self.hover_over(cat_input.wait_for_visible())
cat_node.connector_destroy_callout(name="input1").wait_for_visible()
self.screenshot("workflow_editor_connection_callout")
cat_node.connector_destroy_callout(name="input1").wait_for_and_click()
self.assert_not_connected("input1#output", "first_cat#input1")
self.screenshot("workflow_editor_connection_destroyed")
self.workflow_editor_connect(
"input1#output", "first_cat#input1", screenshot_partial="workflow_editor_connection_dragging"
)
self.assert_connected("input1#output", "first_cat#input1")
@selenium_test
def test_reconnecting_nodes(self):
name = self.open_in_workflow_editor(WORKFLOW_SIMPLE_CAT_TWICE)
self.assert_connected("input1#output", "first_cat#input1")
self.workflow_editor_destroy_connection("first_cat#input1")
self.assert_not_connected("input1#output", "first_cat#input1")
self.workflow_editor_connect("input1#output", "first_cat#input1")
self.assert_connected("input1#output", "first_cat#input1")
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_workflow_has_changes_and_save()
self.workflow_index_open_with_name(name)
self.assert_connected("input1#output", "first_cat#input1")
@selenium_test
def test_rendering_output_collection_connections(self):
self.open_in_workflow_editor(WORKFLOW_WITH_OUTPUT_COLLECTION)
self.workflow_editor_maximize_center_pane()
self.screenshot("workflow_editor_output_collections")
@selenium_test
def test_simple_mapping_connections(self):
self.open_in_workflow_editor(WORKFLOW_SIMPLE_MAPPING)
self.workflow_editor_maximize_center_pane()
self.screenshot("workflow_editor_simple_mapping")
self.assert_connected("input1#output", "cat#input1")
self.assert_input_mapped("cat#input1")
self.workflow_editor_destroy_connection("cat#input1")
self.assert_input_not_mapped("cat#input1")
self.assert_not_connected("input1#output", "cat#input1")
self.workflow_editor_connect("input1#output", "cat#input1")
self.assert_input_mapped("cat#input1")
@selenium_test
def test_rendering_simple_nested_workflow(self):
self.open_in_workflow_editor(WORKFLOW_NESTED_SIMPLE)
self.workflow_editor_maximize_center_pane()
self.screenshot("workflow_editor_simple_nested")
@selenium_test
def test_best_practices_input_label(self):
editor = self.components.workflow_editor
annotation = "best_practices_input_label"
self.workflow_create_new(annotation=annotation)
self.workflow_editor_add_input(item_name="data_input")
editor.tool_bar.best_practices.wait_for_and_click()
best_practices = editor.best_practices
section_element = best_practices.section_input_metadata.wait_for_present()
assert section_element.get_attribute("data-lint-status") == "warning"
item = best_practices.item_input_metadata(index=0)
element = item.wait_for_present()
assert element.get_attribute("data-missing-label") == "true"
assert element.get_attribute("data-missing-annotation") == "true"
item.wait_for_and_click()
self.workflow_editor_set_node_label("best practice input")
# editor.tool_bar.best_practices.wait_for_and_click()
element = item.wait_for_present()
assert element.get_attribute("data-missing-label") == "false"
assert element.get_attribute("data-missing-annotation") == "true"
self.workflow_editor_set_node_annotation("informative annotation")
@retry_assertion_during_transitions
def assert_linting_input_metadata_okay():
section_element = best_practices.section_input_metadata.wait_for_present()
assert section_element.get_attribute("data-lint-status") == "ok"
assert_linting_input_metadata_okay()
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
def test_rendering_rules_workflow_1(self):
self.open_in_workflow_editor(WORKFLOW_WITH_RULES_1)
rule_output = "apply#output"
random_lines_input = "random_lines#input"
self.workflow_editor_maximize_center_pane()
self.screenshot("workflow_editor_rules_1")
self.assert_connected(rule_output, random_lines_input)
self.assert_input_mapped(random_lines_input)
self.workflow_editor_destroy_connection(random_lines_input)
self.assert_not_connected(rule_output, random_lines_input)
self.assert_input_not_mapped(random_lines_input)
self.workflow_editor_connect(rule_output, random_lines_input)
self.assert_connected(rule_output, random_lines_input)
self.assert_input_mapped(random_lines_input)
@selenium_test
def test_rendering_rules_workflow_2(self):
self.open_in_workflow_editor(WORKFLOW_WITH_RULES_2)
self.workflow_editor_maximize_center_pane(collapse_right=False)
editor = self.components.workflow_editor
rule_builder = self.components.rule_builder
rule_output = "apply#output"
copy_list_input = "copy_list#input1"
apply_node = editor.node._(label="apply")
self.assert_connected(rule_output, copy_list_input)
self.assert_input_mapped(copy_list_input)
self.workflow_editor_destroy_connection(copy_list_input)
self.assert_not_connected(rule_output, copy_list_input)
self.assert_input_not_mapped(copy_list_input)
self.workflow_editor_connect(rule_output, copy_list_input)
self.assert_connected(rule_output, copy_list_input)
self.assert_input_mapped(copy_list_input)
apply_node.title.wait_for_and_click()
self.screenshot("workflow_editor_rules_2_form")
self.tool_parameter_edit_rules()
rule_builder._.wait_for_visible()
self.screenshot("workflow_editor_rules_2_builder")
new_rules = dict(
rules=[{"type": "add_column_metadata", "value": "identifier0"}],
mapping=[{"type": "list_identifiers", "columns": [0]}],
)
self.rule_builder_set_source(json.dumps(new_rules))
rule_builder.main_button_ok.wait_for_and_click()
apply_node.title.wait_for_and_click()
self.sleep_for(self.wait_types.UX_RENDER)
# screenshot should have async warning about connection removed
self.screenshot("workflow_editor_rules_2_after_change")
self.assert_input_not_mapped(copy_list_input)
# changing output collection type remove outbound connections, so this
# this needs to be re-connected. Remove this re-connection if we upgrade
# the workflow editor to try to re-establish the connection with different
# mapping.
self.workflow_editor_connect(rule_output, copy_list_input)
self.assert_connected(rule_output, copy_list_input)
# Regardless - this rules now say to connect a list to a list instead of a list
# to a list:list, so there should be no mapping anymore even after connected.
self.assert_input_not_mapped(copy_list_input)
@selenium_test
def test_save_as(self):
name = self.workflow_upload_yaml_with_random_name(WORKFLOW_SIMPLE_CAT_TWICE)
self.workflow_index_open()
self.workflow_index_open_with_name(name)
self.sleep_for(self.wait_types.UX_RENDER)
self.screenshot("workflow_editor_edit_menu")
self.components.workflow_editor.save_as_activity.wait_for_and_click()
self.components.workflow_editor.save_as_modal_close.wait_for_and_click()
@selenium_test
def test_editor_tool_upgrade(self):
workflow_populator = self.workflow_populator
workflow_id = workflow_populator.upload_yaml_workflow(
"""class: GalaxyWorkflow
inputs: []
steps:
- tool_id: multiple_versions
tool_version: "0.1"
label: multiple_versions
state:
foo: bar
""",
exact_tools=True,
)
self.workflow_index_open()
self.components.workflows.edit_button.wait_for_and_click()
editor = self.components.workflow_editor
self.workflow_editor_set_tool_vesrion("0.2", node="multiple_versions")
self.screenshot("workflow_editor_version_update")
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_workflow_has_changes_and_save()
workflow = self.workflow_populator.download_workflow(workflow_id)
assert workflow["steps"]["0"]["tool_version"] == "0.2"
editor.node._(label="multiple_versions").wait_for_and_click()
editor.tool_version_button.wait_for_and_click()
assert self.select_dropdown_item("Switch to 0.1+galaxy6"), "Switch to tool version dropdown item not found"
self.screenshot("workflow_editor_version_downgrade")
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_workflow_has_changes_and_save()
workflow = self.workflow_populator.download_workflow(workflow_id)
assert workflow["steps"]["0"]["tool_version"] == "0.1+galaxy6"
@selenium_test
def test_editor_tool_upgrade_all_tools(self):
editor = self.components.workflow_editor
annotation = "upgarde_all_test"
self.workflow_create_new(annotation=annotation)
self.workflow_editor_add_tool_step("multiple_versions")
self.workflow_editor_set_node_label(label="target label")
self.workflow_editor_set_tool_vesrion("0.1")
self.assert_workflow_has_changes_and_save()
editor.tool_bar.upgrade_all.wait_for_and_click()
self.workflow_editor_ensure_tool_form_open(node=0)
node = self.components.tool_form.tool_version.wait_for_present()
version = node.get_attribute("data-version")
assert version == "0.2"
@selenium_test
def test_editor_tool_upgrade_message(self):
workflow_populator = self.workflow_populator
workflow_populator.upload_yaml_workflow(WORKFLOW_WITH_OLD_TOOL_VERSION, exact_tools=True)
self.workflow_index_open()
self.components.workflows.edit_button.wait_for_and_click()
self.assert_modal_has_text("Using version '0.2' instead of version '0.0.1'")
self.screenshot("workflow_editor_tool_upgrade")
self.components.workflow_editor.state_upgrade_modal_close.wait_for_and_click()
self.assert_workflow_has_changes_and_save()
@selenium_test
def test_editor_subworkflow_tool_upgrade_message(self):
workflow_populator = self.workflow_populator
embedded_workflow = yaml.safe_load(WORKFLOW_WITH_OLD_TOOL_VERSION)
# Create invalid tool state
embedded_workflow["steps"]["mul_versions"]["state"]["inttest"] = "Invalid"
outer_workflow = yaml.safe_load("""
class: GalaxyWorkflow
inputs:
outer_input: data
steps:
nested_workflow:
run: {}
in:
input1: outer_input
""")
outer_workflow["steps"]["nested_workflow"]["run"] = embedded_workflow
workflow_populator.upload_yaml_workflow(json.dumps(outer_workflow), exact_tools=True)
self.workflow_index_open()
self.components.workflows.edit_button.wait_for_and_click()
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_modal_has_text("Using version '0.2' instead of version '0.0.1'")
self.assert_modal_has_text("Parameter 'inttest': an integer or workflow parameter is required")
self.screenshot("workflow_editor_subworkflow_tool_upgrade")
self.workflow_editor_dismiss_state_upgrade_modal()
self.assert_workflow_has_changes_and_save()
# Ensure that the state upgrade modal is hidden by the end, to ensure AXE checks pass (no dialog should be present)
self.workflow_editor_dismiss_state_upgrade_modal()
@staticmethod
def set_text_element(element, value):
# Try both, no harm here
element.wait_for_and_send_keys(Keys.CONTROL, "a")
element.wait_for_and_send_keys(Keys.COMMAND, "a")
element.wait_for_and_send_keys(Keys.BACKSPACE)
element.wait_for_and_send_keys(value)
@selenium_test
def test_change_datatype(self):
self.open_in_workflow_editor("""
class: GalaxyWorkflow
inputs: []
steps:
- tool_id: create_2
label: create_2
- tool_id: checksum
label: checksum
in:
input: create_2/out_file1
""")
editor = self.components.workflow_editor
self.assert_connected("create_2#out_file1", "checksum#input")
node = editor.node._(label="create_2")
node.wait_for_and_click()
editor.configure_output(output="out_file1").wait_for_and_click()
editor.change_datatype.wait_for_and_click()
editor.select_datatype_text_search.wait_for_and_send_keys("bam")
editor.select_datatype(datatype="bam").wait_for_and_click()
editor.node.output_data_row(output_name="out_file1", extension="bam").wait_for_visible()
self.assert_connection_invalid("create_2#out_file1", "checksum#input")
# Assert save button
save_button = self.components.workflow_editor.save_button
save_button.wait_for_and_click()
# Will trigger confirmation modal
self.components.confirm_dialog.ok_button.wait_for_and_click()
self.components.confirm_dialog._.wait_for_absent_or_hidden()
# Make connection valid again
editor.configure_output(output="out_file1").wait_for_and_click()
editor.change_datatype.wait_for_and_click()
editor.select_datatype_text_search.wait_for_and_send_keys("tabular")
editor.select_datatype(datatype="tabular").wait_for_and_click()
# Assert connection is valid
self.assert_connected("create_2#out_file1", "checksum#input")
@selenium_test
def test_change_datatype_post_job_action_lost_regression(self):
self.open_in_workflow_editor("""
class: GalaxyWorkflow
inputs: []
steps:
- tool_id: create_2
label: create_2
out:
out_file1:
change_datatype: bam
- tool_id: metadata_bam
label: metadata_bam
in:
input_bam: create_2/out_file1
""")
self.assert_connected("create_2#out_file1", "metadata_bam#input_bam")
editor = self.components.workflow_editor
node = editor.node._(label="create_2")
node.wait_for_and_click()
self.assert_connected("create_2#out_file1", "metadata_bam#input_bam")
@selenium_test
def test_change_datatype_in_subworkflow(self):
self.open_in_workflow_editor("""
class: GalaxyWorkflow
inputs: []
steps:
nested_workflow:
run:
class: GalaxyWorkflow
inputs: []
steps:
- tool_id: create_2
label: create_2
out:
out_file1:
change_datatype: bam
outputs:
workflow_output:
outputSource: create_2/out_file1
metadata_bam:
tool_id: metadata_bam
""")
editor = self.components.workflow_editor
node = editor.node._(label="nested_workflow")
node.wait_for_and_click()
node.output_data_row(output_name="workflow_output", extension="bam").wait_for_visible()
# Move canvas, so terminals are in viewport
self.move_center_of_canvas(xoffset=100, yoffset=100)
self.workflow_editor_connect("nested_workflow#workflow_output", "metadata_bam#input_bam")
self.assert_connected("nested_workflow#workflow_output", "metadata_bam#input_bam")
@selenium_test
def test_edit_subworkflow(self):
self.open_in_workflow_editor("""
class: GalaxyWorkflow
inputs: []
steps:
nested_workflow:
run:
class: GalaxyWorkflow
inputs: []
steps:
- tool_id: create_2
label: create_2
""")
# Save after auto-layout so there are no unsaved changes
self.assert_workflow_has_changes_and_save()
editor = self.components.workflow_editor
node = editor.node._(label="nested_workflow")
node.wait_for_and_click()
editor.edit_subworkflow.wait_for_and_click()
self.sleep_for(self.wait_types.UX_RENDER)
node = editor.node._(label="create_2")
node.wait_for_and_click()
@selenium_test
def test_editor_duplicate_node(self):
workflow_id = self.workflow_populator.upload_yaml_workflow(WORKFLOW_SIMPLE_CAT_TWICE)
self.workflow_index_open()
self.components.workflows.edit_button.wait_for_and_click()
editor = self.components.workflow_editor
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()
editor.annotation_input.wait_for_and_send_keys("source annotation")
self.assert_workflow_has_changes_and_save()
editor.configure_output(output="out_file1").wait_for_and_click()
output_label = editor.label_output(output="out_file1")
self.set_text_element(output_label, "workflow output label")
self.set_text_element(editor.rename_output, "renamed_output")
editor.change_datatype.wait_for_and_click()
editor.select_datatype_text_search.wait_for_and_send_keys("bam")
editor.select_datatype(datatype="bam").wait_for_and_click()
editor.add_tags_button.wait_for_and_click()
editor.add_tags_input.wait_for_and_send_keys("#crazynewtag" + Keys.ENTER + Keys.ESCAPE)
editor.remove_tags_button.wait_for_and_click()
editor.remove_tags_input.wait_for_and_send_keys("#oldboringtag" + Keys.ENTER + Keys.ESCAPE)
self.sleep_for(self.wait_types.UX_RENDER)
cat_node.clone.wait_for_and_click()
cloned_node = editor.node.by_id(id=2)
cloned_node.wait_for_and_click()
editor.label_input.wait_for_and_send_keys(Keys.BACKSPACE * 20)
editor.label_input.wait_for_and_send_keys("cloned label")
output_label = editor.label_output(output="out_file1")
self.set_text_element(output_label, "cloned output label")
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_workflow_has_changes_and_save()
edited_workflow = self.workflow_populator.download_workflow(workflow_id)
source_step = next(iter(step for step in edited_workflow["steps"].values() if step["label"] == "source label"))
cloned_step = next(iter(step for step in edited_workflow["steps"].values() if step["label"] == "cloned label"))
assert source_step["annotation"] == cloned_step["annotation"] == "source annotation"
assert source_step["workflow_outputs"][0]["label"] == "workflow output label"
assert cloned_step["workflow_outputs"][0]["label"] == "cloned output label"
assert len(source_step["post_job_actions"]) == len(cloned_step["post_job_actions"]) == 4
assert source_step["post_job_actions"] == cloned_step["post_job_actions"]
@selenium_test
def test_editor_embed_workflow(self):
self.setup_subworkflow()
def setup_subworkflow(self):
workflow_populator = self.workflow_populator
child_workflow_name = self._get_random_name()
workflow_populator.upload_yaml_workflow(WORKFLOW_OPTIONAL_TRUE_INPUT_COLLECTION, name=child_workflow_name)
parent_workflow_id = workflow_populator.upload_yaml_workflow("""class: GalaxyWorkflow
inputs:
input_collection:
type: collection
collection_type: "list"
steps:
- tool_id: multiple_versions
tool_version: "0.1"
label: multiple_versions
state:
foo: bar
""")
self.workflow_index_open()
self.components.workflows.edit_button.wait_for_and_click()
editor = self.components.workflow_editor
editor.canvas_body.wait_for_visible()
self.workflow_editor_add_subworkflow(child_workflow_name)
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_workflow_has_changes_and_save()
workflow = self.workflow_populator.download_workflow(parent_workflow_id)
subworkflow_step = workflow["steps"]["2"]
assert subworkflow_step["name"] == child_workflow_name
assert subworkflow_step["type"] == "subworkflow"
assert subworkflow_step["subworkflow"]["a_galaxy_workflow"] == "true"
self.workflow_editor_connect("input_collection#output", f"{child_workflow_name}#input1")
self.assert_connected("input_collection#output", f"{child_workflow_name}#input1")
self.assert_workflow_has_changes_and_save()
workflow = self.workflow_populator.download_workflow(parent_workflow_id)
subworkflow_step = workflow["steps"]["2"]
assert subworkflow_step["input_connections"]["input1"]["input_subworkflow_step_id"] == 0
return child_workflow_name
@selenium_test
def test_editor_insert_steps(self):
steps_to_insert = self.workflow_upload_yaml_with_random_name(WORKFLOW_SIMPLE_CAT_TWICE)
annotation = "insert step test"
self.workflow_create_new(annotation=annotation)
self.workflow_editor_add_input(item_name="data_input")
editor = self.components.workflow_editor
editor.canvas_body.wait_for_visible()
self.workflow_editor_add_steps(steps_to_insert)
self.assert_connected("input1#output", "first_cat#input1")
self.assert_workflow_has_changes_and_save()
workflow = self._download_current_workflow()
assert len(workflow["steps"]) == 3
def _download_current_workflow(self):
self.sleep_for(self.wait_types.DATABASE_OPERATION)
workflow_id = self.current_url.split("id=")[1]
workflow = self.workflow_populator.download_workflow(workflow_id)
return workflow
def _pick_value_select_mode(self, label):
mode_selector = "div.ui-form-element[id='form-element-mode']"
container = self.wait_for_selector(mode_selector)
trigger = container.find_element(By.CSS_SELECTOR, ".multiselect__select")
trigger.click()
self.sleep_for(self.wait_types.UX_RENDER)
js = """
var label = arguments[0];
var container = document.querySelector('#form-element-mode');
var items = container.querySelectorAll('.multiselect__element');
for (var i = 0; i < items.length; i++) {
if (items[i].textContent.trim() === label) {
items[i].querySelector('.multiselect__option').click();
return true;
}
}
return false;
"""
result = self.execute_script(js, label)
assert result, f"Mode option '{label}' not found"
@selenium_test
def test_pick_value_add_from_palette(self):
self.workflow_create_new(annotation="pick value test")
self.workflow_editor_add_input(item_name="pick_value")
editor = self.components.workflow_editor
editor.node._(label="Pick Value").wait_for_present()
@selenium_test
def test_pick_value_mode_selection(self):
self.workflow_create_new(annotation="pick value mode test")
self.workflow_editor_add_input(item_name="pick_value")
editor = self.components.workflow_editor
node = editor.node._(label="Pick Value")
node.wait_for_and_click()
self._pick_value_select_mode("All non-null (as collection)")
self.sleep_for(self.wait_types.UX_RENDER)
self.assert_workflow_has_changes_and_save()
workflow = self._download_current_workflow()
pick_step = [s for s in workflow["steps"].values() if s["type"] == "pick_value"][0]
tool_state = json.loads(pick_step["tool_state"])
assert tool_state["mode"] == "all_non_null"
@selenium_test
def test_pick_value_terminals(self):
self.workflow_create_new(annotation="pick value terminals test")
self.workflow_editor_add_input(item_name="pick_value")
editor = self.components.workflow_editor