diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index e079fd3..2490444 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 6704566..d123a22 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 449f151..23dc029 100644 --- a/README.md +++ b/README.md @@ -86,14 +86,9 @@ To uninstall the instance: remove-module --no-preserve kickstart1 -## Testing +## Running tests locally -Test the module using the `test-module.sh` script: - - - ./test-module.sh ghcr.io/nethserver/kickstart: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 README. ## UI translation diff --git a/test-module.sh b/test-module.sh deleted file mode 100755 index 17b4dba..0000000 --- a/test-module.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# -# Copyright (C) 2023 Nethesis S.r.l. -# SPDX-License-Identifier: GPL-3.0-or-later -# - -LEADER_NODE=$1 -IMAGE_URL=$2 -SSH_KEYFILE=${SSH_KEYFILE:-$HOME/.ssh/id_rsa} - -ssh_key="$(cat $SSH_KEYFILE)" - -podman run -i \ - -v .:/home/pwuser/ns8-module:z \ - --name rf-core-runner ghcr.io/marketsquare/robotframework-browser/rfbrowser-stable:v10.0.3 \ - bash -l -s < /home/pwuser/ns8-key - set -x - pip install -r /home/pwuser/ns8-module/tests/pythonreq.txt - mkdir ~/outputs - cd /home/pwuser/ns8-module - robot -v NODE_ADDR:${LEADER_NODE} \ - -v IMAGE_URL:${IMAGE_URL} \ - -v SSH_KEYFILE:/home/pwuser/ns8-key \ - -d ~/outputs /home/pwuser/ns8-module/tests/ -EOF - -tests_res=$? - -podman cp rf-core-runner:/home/pwuser/outputs tests/ -podman stop rf-core-runner -podman rm rf-core-runner - -exit ${tests_res} diff --git a/tests/kickstart.robot b/tests/10__kickstart.robot similarity index 93% rename from tests/kickstart.robot rename to tests/10__kickstart.robot index e1984f0..e738112 100644 --- a/tests/kickstart.robot +++ b/tests/10__kickstart.robot @@ -7,7 +7,7 @@ Check if kickstart is installed correctly ... return_rc=True Should Be Equal As Integers ${rc} 0 &{output} = Evaluate ${output} - Set Suite Variable ${module_id} ${output.module_id} + Set Global Variable ${module_id} ${output.module_id} Check if kickstart can be configured ${rc} = Execute Command api-cli run module/${module_id}/configure-module --data '{}' diff --git a/tests/20__ui.robot b/tests/20__ui.robot new file mode 100644 index 0000000..e89ed75 --- /dev/null +++ b/tests/20__ui.robot @@ -0,0 +1,34 @@ +*** Settings *** +Library Browser + +*** Variables *** +${ADMIN_USER} admin +${ADMIN_PASSWORD} Nethesis,1234 +${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/${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/${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