2022-01-12 12:15:29 -06:00
|
|
|
#!/usr/bin/env bash
|
2020-07-10 09:09:21 -05:00
|
|
|
set -xeo pipefail
|
2020-03-13 08:34:25 -05:00
|
|
|
|
2022-01-20 11:01:00 -06:00
|
|
|
. scripts/grafana-server/variables
|
2020-03-13 08:34:25 -05:00
|
|
|
|
2022-01-12 12:15:29 -06:00
|
|
|
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
|
|
|
|
|
2020-07-10 09:09:21 -05:00
|
|
|
HOST=${HOST:-$DEFAULT_HOST}
|
|
|
|
PORT=${PORT:-$DEFAULT_PORT}
|
|
|
|
|
2020-03-13 08:34:25 -05:00
|
|
|
echo -e "Starting Cypress scenarios"
|
|
|
|
|
2021-11-24 04:20:11 -06:00
|
|
|
args=("$@")
|
|
|
|
|
2023-09-14 09:00:29 -05:00
|
|
|
CMD="cypress run --browser=chrome"
|
2020-03-16 08:35:55 -05:00
|
|
|
PARAMS=""
|
2023-01-26 15:04:13 -06:00
|
|
|
CLEANUP=""
|
2022-01-12 12:15:29 -06:00
|
|
|
|
|
|
|
declare -A env=(
|
|
|
|
[BASE_URL]=${BASE_URL:-"http://$HOST:$PORT"}
|
|
|
|
[SLOWMO]=0
|
|
|
|
)
|
|
|
|
|
|
|
|
testFilesForSingleSuite="*.spec.ts"
|
2023-09-08 10:51:59 -05:00
|
|
|
rootForEnterpriseSuite="./e2e/extensions-suite"
|
2022-01-12 12:15:29 -06:00
|
|
|
|
|
|
|
declare -A cypressConfig=(
|
2023-09-08 10:51:59 -05:00
|
|
|
[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
|
2022-01-12 12:15:29 -06:00
|
|
|
[defaultCommandTimeout]=30000
|
|
|
|
[viewportWidth]=1920
|
|
|
|
[viewportHeight]=1080
|
|
|
|
[trashAssetsBeforeRuns]=false
|
2023-09-08 10:51:59 -05:00
|
|
|
[reporter]=./e2e/log-reporter.js
|
|
|
|
[baseUrl]=${BASE_URL:-"http://$HOST:$PORT"}
|
2022-01-12 12:15:29 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
case "$1" in
|
2021-11-24 08:16:51 -06:00
|
|
|
"debug")
|
|
|
|
echo -e "Debug mode"
|
2022-01-12 12:15:29 -06:00
|
|
|
env[SLOWMO]=1
|
2021-11-24 08:16:51 -06:00
|
|
|
PARAMS="--no-exit"
|
|
|
|
;;
|
|
|
|
"dev")
|
|
|
|
echo "Dev mode"
|
2023-09-14 09:00:29 -05:00
|
|
|
CMD="cypress open"
|
2021-11-24 08:16:51 -06:00
|
|
|
;;
|
2022-01-12 12:15:29 -06:00
|
|
|
"benchmark")
|
|
|
|
echo "Benchmark"
|
2023-09-14 09:00:29 -05:00
|
|
|
PARAMS="--headed --no-runner-ui"
|
2022-01-12 12:15:29 -06:00
|
|
|
env[BENCHMARK_PLUGIN_ENABLED]=true
|
2023-09-08 10:51:59 -05:00
|
|
|
env[BENCHMARK_PLUGIN_RESULTS_FOLDER]=./e2e/benchmarks/"${args[1]}"/results
|
2022-01-12 12:15:29 -06:00
|
|
|
cypressConfig[video]=false
|
2023-09-08 10:51:59 -05:00
|
|
|
cypressConfig[screenshotsFolder]=./e2e/benchmarks/"${args[1]}"/screenshots
|
|
|
|
cypressConfig[specPattern]=./e2e/benchmarks/"${args[1]}"/$testFilesForSingleSuite
|
2022-01-12 12:15:29 -06:00
|
|
|
;;
|
2023-01-26 15:04:13 -06:00
|
|
|
"enterprise")
|
|
|
|
echo "Enterprise"
|
2023-09-08 10:51:59 -05:00
|
|
|
CLEANUP="rm -rf ./e2e/extensions-suite"
|
|
|
|
SETUP="cp -Lr ./e2e/extensions ./e2e/extensions-suite"
|
2023-01-26 15:04:13 -06:00
|
|
|
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"
|
2023-09-14 09:00:29 -05:00
|
|
|
CMD="cypress open"
|
2023-01-26 15:04:13 -06:00
|
|
|
enterpriseSuite=$(basename "${args[2]}")
|
|
|
|
;;
|
|
|
|
esac
|
2023-09-08 10:51:59 -05:00
|
|
|
cypressConfig[specPattern]=$rootForEnterpriseSuite/$enterpriseSuite/*-suite/*.spec.ts
|
2023-01-26 15:04:13 -06:00
|
|
|
$CLEANUP && $SETUP
|
|
|
|
;;
|
2021-11-24 08:16:51 -06:00
|
|
|
"")
|
|
|
|
;;
|
|
|
|
*)
|
2023-09-08 10:51:59 -05:00
|
|
|
cypressConfig[specPattern]=./e2e/"${args[0]}"/$testFilesForSingleSuite
|
2022-11-08 04:27:54 -06:00
|
|
|
cypressConfig[video]=${args[1]}
|
2021-11-24 08:16:51 -06:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-01-12 12:15:29 -06:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2023-08-23 07:57:32 -05:00
|
|
|
export TZ="Pacific/Honolulu"
|
2022-01-12 12:15:29 -06:00
|
|
|
|
2023-09-14 09:00:29 -05:00
|
|
|
yarn run $CMD --env "$(join env)" \
|
2022-01-12 12:15:29 -06:00
|
|
|
--config "$(join cypressConfig)" \
|
2020-03-16 08:35:55 -05:00
|
|
|
$PARAMS
|
2023-01-26 15:04:13 -06:00
|
|
|
|
|
|
|
$CLEANUP
|