grafana/e2e/run-suite
Ashley Harrison 0f2f25c5d9
Chore: Move to Cypress 12 and decouple cypress from @grafana/e2e (#74084)
* update drone to use cypress 12 image

* upgrade cypress to 12 in core

* cypress config actually valid

* update @grafana/e2e imports and add lint rule

* ignore grafana-e2e from betterer now it's deprecated

* fix remaining type errors

* fix failing tests

* remove unnecessary tsconfig

* remove unnecessary comment

* update enterprise suite commands to work

* add cypress config to CODEOWNERS

* export setTimeRange in utils

* remove @grafana/e2e from core deps

* try running the command through yarn

* move CMD to scripts

* Update cloud-data-sources e2e image

* Update paths

---------

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
2023-09-08 16:51:59 +01:00

122 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -xeo pipefail
. scripts/grafana-server/variables
if ((BASH_VERSINFO[0] < 4)); then
echo "Bash ver >= 4 is needed to run this script"
echo "Please upgrade your bash - run 'brew install bash' if you use Homebrew on MacOS"
exit 1;
fi
HOST=${HOST:-$DEFAULT_HOST}
PORT=${PORT:-$DEFAULT_PORT}
echo -e "Starting Cypress scenarios"
args=("$@")
CMD="cy:run"
PARAMS=""
CLEANUP=""
declare -A env=(
[BASE_URL]=${BASE_URL:-"http://$HOST:$PORT"}
[SLOWMO]=0
)
testFilesForSingleSuite="*.spec.ts"
rootForEnterpriseSuite="./e2e/extensions-suite"
declare -A cypressConfig=(
[screenshotsFolder]=./e2e/"${args[0]}"/screenshots
[fixturesFolder]=./e2e/cypress/fixtures
[videosFolder]=./e2e/"${args[0]}"/videos
[downloadsFolder]=./e2e/cypress/downloads
[fileServerFolder]=./e2e/cypress
[specPattern]=./e2e/*-suite/*spec.ts
[defaultCommandTimeout]=30000
[viewportWidth]=1920
[viewportHeight]=1080
[trashAssetsBeforeRuns]=false
[videoUploadOnPasses]=false
[reporter]=./e2e/log-reporter.js
[baseUrl]=${BASE_URL:-"http://$HOST:$PORT"}
)
case "$1" in
"debug")
echo -e "Debug mode"
env[SLOWMO]=1
PARAMS="--no-exit"
;;
"dev")
echo "Dev mode"
CMD="cy:open"
;;
"benchmark")
echo "Benchmark"
PARAMS="--headed"
CMD="cy:benchmark"
env[BENCHMARK_PLUGIN_ENABLED]=true
env[BENCHMARK_PLUGIN_RESULTS_FOLDER]=./e2e/benchmarks/"${args[1]}"/results
cypressConfig[video]=false
cypressConfig[screenshotsFolder]=./e2e/benchmarks/"${args[1]}"/screenshots
cypressConfig[specPattern]=./e2e/benchmarks/"${args[1]}"/$testFilesForSingleSuite
;;
"enterprise")
echo "Enterprise"
CLEANUP="rm -rf ./e2e/extensions-suite"
SETUP="cp -Lr ./e2e/extensions ./e2e/extensions-suite"
enterpriseSuite=$(basename "${args[1]}")
case "$2" in
"debug")
echo -e "Debug mode"
env[SLOWMO]=1
PARAMS="--no-exit"
enterpriseSuite=$(basename "${args[2]}")
;;
"dev")
echo "Dev mode"
CMD="cy:open"
enterpriseSuite=$(basename "${args[2]}")
;;
esac
cypressConfig[specPattern]=$rootForEnterpriseSuite/$enterpriseSuite/*-suite/*.spec.ts
$CLEANUP && $SETUP
;;
"")
;;
*)
cypressConfig[specPattern]=./e2e/"${args[0]}"/$testFilesForSingleSuite
cypressConfig[video]=${args[1]}
;;
esac
function join () {
local -n map=$1
local delimiter=","
local res=""
for key in "${!map[@]}"
do
value=${map[$key]}
if [ -z "${res}" ]; then
res=$key=$value
else
res=$res$delimiter$key=$value
fi
done
echo "$res"
}
export TZ="Pacific/Honolulu"
yarn $CMD --env "$(join env)" \
--config "$(join cypressConfig)" \
$PARAMS
$CLEANUP