-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
374 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
name: Playwright Tests | ||
name: Execute tests on georchestra/docker:master | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
schedule: | ||
- cron: "0 4 * * 1" | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
|
@@ -12,6 +17,9 @@ jobs: | |
- uses: actions/checkout@v4 | ||
with: | ||
path: tests | ||
- name: Add hosts to /etc/hosts | ||
run: | | ||
sudo echo "127.0.0.1 georchestra-127-0-0-1.nip.io" | sudo tee -a /etc/hosts | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
|
@@ -30,14 +38,17 @@ jobs: | |
with: | ||
repository: georchestra/docker | ||
submodules: 'recursive' | ||
ref: 'rbmq-limited' | ||
ref: 'data-api-24' | ||
path: 'docker' | ||
|
||
- name: Launch docker-compose | ||
run: | | ||
cd docker | ||
docker compose up -d --wait --quiet-pull | ||
cd .. | ||
echo "Trigger GN wro4j..." | ||
curl -k https://georchestra-127-0-0-1.nip.io/geonetwork/srv/eng/catalog.search | ||
- name: Caddy trust | ||
run: | | ||
|
@@ -46,7 +57,11 @@ jobs: | |
./caddy trust | ||
- name: Run your tests | ||
run: pytest tests --tracing=retain-on-failure --alluredir=allure-results | ||
run: | | ||
cd ./tests | ||
pwd | ||
pytest tests --tracing=retain-on-failure --alluredir=allure-results --base-url=https://georchestra-127-0-0-1.nip.io --reruns=1 | ||
cd .. | ||
- name: Load test report history | ||
uses: actions/checkout@v3 | ||
|
@@ -60,9 +75,8 @@ jobs: | |
uses: simple-elf/[email protected] | ||
if: always() | ||
with: | ||
gh_pages: gh-pages | ||
allure_history: allure-history | ||
allure_results: allure-results | ||
allure_results: tests/allure-results | ||
keep_reports: 5 | ||
|
||
- name: Publish test report | ||
uses: peaceiris/actions-gh-pages@v3 | ||
|
@@ -71,9 +85,10 @@ jobs: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_branch: gh-pages | ||
publish_dir: allure-history | ||
force_orphan: true | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: playwright-traces | ||
path: test-results/ | ||
path: test-results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Push on docker hub | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
|
||
jobs: | ||
build: | ||
if: "!startsWith(github.event.head_commit.message, '[skip ci] ')" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- name: "Checking out" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Building docker image" | ||
if: github.repository == 'georchestra/e2e-tests' | ||
run: | | ||
docker build -t georchestra/e2e-tests:latest . | ||
- name: "Logging in docker.io" | ||
if: github.repository == 'georchestra/e2e-tests' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' | ||
uses: azure/docker-login@v1 | ||
with: | ||
username: '${{ secrets.DOCKER_HUB_USERNAME }}' | ||
password: '${{ secrets.DOCKER_HUB_PASSWORD }}' | ||
|
||
- name: "Update Docker Hub Description" | ||
uses: peter-evans/dockerhub-description@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
repository: georchestra/e2e-tests | ||
readme-filepath: ./DOCKER_HUB.md | ||
short-description: 'End to end tests for the geOrchestra SDI' | ||
|
||
- name: "Pushing latest to docker.io" | ||
if: github.ref == 'refs/heads/main' && github.repository == 'georchestra/e2e-tests' | ||
run: | | ||
docker push georchestra/e2e-tests:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Quick reference | ||
|
||
- **Maintained by**: | ||
[georchestra.org](https://www.georchestra.org/) | ||
|
||
- **Where to get help**: | ||
the [geOrchestra Github repo](https://github.com/georchestra/georchestra), [IRC chat](https://matrix.to/#/#georchestra:osgeo.org), Stack Overflow | ||
|
||
# Featured tags | ||
|
||
- `latest` | ||
|
||
# Quick reference | ||
|
||
- **Where to file issues**: | ||
[https://github.com/georchestra/georchestra/issues](https://github.com/georchestra/e2e-tests/issues) | ||
|
||
- **Supported architectures**: | ||
[`amd64`](https://hub.docker.com/r/amd64/docker/) | ||
|
||
- **Source of this description**: | ||
[docs repo's directory](https://github.com/georchestra/e2e-tests/blob/main/DOCKER_HUB.md) | ||
|
||
# What is `georchestra/e2e-tests` ? | ||
|
||
This project contains automated tests for the geOrchestra web applications using Playwright and pytest. | ||
|
||
A [complete description](https://github.com/georchestra/e2e-tests/blob/main/console/README.md) is available on github . | ||
|
||
# How to use base image and run specific tests | ||
|
||
Create a folder where you put your specific tests and create a Dockerfile with the following content: | ||
|
||
```Dockerfile | ||
FROM georchestra/e2e-tests:latest | ||
|
||
COPY mytests /app/tests/mytests | ||
``` | ||
|
||
## Where is it built | ||
|
||
This image is built using Dockerfile in [docs repo's directory](https://github.com/georchestra/e2e-tests/blob/main/Dockerfile) | ||
|
||
# License | ||
|
||
View [license information](https://www.georchestra.org/software.html) for the software contained in this image. | ||
|
||
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained). | ||
|
||
[//]: # (Some additional license information which was able to be auto-detected might be found in [the `repo-info` repository's georchestra/ directory]().) | ||
|
||
As for any docker image, it is the user's responsibility to ensure that usages of this image comply with any relevant licenses for all software contained within. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3-slim | ||
ENV BASE_URL=https://georchestra-127-0-0-1.nip.io | ||
|
||
COPY . /app | ||
|
||
WORKDIR /app | ||
RUN pip install -r requirements.txt | ||
RUN python -m playwright install --with-deps | ||
|
||
ENTRYPOINT pytest --base-url=$BASE_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import yaml | ||
import os | ||
|
||
def path_from_project_root(file_path: str) -> str: | ||
_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
return _root_dir + '/' + file_path | ||
|
||
class ConfigurationManager: | ||
with open(path_from_project_root('resources/config.yaml'), 'rb') as __config_file: | ||
__configs = yaml.load(__config_file, Loader=yaml.FullLoader) | ||
|
||
@staticmethod | ||
def __config() -> dict: | ||
return ConfigurationManager.__configs | ||
|
||
@staticmethod | ||
def local_admin() -> dict: | ||
return ConfigurationManager.__configs['local.account'] | ||
|
||
@staticmethod | ||
def write_tests_disabled() -> bool: | ||
return ConfigurationManager.__configs['write_tests_disabled'] == 'true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
addopts = --base-url=https://georchestra-127-0-0-1.nip.io --reruns=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
allure-pytest | ||
pytest-playwright | ||
pytest-playwright | ||
pyyaml | ||
pytest-rerunfailures |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
local.account: | ||
username: 'testadmin' | ||
password: 'testadmin' | ||
write_tests_disabled: 'false' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
import allure | ||
from playwright.sync_api import Page | ||
|
||
from helper.configuration_manager import ConfigurationManager | ||
|
||
|
||
|
||
def screenshot_page(page, name): | ||
png_bytes = page.screenshot() | ||
allure.attach( | ||
png_bytes, | ||
name=name, | ||
attachment_type=allure.attachment_type.PNG | ||
) | ||
) | ||
|
||
def login(page: Page, cas: bool = False): | ||
page.goto("/datahub/") | ||
page.get_by_role("link", name="login").click() | ||
username_input = page.get_by_placeholder("Username") | ||
if cas: | ||
username_input = page.locator("#username") | ||
username_input.fill(ConfigurationManager.local_admin()["username"]) | ||
username_input.press("Tab") | ||
password_input = page.get_by_placeholder("Password") | ||
if cas: | ||
password_input = page.locator("#password") | ||
password_input.fill(ConfigurationManager.local_admin()["password"]) | ||
password_input.press("Enter") |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import allure | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
from tests.common import screenshot_page, login | ||
import pytest | ||
|
||
|
||
@allure.epic("Web interface") | ||
@allure.feature("geOrchestra") | ||
@allure.story("GeoNetwork") | ||
@allure.description("This test attempts to load every GeoNetwork wro4j.") | ||
@allure.title("Test the GeoNetwork webapp") | ||
@pytest.mark.flaky(reruns=5) | ||
def test_geo_network_webapp(page: Page): | ||
login(page) | ||
#Search page | ||
page.goto("/geonetwork/srv/eng/catalog.search") | ||
expect(page.get_by_role("combobox", name="Search")).to_be_visible(timeout=20000) | ||
screenshot_page(page,"geonetwork search") | ||
#Editor page | ||
page.goto("/geonetwork/srv/eng/catalog.edit#/board?from=1&to=30") | ||
expect(page.get_by_role("link", name="+ Add new record")).to_be_visible(timeout=20000) | ||
screenshot_page(page,"geonetwork editor") | ||
#admin page | ||
page.goto("/geonetwork/srv/eng/admin.console#/home") | ||
expect(page.locator("body")).to_contain_text(expected="Harvesting", timeout=20000) | ||
screenshot_page(page,"geonetwork admin") | ||
|
||
|
Oops, something went wrong.