diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index e079fd39..24904441 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: on_renovate_ui_change + 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/30_ui.robot b/tests/30_ui.robot new file mode 100644 index 00000000..37866a5f --- /dev/null +++ b/tests/30_ui.robot @@ -0,0 +1,34 @@ +*** Settings *** +Library Browser + +*** Variables *** +${ADMIN_USER} admin +${ADMIN_PASSWORD} Nethesis,1234 +${imapsync_module_id} ${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/${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/${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 + 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