This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/main by this push:
     new a3b9971  Add tests for the ongoing tasks script
a3b9971 is described below

commit a3b997105299f9dd432b4037b089f5bf2d17a7aa
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Dec 11 20:31:56 2025 +0000

    Add tests for the ongoing tasks script
---
 tests/e2e/compose/__init__.py |  16 +++++++
 tests/e2e/compose/conftest.py |  91 ++++++++++++++++++++++++++++++++++++
 tests/e2e/compose/test_get.py | 106 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 213 insertions(+)

diff --git a/tests/e2e/compose/__init__.py b/tests/e2e/compose/__init__.py
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/tests/e2e/compose/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
diff --git a/tests/e2e/compose/conftest.py b/tests/e2e/compose/conftest.py
new file mode 100644
index 0000000..0808bb5
--- /dev/null
+++ b/tests/e2e/compose/conftest.py
@@ -0,0 +1,91 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import pathlib
+from typing import TYPE_CHECKING, Final
+
+import e2e.helpers as helpers  # type: ignore[reportMissingImports]
+import pytest
+
+if TYPE_CHECKING:
+    from collections.abc import Generator
+
+    from playwright.sync_api import Browser, BrowserContext, Page
+
+PROJECT_NAME: Final[str] = "test"
+VERSION_NAME: Final[str] = "0.1+compose"
+FILE_NAME: Final[str] = "apache-test-0.2.tar.gz"
+CURRENT_DIR: Final[pathlib.Path] = pathlib.Path(__file__).parent.resolve()
+COMPOSE_URL: Final[str] = f"/compose/{PROJECT_NAME}/{VERSION_NAME}"
+
+
[email protected](scope="module")
+def compose_context(browser: Browser) -> Generator[BrowserContext]:
+    """Create a release in the compose phase with completed tasks."""
+    context = browser.new_context(ignore_https_errors=True)
+    page = context.new_page()
+
+    helpers.log_in(page)
+
+    _delete_release_if_exists(page)
+
+    helpers.visit(page, f"/start/{PROJECT_NAME}")
+    page.locator("input#version_name").fill(VERSION_NAME)
+    page.get_by_role("button", name="Start new release").click()
+    page.wait_for_url(f"**/compose/{PROJECT_NAME}/{VERSION_NAME}")
+
+    helpers.visit(page, f"/upload/{PROJECT_NAME}/{VERSION_NAME}")
+    
page.locator('input[name="file_data"]').set_input_files(f"{CURRENT_DIR}/../test_files/{FILE_NAME}")
+    page.get_by_role("button", name="Add files").click()
+    page.wait_for_url(f"**/compose/{PROJECT_NAME}/{VERSION_NAME}")
+
+    helpers.visit(page, f"/compose/{PROJECT_NAME}/{VERSION_NAME}")
+    _wait_for_tasks_banner_hidden(page, timeout=60000)
+
+    page.close()
+
+    yield context
+
+    context.close()
+
+
[email protected]
+def page_compose(compose_context: BrowserContext) -> Generator[Page]:
+    """Navigate to the compose page with a fresh page for each test."""
+    page = compose_context.new_page()
+    helpers.visit(page, COMPOSE_URL)
+    yield page
+    page.close()
+
+
+def _delete_release_if_exists(page: Page) -> None:
+    """Delete the test release if it already exists."""
+    helpers.visit(page, COMPOSE_URL)
+    if not page.url.endswith(COMPOSE_URL.lstrip("/")):
+        return
+    delete_form = page.locator("#delete-draft-form form")
+    if delete_form.count() == 0:
+        return
+    delete_form.get_by_role("button").click()
+    page.wait_for_load_state()
+
+
+def _wait_for_tasks_banner_hidden(page: Page, timeout: int = 30000) -> None:
+    """Wait for all background tasks to be completed."""
+    page.wait_for_selector("#ongoing-tasks-banner", state="hidden", 
timeout=timeout)
diff --git a/tests/e2e/compose/test_get.py b/tests/e2e/compose/test_get.py
new file mode 100644
index 0000000..fecda2b
--- /dev/null
+++ b/tests/e2e/compose/test_get.py
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import re
+
+from playwright.sync_api import Page, expect
+
+
+def test_ongoing_tasks_banner_appears_when_tasks_restart(page_compose: Page) 
-> None:
+    """The ongoing tasks banner should appear when tasks are restarted."""
+    banner = page_compose.locator("#ongoing-tasks-banner")
+    expect(banner).to_be_hidden()
+
+    restart_button = page_compose.get_by_role("button", name="Restart all 
checks")
+    restart_button.click()
+    page_compose.wait_for_load_state()
+
+    expect(banner).to_be_visible()
+
+
+def test_ongoing_tasks_banner_has_progress_bar(page_compose: Page) -> None:
+    """The ongoing tasks banner should have a progress bar."""
+    restart_button = page_compose.get_by_role("button", name="Restart all 
checks")
+    restart_button.click()
+    page_compose.wait_for_load_state()
+
+    progress_bar = page_compose.locator("#poll-progress")
+    expect(progress_bar).to_be_visible()
+
+
+def test_ongoing_tasks_banner_has_task_count(page_compose: Page) -> None:
+    """The ongoing tasks banner should display the task count."""
+    restart_button = page_compose.get_by_role("button", name="Restart all 
checks")
+    restart_button.click()
+    page_compose.wait_for_load_state()
+
+    count_element = page_compose.locator("#ongoing-tasks-count")
+    expect(count_element).to_be_visible()
+    expect(count_element).not_to_be_empty()
+
+
+def test_ongoing_tasks_banner_has_warning_icon(page_compose: Page) -> None:
+    """The ongoing tasks banner should have a warning icon when visible."""
+    restart_button = page_compose.get_by_role("button", name="Restart all 
checks")
+    restart_button.click()
+    page_compose.wait_for_load_state()
+
+    warning_icon = page_compose.locator("#ongoing-tasks-banner 
i.bi-exclamation-triangle")
+    expect(warning_icon).to_be_visible()
+
+
+def test_ongoing_tasks_banner_hidden_when_complete(page_compose: Page) -> None:
+    """The ongoing tasks banner should be hidden when all tasks are 
complete."""
+    banner = page_compose.locator("#ongoing-tasks-banner")
+    expect(banner).to_be_hidden(timeout=60000)
+
+
+def test_ongoing_tasks_banner_hides_when_tasks_complete(page_compose: Page) -> 
None:
+    """The ongoing tasks banner should hide when all tasks complete."""
+    restart_button = page_compose.get_by_role("button", name="Restart all 
checks")
+    restart_button.click()
+    page_compose.wait_for_load_state()
+
+    banner = page_compose.locator("#ongoing-tasks-banner")
+    expect(banner).to_be_visible()
+
+    expect(banner).to_be_hidden(timeout=60000)
+
+
+def test_ongoing_tasks_script_loaded(page_compose: Page) -> None:
+    """The ongoing-tasks-poll.js script should be loaded on the compose 
page."""
+    script = page_compose.locator('script[src*="ongoing-tasks-poll.js"]')
+    expect(script).to_be_attached()
+
+
+def test_start_vote_button_enabled_when_tasks_complete(page_compose: Page) -> 
None:
+    """The start vote button should be enabled when all tasks are complete."""
+    vote_button = page_compose.locator("#start-vote-button")
+    expect(vote_button).to_be_visible()
+    expect(vote_button).not_to_have_class("disabled")
+
+
+def test_start_vote_button_has_href(page_compose: Page) -> None:
+    """The start vote button should have an href attribute set."""
+    vote_button = page_compose.locator("#start-vote-button")
+    expect(vote_button).to_have_attribute("href", 
re.compile(r"/voting/test/0\.1\+compose/\d+"))
+
+
+def test_start_vote_button_has_title(page_compose: Page) -> None:
+    """The start vote button should have a descriptive title."""
+    vote_button = page_compose.locator("#start-vote-button")
+    expect(vote_button).to_have_attribute("title", "Start a vote on this 
draft")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to