Skip to content
Snippets Groups Projects

add afterAll(), fix some tests

Merged ilyaukin requested to merge IL/teardown into 1.3.x
Files
10
+ 63
21
#!/bin/bash
# Set up tests for specified testing framework.
# Can copy or link the tests to their destination.
# Set up either Cypress or Playwright tests.
# Can copy or link the tests to their destination as well as copy
# the tests back to their original location, which is useful
# for ATK contributors.
# Change WEB_ROOT_DIR as needed (usually "html" or "web").
# atk_setup <framework> <"back"|"link"|"">
# 1st argument:
# framework = "playwright" OR "cypress"
# 2nd argument:
# <blank> = copy tests
# "link" = symlink tests instead of copying them
# "back" = copy tests back to module
# For the initial install, from the project root
# (above web or html), use:
# module_support/atk_setup playwright
# == For Automated Testing Kit Contributors ==
# Copy the tests located in <project root>/tests to the repo
# (often located in <project root>/web/modules/contrib/automated_testing_kit),
# use:
# module_support/atk_setup playwright back
# atk_setup <tool> <do_link>
# tool = playwright OR cypress
# do_link = "link" or blank
# ATTENTION:
# Before using this tool, set the project root directory below.
WEB_ROOT_DIR="web"
MODULE_DIR="modules/contrib/automated_testing_kit"
MODULE_SUPPORT_DIR=$WEB_ROOT_DIR/$MODULE_DIR/module_support
@@ -18,13 +34,19 @@ if [ -z "$1" ]; then
exit 1
fi
DO_COPY=1
DO_BACK=0
DO_LINK=0
if [ ! -z "$2" ]; then
if [ "$2" != 'link' ]; then
echo "Second parameter allowed to be only 'link'."
DO_COPY=0
if [ "$2" == 'back' ]; then
DO_BACK=1
elif [ "$2" == 'link' ]; then
DO_LINK=1
else
echo "Second parameter must be 'back'|'link'."
exit 1
fi
DO_LINK=1
fi
# Check if in project root by testing for presence of package.json.
@@ -63,6 +85,7 @@ fi
#
# Copy xx.atk.config.js to the project root.
#
if [[ $DO_BACK == 0 ]]; then
if [ "$1" == "cypress" ]; then
echo "Copying cypress.atk.config.js to <project_root>/cypress.atk.config.js."
cp $MODULE_SUPPORT_DIR/cypress.atk.config.js .
@@ -70,18 +93,24 @@ else
echo "Copying playwright.atk.config.js to <project_root>/playwright.atk.config.js."
cp $MODULE_SUPPORT_DIR/playwright.atk.config.js .
fi
fi
#
# Copy or link framework tests.
#
echo "Copying or linking tests to <project_root>/$TEST_DESTINATION_DIR."
if (( $DO_LINK == 0 )); then
if [[ $DO_COPY == 1 ]]; then
echo "Copying tests to <project_root>/$TEST_DESTINATION_DIR."
# Ensure the destination directory exists.
mkdir ${TEST_DESTINATION_DIR}
mkdir -p ${TEST_DESTINATION_DIR}
cp -R $TEST_SOURCE_DIR/* $TEST_DESTINATION_DIR
else
elif [[ $DO_BACK == 1 ]]; then
echo "Copying tests back to $TEST_SOURCE_DIR."
cp -R $TEST_DESTINATION_DIR/atk** $TEST_SOURCE_DIR
elif [[ $DO_LINK == 1 ]]; then
echo "Linking tests to <project_root>/$TEST_DESTINATION_DIR."
# Can't link the parent source directory so need to iterate through
# just test directories to link individual tests.
TESTS=$(find "${TEST_SOURCE_DIR}" -mindepth 1 -type d)
@@ -104,19 +133,32 @@ fi
#
# Copy or link data files.
#
echo "Copying or linking data files to <project_root>/$DATA_DESTINATION_DIR."
if (( $DO_LINK == 0 )); then
if [[ $DO_COPY == 1 ]]; then
echo "Copying data files to <project_root>/$DATA_DESTINATION_DIR."
cp -R $DATA_SOURCE_DIR $DATA_DESTINATION_DIR
else
elif [[ $DO_BACK == 1 ]]; then
echo "Copying data files back to $DATA_SOURCE_DIR."
cp -R $DATA_DESTINATION_DIR/data/* $DATA_SOURCE_DIR
elif [[ $DO_LINK == 1 ]]; then
echo "Linking data files to <project_root>/$DATA_DESTINATION_DIR."
ln -s "$PWD/$DATA_SOURCE_DIR" "$PWD/$DATA_DESTINATION_DIR"
fi
#
# Copy or link testing framework support files.
#
echo "Copying or linking test framework support files to <project_root>/$SUPPORT_DESTINATION_DIR."
if (( $DO_LINK == 0 )); then
if [[ $DO_COPY == 1 ]]; then
echo "Copying test framework support files to <project_root>/$SUPPORT_DESTINATION_DIR."
cp -R $SUPPORT_SOURCE_DIR $SUPPORT_DESTINATION_DIR
else
elif [[ $DO_BACK == 1 ]]; then
echo "Copying test framework support files back to $SUPPORT_SOURCE_DIR."
cp -R $SUPPORT_DESTINATION_DIR/support/* $SUPPORT_SOURCE_DIR
elif [[ $DO_LINK == 1 ]]; then
echo "Linking test framework support files to <project_root>/$SUPPORT_DESTINATION_DIR."
ln -s "$PWD/$SUPPORT_SOURCE_DIR" "$PWD/$SUPPORT_DESTINATION_DIR"
fi
Loading