-
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.
🔧 configured docker to run playwright tests
- Loading branch information
Showing
16 changed files
with
374 additions
and
43 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# General exclusions | ||
# Exclude version control | ||
.git | ||
*.gitignore | ||
|
||
# Exclude IDE and editor files | ||
.vscode | ||
|
||
# Exclude logs and caches | ||
logs | ||
*.log | ||
cache | ||
*.cache | ||
|
||
# Exclude build artifacts | ||
build | ||
dist | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# Node.js specific | ||
node_modules | ||
|
||
# Python specific | ||
__pycache__/ | ||
.pytest_cache | ||
|
||
# Mypy | ||
.mypy_cache |
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
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,20 @@ | ||
# Use the official Node.js image | ||
FROM node:20 | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json yarn.lock ./ | ||
COPY .yarnrc.yml ./ | ||
|
||
# Install dependencies | ||
RUN \ | ||
apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& yarn set version 4.3.0 \ | ||
&& yarn install --immutable | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 5173 | ||
|
||
# Command to run the application | ||
CMD ["yarn", "dev", "--host", "0.0.0.0"] |
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,24 @@ | ||
version: '3.8' | ||
|
||
services: | ||
web: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.dev | ||
ports: | ||
- "5173:5173" | ||
volumes: | ||
- ./:/app | ||
- /app/node_modules | ||
|
||
tests: | ||
build: | ||
context: . | ||
dockerfile: playwright/Dockerfile | ||
depends_on: | ||
- web | ||
environment: | ||
- BASE_URL=http://web:5173 | ||
- POETRY_VIRTUALENVS_CREATE=false | ||
volumes: | ||
- ./playwright:/app |
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
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 |
---|---|---|
|
@@ -161,3 +161,6 @@ cython_debug/ | |
|
||
# Custom Specifications | ||
# Project specific gitignores are listed here | ||
|
||
# Test reports | ||
reports |
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,20 @@ | ||
# Use the official Playwright image | ||
FROM mcr.microsoft.com/playwright/python:v1.43.0-jammy | ||
|
||
WORKDIR /app | ||
|
||
COPY playwright/pyproject.toml playwright/poetry.lock /app/ | ||
COPY playwright/scripts/entrypoint.sh /app/ | ||
|
||
RUN \ | ||
apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
# Install dependencies | ||
&& python3 -m pip install poetry \ | ||
&& python3 -m poetry install --no-root --no-interaction --no-ansi \ | ||
# Set entrypoint for Docker Image | ||
&& cp /app/entrypoint.sh /entrypoint.sh \ | ||
&& chmod +x /entrypoint.sh | ||
|
||
# Set the entrypoint | ||
ENTRYPOINT ["/entrypoint.sh"] |
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,88 @@ | ||
# Pytest Playwright UI Tests | ||
|
||
This is a suite of automated end-to-end UI tests for the AODN Portal v2. The tests are implemented using [pytest](https://pytest.org/) framework and [Playwright](https://playwright.dev/python/) for interactions with the web browser. | ||
|
||
## Setup Guide: | ||
|
||
### Python version: | ||
|
||
Python 3.10.x is required. **UNIX/MacOS** users can use [Pyenv](https://github.com/pyenv/pyenv) for Python version management. | ||
|
||
_However, This guide provides instructions for setting up your working environment using [Conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) to create a virtual [environment](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html) with the required Python version that should work on both UNIX/MacOS and Windows. Additionally, we'll utilize [Poetry](https://python-poetry.org/docs/) to manage packages within the `conda` environment._ | ||
|
||
## Installation: | ||
|
||
If you don't have `Conda` and `Poetry` installed, you'll need to install them before setting up the project. | ||
|
||
> _`Poetry` should be installed globally on your system, not within a Python virtual environment. We will utilize `pipx` to ensure that `Poetry` remains isolated in the global scope while also being accessible from anywhere on your system._ | ||
### Conda | ||
|
||
To install `Conda`, please refer to the [official guide](https://conda.io/projects/conda/en/latest/user-guide/install/index.html). | ||
|
||
### Poetry | ||
|
||
1. First, install `pipx` by following the instructions in the [official repository](https://github.com/pypa/pipx). Ensure that `pipx` is added to your system's PATH variable after installation. | ||
2. For **OSX** and **Z Shell** users, open up `~/.zshrc` and add this: | ||
|
||
```bash | ||
export PATH="$HOME/.local/bin:$PATH" | ||
``` | ||
|
||
3. Then, proceed to install `Poetry` by running the following command: | ||
|
||
```bash | ||
pipx install poetry | ||
``` | ||
|
||
## Project Setup: | ||
|
||
1. Open your terminal (Linux, MacOS) or the Miniconda/Anaconda Prompt (Windows). | ||
2. Navigate to the `/playwright` directory. | ||
3. Create a `conda` environment using the `environment.yml` file: | ||
|
||
```bash | ||
conda env create -f environment.yml | ||
``` | ||
|
||
> This command creates a virtual environment with the name `aodn-portal-v2` and installs the required python version. | ||
|
||
4. Activate this `conda` environment: | ||
```bash | ||
conda activate aodn-portal-v2 | ||
``` | ||
5. Install dependencies defined in `pyproject.toml`: | ||
```bash | ||
poetry install | ||
``` | ||
6. Install the required browsers: | ||
```bash | ||
playwright install | ||
``` | ||
7. Configure project related settings: | ||
|
||
a) Open the `settings.toml` file | ||
|
||
b) Update the required values according to your environment. | ||
|
||
## Running Tests: | ||
|
||
1. Run all tests: | ||
```bash | ||
pytest | ||
``` | ||
2. Run tests with visible browsers | ||
|
||
```bash | ||
pytest --headed | ||
``` | ||
|
||
3. To run tests in parallel, use the `--numprocesses` flag: | ||
```bash | ||
pytest --numprocesses auto | ||
``` | ||
More configurable options can be found in the [official documentation](https://playwright.dev/python/docs/running-tests). | ||
|
||
## Test Report: | ||
|
||
Test reports are generated using [pytest-html](https://pytest-html.readthedocs.io/en/latest/). The generated report for the _latest_ test run will be stored inside the `/playwright/reports` directory. |
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
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,7 @@ | ||
name: aodn-portal-v2 | ||
channels: | ||
- microsoft | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- python=3.10.12 |
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
Oops, something went wrong.