-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
front, scripts: add playwright container for e2e tests
Signed-off-by: Alice Khoudli <[email protected]>
- Loading branch information
Showing
5 changed files
with
68 additions
and
7 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 |
---|---|---|
|
@@ -84,6 +84,7 @@ | |
|
||
# OSRD dev scripts | ||
osrd-dev-scripts | ||
jq | ||
|
||
] | ||
# Section added only on Linux systems | ||
|
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,3 +1,4 @@ | ||
node_modules | ||
npm-debug.log | ||
Dockerfile | ||
playwright-report |
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,10 @@ | ||
ARG PLAYWRIGHT_VERSION=latest | ||
FROM mcr.microsoft.com/playwright:$PLAYWRIGHT_VERSION | ||
|
||
COPY front/package.json front/yarn.lock /app/front/ | ||
WORKDIR /app/front | ||
RUN yarn install --frozen-lockfile | ||
|
||
COPY front /app/front/ | ||
COPY tests /app/tests | ||
RUN chmod a+w /app/front/ |
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,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Open the base osrd folder, assuming the script is located in osrd/scripts | ||
cd "$(realpath "$(dirname "$0")"/..)" | ||
|
||
# Detect the playwright version installed in the front | ||
if ! command -v jq &> /dev/null; then | ||
echo "Error: jq is not installed. Please install jq using your package manager to continue." >&2 | ||
exit 1 | ||
fi | ||
cd front | ||
VERSION=$(yarn list --pattern playwright --json | jq -r '.data.trees[].name | split("@")[-1]' | sort -u) | ||
if [ "$(echo "$VERSION" | wc -l)" -ne 1 ]; then | ||
echo "Error: Zero or multiple playwright versions found: $VERSION" >&2 | ||
exit 1 | ||
fi | ||
cd .. | ||
|
||
# Loop through each argument passed to the scripts, and replace --ui with --ui=host=localhost | ||
args=() | ||
for arg in "$@"; do | ||
if [ "$arg" = "--ui" ]; then | ||
args+=("--ui-host=localhost") | ||
else | ||
args+=("$arg") | ||
fi | ||
done | ||
|
||
docker build --build-arg PLAYWRIGHT_VERSION=v"$VERSION" -t osrd-playwright:latest -f front/docker/Dockerfile.playwright . | ||
|
||
# Create the bind mounted folders if they don't exist, to avoid them being created as root | ||
mkdir -p "$PWD/front/playwright-report" | ||
mkdir -p "$PWD/front/test-results" | ||
|
||
docker run -it --rm \ | ||
--ipc=host \ | ||
--network=host \ | ||
-v "$PWD/front/playwright-report:/app/front/playwright-report" \ | ||
-v "$PWD/front/test-results:/app/front/test-results" \ | ||
-u "$(stat -c %u:%g .)" \ | ||
osrd-playwright:latest yarn playwright test "${args[@]}" |