Refactor selenium tests to use upload helpers

Migrates integration tests to use the modern upload activity helper instead of legacy upload methods. This standardizes how files, pasted content, and remote resources are staged in selenium tests, improving maintainability and reliability of the test suite.
This commit is contained in:
davelopez
2026-06-09 14:55:49 +02:00
parent 37f3e1982c
commit af7a709d3f
11 changed files with 63 additions and 46 deletions
@@ -1,10 +1,11 @@
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
)
class TestLegacyHistoryExport(SeleniumIntegrationTestCase):
class TestLegacyHistoryExport(SeleniumIntegrationTestCase, UsesUploadActivity):
"""Test legacy history export for when celery is disabled.
If Celery is enabled, a wizard will be setup and STS will serve downloads,
@@ -22,7 +23,7 @@ class TestLegacyHistoryExport(SeleniumIntegrationTestCase):
@selenium_test
def test_history_export(self):
self.perform_upload_of_pasted_content("my cool content")
self.upload_context("paste-content").stage_paste_content("my cool content").start()
self.history_panel_wait_for_hid_ok(1)
self.click_history_option_export_to_file()
@@ -45,7 +46,7 @@ class TestLegacyHistoryExport(SeleniumIntegrationTestCase):
history_export.generated_export_link.wait_for_visible()
history_export.export_link.assert_absent()
self.perform_upload_of_pasted_content("my cool content part 2")
self.upload_context("paste-content").stage_paste_content("my cool content part 2").start()
self.history_panel_wait_for_hid_ok(2)
self.click_history_option_export_to_file()
@@ -1,12 +1,13 @@
import os
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
)
class TestHistoryImportExportFtpSeleniumIntegrationBase(SeleniumIntegrationTestCase):
class TestHistoryImportExportFtpSeleniumIntegrationBase(SeleniumIntegrationTestCase, UsesUploadActivity):
ensure_registered = True
@classmethod
@@ -54,7 +55,7 @@ class TestHistoryImportExportFtpSeleniumIntegration(TestHistoryImportExportFtpSe
self.create_user_ftp_dir()
gx_selenium_context = self
gx_selenium_context.perform_upload_of_pasted_content("my cool content")
gx_selenium_context.upload_context("paste-content").stage_paste_content("my cool content").start()
gx_selenium_context.history_panel_wait_for_hid_ok(1)
gx_selenium_context.click_history_options()
gx_selenium_context.components.history_panel.options_show_export_history_to_file.wait_for_and_click()
@@ -103,7 +104,7 @@ class TestHistoryImportExportFtpSeleniumIntegrationWithTasks(TestHistoryImportEx
def test_history_export_tracking(self):
self.create_user_ftp_dir()
self.perform_upload_of_pasted_content("my cool content")
self.upload_context("paste-content").stage_paste_content("my cool content").start()
self.history_panel_wait_for_hid_ok(1)
self.click_history_option_export_to_file()
@@ -6,6 +6,7 @@ from typing import (
from galaxy_test.driver.integration_util import ConfiguresObjectStores
from galaxy_test.selenium.framework import managed_history
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
@@ -62,7 +63,9 @@ backends:
AvailableObjectStoreIDs = Literal["default", "short_term", "mid_term"]
class TestObjectStoreContentsExpirationIntegration(SeleniumIntegrationTestCase, ConfiguresObjectStores):
class TestObjectStoreContentsExpirationIntegration(
SeleniumIntegrationTestCase, ConfiguresObjectStores, UsesUploadActivity
):
ensure_registered = True
dataset_populator: "SeleniumSessionDatasetPopulator"
dataset_collection_populator: "SeleniumSessionDatasetCollectionPopulator"
@@ -92,7 +95,7 @@ class TestObjectStoreContentsExpirationIntegration(SeleniumIntegrationTestCase,
def test_no_expiration_for_default_storage(self):
self._select_history_storage("default")
self.perform_upload_of_pasted_content("default storage content")
self.upload_context("paste-content").stage_paste_content("default storage content").start()
self.history_panel_wait_for_hid_visible(1)
self._assert_no_expiration_indicator_for(hid=1)
@@ -101,7 +104,7 @@ class TestObjectStoreContentsExpirationIntegration(SeleniumIntegrationTestCase,
def test_expiration_of_single_dataset(self):
self._select_history_storage("short_term")
self.perform_upload_of_pasted_content("my test content")
self.upload_context("paste-content").stage_paste_content("my test content").start()
self.history_panel_wait_for_hid_visible(1)
self._assert_expiration_indicator_visible_for(hid=1, expected_storage_id="short_term")
@@ -110,10 +113,10 @@ class TestObjectStoreContentsExpirationIntegration(SeleniumIntegrationTestCase,
def test_expiration_of_collection(self):
self._select_history_storage("short_term")
self.perform_upload_of_pasted_content("dataset 1 content")
self.upload_context("paste-content").stage_paste_content("dataset 1 content").start()
self.history_panel_wait_for_hid_visible(1)
self.perform_upload_of_pasted_content("dataset 2 content")
self.upload_context("paste-content").stage_paste_content("dataset 2 content").start()
self.history_panel_wait_for_hid_visible(2)
self.history_panel_wait_for_and_select([1, 2])
@@ -129,19 +132,19 @@ class TestObjectStoreContentsExpirationIntegration(SeleniumIntegrationTestCase,
def test_expiration_if_mixed_storage_in_collection(self):
self._select_history_storage("default")
self.perform_upload_of_pasted_content("dataset stored in default storage")
self.upload_context("paste-content").stage_paste_content("dataset stored in default storage").start()
self.history_panel_wait_for_hid_visible(1)
self._assert_no_expiration_indicator_for(hid=1)
self._select_history_storage("short_term")
self.perform_upload_of_pasted_content("dataset stored in short term storage")
self.upload_context("paste-content").stage_paste_content("dataset stored in short term storage").start()
self.history_panel_wait_for_hid_visible(2)
self._assert_expiration_indicator_visible_for(hid=2, expected_storage_id="short_term")
self._select_history_storage("mid_term")
self.perform_upload_of_pasted_content("dataset stored in mid term storage")
self.upload_context("paste-content").stage_paste_content("dataset stored in mid term storage").start()
self.history_panel_wait_for_hid_visible(3)
self._assert_expiration_indicator_visible_for(hid=3, expected_storage_id="mid_term")
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING
from galaxy_test.driver.integration_setup import PosixFileSourceSetup
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
@@ -10,7 +11,7 @@ if TYPE_CHECKING:
from galaxy_test.selenium.framework import SeleniumSessionDatasetPopulator
class TestPosixFileSourceSeleniumIntegration(PosixFileSourceSetup, SeleniumIntegrationTestCase):
class TestPosixFileSourceSeleniumIntegration(PosixFileSourceSetup, SeleniumIntegrationTestCase, UsesUploadActivity):
dataset_populator: "SeleniumSessionDatasetPopulator"
# For simplicity, otherwise need to setup a different file_sources_config_file
@@ -19,19 +20,17 @@ class TestPosixFileSourceSeleniumIntegration(PosixFileSourceSetup, SeleniumInteg
@selenium_test
def test_upload_from_posix(self):
self.admin_login()
self.components.upload.start.wait_for_and_click()
self.components.upload.file_dialog.wait_for_and_click()
self.components.upload.file_source_selector(path="gxfiles://posix_test").wait_for_and_click()
self.components.upload.file_source_selector(path="gxfiles://posix_test/a").wait_for_and_click()
self.components.upload.file_dialog_ok.wait_for_and_click()
self.upload_start()
self.upload_context("remote-files").stage_remote_file(
source_label="Posix",
file_label="a",
).start()
self.sleep_for(self.wait_types.UX_RENDER)
self.wait_for_history()
@selenium_test
def test_upload_from_posix_file_uri(self):
self.admin_login()
self.perform_upload_of_pasted_content(f"file://{self.root_dir}/a")
self.upload_context("paste-links").stage_paste_link(f"file://{self.root_dir}/a").start()
self.sleep_for(self.wait_types.UX_RENDER)
self.wait_for_history()
+5 -9
View File
@@ -1,12 +1,13 @@
import os
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
)
class TestUploadFtpSeleniumIntegration(SeleniumIntegrationTestCase):
class TestUploadFtpSeleniumIntegration(SeleniumIntegrationTestCase, UsesUploadActivity):
ensure_registered = True
@classmethod
@@ -23,15 +24,10 @@ class TestUploadFtpSeleniumIntegration(SeleniumIntegrationTestCase):
def _upload_all(self, n):
self.home()
self.components.upload.start.wait_for_and_click()
self.components.upload.file_dialog.wait_for_and_click()
self.components.upload.file_source_selector(path="gxftp://").wait_for_and_click()
context = self.upload_context("remote-files")
for i in range(n):
self.components.upload.file_source_selector(path=f"gxftp://{i}.txt").wait_for_and_click()
self.components.upload.file_dialog_ok.wait_for_and_click()
for i in range(n):
self.components.upload.row(n=i).wait_for_visible()
self.upload_start()
context.stage_remote_file(source_label="FTP", file_label=f"{i}.txt")
context.start()
self.sleep_for(self.wait_types.UX_RENDER)
self.wait_for_history()
@@ -2,6 +2,7 @@ from galaxy.selenium.navigates_galaxy import (
ConfigTemplateParameter,
FileSourceInstance,
)
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from ._base_user_file_sources import BaseUserObjectStoreSeleniumIntegration
from .framework import (
managed_history,
@@ -9,7 +10,7 @@ from .framework import (
)
class TestUserFileSourceAwsPublicSeleniumIntegration(BaseUserObjectStoreSeleniumIntegration):
class TestUserFileSourceAwsPublicSeleniumIntegration(BaseUserObjectStoreSeleniumIntegration, UsesUploadActivity):
example_filename = "production_aws_public_bucket.yml"
@managed_history
@@ -25,4 +26,5 @@ class TestUserFileSourceAwsPublicSeleniumIntegration(BaseUserObjectStoreSelenium
],
)
uri_root = self.create_file_source_template(instance)
self.upload_uri(f"{uri_root}/robots.txt", wait=True)
self.upload_context("paste-links").stage_paste_link(f"{uri_root}/robots.txt").start()
self.wait_for_history()
@@ -5,6 +5,7 @@ from galaxy.selenium.navigates_galaxy import (
FileSourceInstance,
)
from galaxy.util.unittest_utils import skip_unless_environ
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from ._base_user_file_sources import BaseUserObjectStoreSeleniumIntegration
from .framework import (
managed_history,
@@ -12,7 +13,7 @@ from .framework import (
)
class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumIntegration):
class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumIntegration, UsesUploadActivity):
@skip_unless_environ("GALAXY_TEST_AZURE_CONTAINER_NAME")
@skip_unless_environ("GALAXY_TEST_AZURE_ACCOUNT_KEY")
@skip_unless_environ("GALAXY_TEST_AZURE_ACCOUNT_NAME")
@@ -39,4 +40,5 @@ class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumInt
"my_cool_file",
uri_root,
)
self.upload_uri(published_uri, wait=True)
self.upload_context("paste-links").stage_paste_link(published_uri).start()
self.wait_for_history()
@@ -2,6 +2,7 @@ from galaxy.selenium.navigates_galaxy import (
ConfigTemplateParameter,
FileSourceInstance,
)
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from ._base_user_file_sources import BaseUserObjectStoreSeleniumIntegration
from .framework import (
managed_history,
@@ -9,7 +10,7 @@ from .framework import (
)
class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumIntegration):
class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumIntegration, UsesUploadActivity):
example_filename = "production_ftp.yml"
@selenium_test
@@ -27,4 +28,5 @@ class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumInt
],
)
uri_root = self.create_file_source_template(instance)
self.upload_uri(f"{uri_root}/welcome.msg", wait=True)
self.upload_context("paste-links").stage_paste_link(f"{uri_root}/welcome.msg").start()
self.wait_for_history()
@@ -6,6 +6,7 @@ from galaxy.selenium.navigates_galaxy import (
ConfigTemplateParameter,
FileSourceInstance,
)
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from ._base_user_file_sources import BaseUserObjectStoreSeleniumIntegration
from ._sftp_server import SFTPServerMixin
from .framework import (
@@ -14,7 +15,9 @@ from .framework import (
)
class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumIntegration, SFTPServerMixin):
class TestObjectStoreSelectionSeleniumIntegration(
BaseUserObjectStoreSeleniumIntegration, SFTPServerMixin, UsesUploadActivity
):
"""Selenium tests for the SSH user file source template.
A single in-process SFTP server is started for the whole class and torn
@@ -71,7 +74,8 @@ class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumInt
],
)
uri_root = self.create_file_source_template(instance)
self.upload_uri(f"{uri_root}/test_file.txt", wait=True)
self.upload_context("paste-links").stage_paste_link(f"{uri_root}/test_file.txt").start()
self.wait_for_history()
@selenium_test
@managed_history
@@ -95,4 +99,5 @@ class TestObjectStoreSelectionSeleniumIntegration(BaseUserObjectStoreSeleniumInt
],
)
uri_root = self.create_file_source_template(instance)
self.upload_uri(f"{uri_root}/subdir_file.txt", wait=True)
self.upload_context("paste-links").stage_paste_link(f"{uri_root}/subdir_file.txt").start()
self.wait_for_history()
@@ -9,6 +9,7 @@ from galaxy_test.selenium.framework import (
selenium_only,
UsesHistoryItemAssertions,
)
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
@@ -18,7 +19,9 @@ if TYPE_CHECKING:
from galaxy_test.selenium.framework import SeleniumSessionDatasetPopulator
class BaseWorkflowRunTargetTestCase(SeleniumIntegrationTestCase, RunsWorkflows, UsesHistoryItemAssertions):
class BaseWorkflowRunTargetTestCase(
SeleniumIntegrationTestCase, RunsWorkflows, UsesHistoryItemAssertions, UsesUploadActivity
):
dataset_populator: "SeleniumSessionDatasetPopulator"
ensure_registered = True
@@ -35,7 +38,7 @@ class TestWorkflowRunNotificationSeleniumIntegration(BaseWorkflowRunTargetTestCa
def test_on_complete_notification_action(self):
"""Test configuring the send notification completion action."""
filename = self.test_data_resolver.get_filename("1.fasta")
self.perform_upload(filename)
self.upload_context("local-file").stage_local_file(filename).start()
self.wait_for_history()
self.workflow_run_open_workflow(WORKFLOW_SIMPLE_CAT_TWICE)
self.sleep_for(self.wait_types.UX_RENDER)
@@ -6,6 +6,7 @@ from galaxy_test.selenium.framework import (
RunsWorkflows,
UsesHistoryItemAssertions,
)
from galaxy_test.selenium.upload_activity_helpers import UsesUploadActivity
from .framework import (
selenium_test,
SeleniumIntegrationTestCase,
@@ -15,7 +16,9 @@ if TYPE_CHECKING:
from galaxy_test.selenium.framework import SeleniumSessionDatasetPopulator
class BaseWorkflowRunTargetTestCase(SeleniumIntegrationTestCase, RunsWorkflows, UsesHistoryItemAssertions):
class BaseWorkflowRunTargetTestCase(
SeleniumIntegrationTestCase, RunsWorkflows, UsesHistoryItemAssertions, UsesUploadActivity
):
dataset_populator: "SeleniumSessionDatasetPopulator"
ensure_registered = True
@@ -31,7 +34,7 @@ class TestWorkflowRunTargetNewSeleniumIntegration(BaseWorkflowRunTargetTestCase)
@managed_history
def test_execution_to_new_history(self):
filename = self.test_data_resolver.get_filename("1.fasta")
self.perform_upload(filename)
self.upload_context("local-file").stage_local_file(filename).start()
self.wait_for_history()
self.workflow_run_open_workflow(WORKFLOW_SIMPLE_CAT_TWICE)
workflow_run = self.components.workflow_run
@@ -57,7 +60,7 @@ class TestWorkflowRunTargetCurrentSeleniumIntegration(BaseWorkflowRunTargetTestC
@managed_history
def test_execution_in_current_history(self):
filename = self.test_data_resolver.get_filename("1.fasta")
self.perform_upload(filename)
self.upload_context("local-file").stage_local_file(filename).start()
self.wait_for_history()
self.workflow_run_open_workflow(WORKFLOW_SIMPLE_CAT_TWICE)
workflow_run = self.components.workflow_run
@@ -81,7 +84,7 @@ class TestWorkflowRunTargetSelectNewSeleniumIntegration(BaseWorkflowRunTargetTes
@managed_history
def test_execution_in_current_history(self):
filename = self.test_data_resolver.get_filename("1.fasta")
self.perform_upload(filename)
self.upload_context("local-file").stage_local_file(filename).start()
self.wait_for_history()
self.workflow_run_open_workflow(WORKFLOW_SIMPLE_CAT_TWICE)
workflow_run = self.components.workflow_run