Skip to content

Commit

Permalink
fixup! front, scripts: add playwright container for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Synar committed Nov 7, 2024
1 parent 347afb1 commit 76bb43e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

# OSRD dev scripts
osrd-dev-scripts
jq

]
# Section added only on Linux systems
Expand Down
5 changes: 3 additions & 2 deletions front/docker/Dockerfile.playwright
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM mcr.microsoft.com/playwright:v1.43.1
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
RUN yarn playwright install --with-deps

COPY front /app/front/
COPY tests /app/tests
RUN chmod a+w /app/front/
17 changes: 15 additions & 2 deletions scripts/run-front-playwright-container.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#!/bin/sh
#!/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
Expand All @@ -15,7 +28,7 @@ for arg in "$@"; do
fi
done

docker build -t osrd-playwright:latest -f front/docker/Dockerfile.playwright .
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"
Expand Down

0 comments on commit 76bb43e

Please sign in to comment.