From 96c0c7a7907e3546b5777a981a0397dc71317a86 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 08:08:35 +0000 Subject: [PATCH 1/3] Initial plan From bf055f8d9ae877d93cda7ed88f408a986d152c95 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 08:10:38 +0000 Subject: [PATCH 2/3] refactor: centralize module testing Agent-Logs-Url: https://github.com/NethServer/ns8-imapsync/sessions/00434d5a-2625-4ff3-8747-eb837cea25f3 Co-authored-by: andre8244 <4612169+andre8244@users.noreply.github.com> --- .github/workflows/test-module.yml | 14 ++++----- .gitignore | 2 ++ README.md | 9 ++---- test-module.sh | 49 ------------------------------- tests/15_ui.robot | 34 +++++++++++++++++++++ tests/pythonreq.txt | 2 -- 6 files changed, 43 insertions(+), 67 deletions(-) delete mode 100755 test-module.sh create mode 100644 tests/15_ui.robot delete mode 100644 tests/pythonreq.txt diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index e079fd39..326e94f6 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -12,15 +12,11 @@ on: types: [completed] jobs: - module: - if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == '' }} - uses: NethServer/ns8-github-actions/.github/workflows/module-info.yml@v1 - run_tests: - needs: module - uses: NethServer/ns8-github-actions/.github/workflows/test-on-digitalocean-infra.yml@v1 + run: + name: "Run tests" + uses: NethServer/ns8-github-actions/.github/workflows/test-module.yml@v1 with: - args: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}" - repo_ref: ${{needs.module.outputs.sha}} - debug_shell: ${{ github.event.inputs.debug_shell == 'true' || false }} + ui_tests_strategy: always + debug_shell: ${{ github.event.inputs.debug_shell == 'true' }} secrets: do_token: ${{ secrets.do_token }} diff --git a/.gitignore b/.gitignore index 67045665..d123a229 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,5 @@ dist # TernJS port file .tern-port + +tests/outputs/ diff --git a/README.md b/README.md index d3767dd2..306ef5e1 100644 --- a/README.md +++ b/README.md @@ -527,14 +527,9 @@ To uninstall the instance: remove-module --no-preserve imapsync1 -## Testing +## Running tests locally -Test the module using the `test-module.sh` script: - - - ./test-module.sh ghcr.io/nethserver/imapsync:latest - -The tests are made using [Robot Framework](https://robotframework.org/) +This module uses the NS8 standard testing infrastructure. For instructions on how to run the test suite locally, refer to the [Running tests locally](https://github.com/NethServer/ns8-github-actions/blob/v1/README.md#running-tests-locally) section of the ns8-github-actions repository. ## UI translation diff --git a/test-module.sh b/test-module.sh deleted file mode 100755 index 76ef1778..00000000 --- a/test-module.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# -# Copyright (C) 2024 Nethesis S.r.l. -# SPDX-License-Identifier: GPL-3.0-or-later -# - -# -# Hint: access the test logs on HTTP port 8000 with this command: -# -# python -mhttp.server -d tests/outputs/ 8000 & -# - -set -e - -SSH_KEYFILE=${SSH_KEYFILE:-$HOME/.ssh/id_rsa} - -LEADER_NODE="${1:?missing LEADER_NODE argument}" -IMAGE_URL="${2:?missing IMAGE_URL argument}" -shift 2 - -ssh_key="$(< $SSH_KEYFILE)" - -cleanup() { - set +e - podman cp rf-core-runner:/home/pwuser/outputs tests/ - podman stop rf-core-runner - podman rm rf-core-runner -} - -trap cleanup EXIT -podman run -i \ - --network=host \ - --volume=.:/home/pwuser/ns8-module:z \ - --volume=site-packages:/home/pwuser/.local/lib/python3.12/site-packages:z \ - --name rf-core-runner ghcr.io/marketsquare/robotframework-browser/rfbrowser-stable:19.11.0 \ - bash -l -s < /home/pwuser/ns8-key -pip install -q -r /home/pwuser/ns8-module/tests/pythonreq.txt -mkdir ~/outputs -cd /home/pwuser/ns8-module -exec robot -v NODE_ADDR:${LEADER_NODE} \ - -v IMAGE_URL:${IMAGE_URL} \ - -v SSH_KEYFILE:/home/pwuser/ns8-key \ - --name "$(basename $PWD)" \ - --skiponfailure unstable \ - -d ~/outputs ${@} /home/pwuser/ns8-module/tests/ -EOF diff --git a/tests/15_ui.robot b/tests/15_ui.robot new file mode 100644 index 00000000..55d1fe8e --- /dev/null +++ b/tests/15_ui.robot @@ -0,0 +1,34 @@ +*** Settings *** +Library Browser + +*** Variables *** +${ADMIN_USER} admin +${ADMIN_PASSWORD} Nethesis,1234 +${MID} ${EMPTY} + +*** Keywords *** + +Login to cluster-admin + New Page https://${NODE_ADDR}/cluster-admin/ + Fill Text text="Username" ${ADMIN_USER} + Click button >> text="Continue" + Fill Text text="Password" ${ADMIN_PASSWORD} + Click button >> text="Log in" + Wait For Elements State css=#main-content visible timeout=10s + +*** Test Cases *** + +Take screenshots + [Tags] ui + New Browser chromium headless=True + New Context ignoreHTTPSErrors=True + Login to cluster-admin + Go To https://${NODE_ADDR}/cluster-admin/#/apps/${MID} + Wait For Elements State iframe >>> h2 >> text="Status" visible timeout=10s + Sleep 5s + Take Screenshot filename=${OUTPUT DIR}/browser/screenshot/1._Status.png + Go To https://${NODE_ADDR}/cluster-admin/#/apps/${MID}?page=settings + Wait For Elements State iframe >>> h2 >> text="Settings" visible timeout=10s + Sleep 5s + Take Screenshot filename=${OUTPUT DIR}/browser/screenshot/2._Settings.png + Close Browser diff --git a/tests/pythonreq.txt b/tests/pythonreq.txt deleted file mode 100644 index af1d9bf5..00000000 --- a/tests/pythonreq.txt +++ /dev/null @@ -1,2 +0,0 @@ -robotframework -robotframework-sshlibrary From e0afeec9bf24765801bca6f41593b904d79c3edd Mon Sep 17 00:00:00 2001 From: Andrea Leardini Date: Mon, 4 May 2026 12:37:28 +0200 Subject: [PATCH 3/3] fix --- .github/workflows/test-module.yml | 2 +- tests/{15_ui.robot => 30_ui.robot} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename tests/{15_ui.robot => 30_ui.robot} (83%) diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index 326e94f6..24904441 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -16,7 +16,7 @@ jobs: name: "Run tests" uses: NethServer/ns8-github-actions/.github/workflows/test-module.yml@v1 with: - ui_tests_strategy: always + ui_tests_strategy: on_renovate_ui_change debug_shell: ${{ github.event.inputs.debug_shell == 'true' }} secrets: do_token: ${{ secrets.do_token }} diff --git a/tests/15_ui.robot b/tests/30_ui.robot similarity index 83% rename from tests/15_ui.robot rename to tests/30_ui.robot index 55d1fe8e..37866a5f 100644 --- a/tests/15_ui.robot +++ b/tests/30_ui.robot @@ -4,7 +4,7 @@ Library Browser *** Variables *** ${ADMIN_USER} admin ${ADMIN_PASSWORD} Nethesis,1234 -${MID} ${EMPTY} +${imapsync_module_id} ${EMPTY} *** Keywords *** @@ -23,11 +23,11 @@ Take screenshots New Browser chromium headless=True New Context ignoreHTTPSErrors=True Login to cluster-admin - Go To https://${NODE_ADDR}/cluster-admin/#/apps/${MID} + Go To https://${NODE_ADDR}/cluster-admin/#/apps/${imapsync_module_id} Wait For Elements State iframe >>> h2 >> text="Status" visible timeout=10s Sleep 5s Take Screenshot filename=${OUTPUT DIR}/browser/screenshot/1._Status.png - Go To https://${NODE_ADDR}/cluster-admin/#/apps/${MID}?page=settings + Go To https://${NODE_ADDR}/cluster-admin/#/apps/${imapsync_module_id}?page=settings Wait For Elements State iframe >>> h2 >> text="Settings" visible timeout=10s Sleep 5s Take Screenshot filename=${OUTPUT DIR}/browser/screenshot/2._Settings.png