Replace Cypress with Playwright

Playwright is more flexible and has better developer experience than Cypress.
We add end to end tests covering:

  - project source browsing
    - tree view
    - commit list view
    - commit view
  - routing
    - hash based
    - history API based
  - clipboard copy paste functionality
  - seed view
  - project search
  - landing page view
  - settings

Co-authored-by: Sebastian Martinez <me@sebastinez.dev>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-12-01 15:54:56 +01:00
co-authored by Sebastian Martinez
parent d740d7e5a1
commit 9cb9332e88
83 changed files with 2173 additions and 4148 deletions
+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
set -euo pipefail
function cleanup {
docker kill radicle-git-server-test
}
trap cleanup EXIT
PASSPHRASE=asdf
REV=40bdc662b2d48cbfaa87182b21457ef8f861b04a
REPO_ROOT=$(git rev-parse --show-toplevel)
ID=$(echo $RANDOM | md5sum | head -c 8)
BASE_PATH=$REPO_ROOT/tests/tmp/create-seed-fixture-$ID
TEST_REPO_ARCHIVE=$REPO_ROOT/tests/fixtures/repos/source-browsing.tar.bz2
TEST_REPO_NAME=source-browsing
TEST_REPO_PATH=$BASE_PATH/repos/$TEST_REPO_NAME
PALM_RAD_HOME=$BASE_PATH/seeds/palm
ALICE_RAD_HOME=$BASE_PATH/peers/alice
ALICE_CHECKOUT=$BASE_PATH/checkout/alice
BOB_RAD_HOME=$BASE_PATH/peers/bob
BOB_CHECKOUT=$BASE_PATH/checkout/bob
mkdir -p $PALM_RAD_HOME
mkdir -p $ALICE_RAD_HOME
mkdir -p $ALICE_CHECKOUT
mkdir -p $BOB_RAD_HOME
mkdir -p $BOB_CHECKOUT
mkdir -p $TEST_REPO_PATH
tar -xf $TEST_REPO_ARCHIVE -C $TEST_REPO_PATH
RAD_HOME=$PALM_RAD_HOME rad auth --init --name palm --passphrase $PASSPHRASE
docker run \
--detach \
--init \
--publish 8778:8778 \
--rm \
--env RAD_HOME=/app/radicle \
--name radicle-git-server-test \
--volume $PALM_RAD_HOME:/app/radicle \
"gcr.io/radicle-services/git-server:$REV" \
--passphrase $PASSPHRASE \
--allow-unauthorized-keys
# git-server takes a while to copy commit hooks to the monorepo
sleep 10
GIT_AUTHOR_NAME="Alice Liddell"
GIT_AUTHOR_EMAIL="alice@radicle.xyz"
GIT_COMMITTER_NAME="Alice Liddell"
GIT_COMMITTER_EMAIL="alice@radicle.xyz"
RAD_HOME=$ALICE_RAD_HOME rad auth --init --name alice --passphrase $PASSPHRASE
cd $ALICE_CHECKOUT
git clone $TEST_REPO_PATH
cd $TEST_REPO_NAME
git checkout feature/branch
git checkout orphaned-branch
git checkout main
RAD_HOME=$ALICE_RAD_HOME rad init --name "source-browsing" --description "Git repository for source browsing tests" --default-branch "main" --no-confirm
RAD_HOME=$ALICE_RAD_HOME rad push --seed 0.0.0.0:8778 --all --sync
PROJECT_URN=$(rad .)
GIT_AUTHOR_NAME="Bob Belcher"
GIT_AUTHOR_EMAIL="bob@radicle.xyz"
GIT_COMMITTER_NAME="Bob Belcher"
GIT_COMMITTER_EMAIL="bob@radicle.xyz"
RAD_HOME=$BOB_RAD_HOME rad auth --init --name bob --passphrase $PASSPHRASE
cd $BOB_CHECKOUT
RAD_HOME=$BOB_RAD_HOME rad clone $PROJECT_URN --seed 0.0.0.0:8778 --no-confirm
cd $TEST_REPO_NAME
echo "Updated readme" > README.md
git add README.md
git commit --message "Update readme" --date "Mon Nov 21 14:00 2022 +0100"
RAD_HOME=$BOB_RAD_HOME rad push --seed 0.0.0.0:8778
RAD_HOME=$BOB_RAD_HOME rad sync --seed 0.0.0.0:8778 --self
RAD_HOME=$BOB_RAD_HOME rad sync --seed 0.0.0.0:8778
cd $BASE_PATH
tar -cjf palm.tar.bz2 --exclude "post-receive" --exclude "pre-receive" -C $PALM_RAD_HOME .
+132
View File
@@ -0,0 +1,132 @@
#!/bin/sh
set -e
REV=40bdc662b2d48cbfaa87182b21457ef8f861b04a
REPO_ROOT=$(git rev-parse --show-toplevel)
FIXTURE=$REPO_ROOT/tests/fixtures/seeds/palm.tar.bz2
WORKSPACE=$REPO_ROOT/tests/tmp/palm
PASSPHRASE=asdf
CONTAINER_NAME=radicle-http-api-with-fixtures
HTTP_API_BINARY=radicle-http-api
show_usage()
{
echo
echo "Starts a http-api backend with test fixtures."
echo
echo "USAGE:"
echo " run-http-api-with-fixtures [-b|d|h|n]"
echo
echo "OPTIONS:"
echo " -b --binary Use a ${HTTP_API_BINARY} binary that is in PATH to avoid using Docker."
echo " -d --detach Daemonize the docker process."
echo " -h --help Print this Help."
echo " -n --non-interactive Run in non-interactive mode, no user prompts."
echo
}
prompt_workspace_removal()
{
echo "This will irrevocably destroy the following directories:"
echo
echo $WORKSPACE
echo
read -r -p "Are you sure you want to continue? [yes/no]: " confirm
case "$confirm" in
[yY][eE][sS] )
rm -rf $WORKSPACE
echo "Done"
;;
* )
echo "Ok, I won't touch your data."
exit
;;
esac
}
prepare_workspace()
{
echo
echo "Unpacking fixture $FIXTURE"
mkdir -p $WORKSPACE
tar -xf $FIXTURE -C $WORKSPACE
}
run_docker() {
echo "Starting docker at container $CONTAINER_NAME at $REV"
echo " http-api --root $WORKSPACE --passphrase $PASSPHRASE"
echo
exec docker run \
--init \
--publish 8777:8777 \
--rm \
--name $CONTAINER_NAME \
--volume $WORKSPACE:/app/radicle \
"$@" \
"gcr.io/radicle-services/http-api:$REV" \
--passphrase $PASSPHRASE
}
run_binary() {
if ! [ -x "$(command -v $HTTP_API_BINARY)" ]; then
echo
echo "Couldn't find the $HTTP_API_BINARY binary in your PATH."
echo "You can compile it from source:"
echo " 👉 https://github.com/radicle-dev/radicle-client-services/tree/${REV}/http-api"
echo
exit 1
fi
echo
echo "Starting $HTTP_API_BINARY"
echo " $HTTP_API_BINARY --listen 0.0.0.0:8777 --root ${WORKSPACE} --passphrase $PASSPHRASE"
echo
$HTTP_API_BINARY --listen 0.0.0.0:8777 --root $WORKSPACE --passphrase $PASSPHRASE
}
BINADY=false
NON_INTERACTIVE=false
DETACH=false
while [ $# -ne 0 ]; do
case "$1" in
--binary|-b)
BINARY=true
;;
--detach|-d)
DETACH=true
;;
--non-interactive|-n)
NON_INTERACTIVE=true
;;
*)
show_usage
exit
;;
esac
shift
done
if [ "$NON_INTERACTIVE" = true ]; then
rm -rf $WORKSPACE
prepare_workspace
else
prompt_workspace_removal
prepare_workspace
fi
if [ "$BINARY" = true ]; then
run_binary
else
if [ "$DETACH" = true ]; then
run_docker --detach
else
run_docker
fi
fi
-5
View File
@@ -1,5 +0,0 @@
#!/bin/sh
set -e
npm run test:unit
npm run test:components