- Created CertificatePage class for testing certificate functionality - Updated DashboardPage to support certificate links in navigation - Implemented test data generator for certificate testing - Added tests for certificate generation with checked-in users - Added tests for certificate generation with non-checked-in users - Added certificate management (view/email/revoke) tests - Created comprehensive trainer journey test including certificates - Added utility script to run certificate-specific tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
123 lines
No EOL
3 KiB
Bash
Executable file
123 lines
No EOL
3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Script to run certificate-specific E2E tests
|
|
# This is helpful for testing only the certificate functionality
|
|
|
|
# Set default values
|
|
HEADLESS=true
|
|
VERBOSE=false
|
|
RETRY_FAILURES=false
|
|
REPORTER="list"
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
# Function to display usage information
|
|
function show_usage {
|
|
echo "Usage: $0 [options]"
|
|
echo "Options:"
|
|
echo " --all Run all certificate tests (default)"
|
|
echo " --checked-in Run only checked-in certificate tests"
|
|
echo " --non-checked-in Run only non-checked-in certificate tests"
|
|
echo " --management Run only certificate management tests"
|
|
echo " --journey Run only the certificate trainer journey"
|
|
echo " --no-headless Run tests with browser visible"
|
|
echo " --verbose Run tests with verbose output"
|
|
echo " --retry-failures Retry failed tests once"
|
|
echo " --html-report Generate HTML report"
|
|
echo " --help Show this help message"
|
|
echo ""
|
|
echo "Example: $0 --journey --no-headless --verbose"
|
|
}
|
|
|
|
# Parse command line arguments
|
|
TEST_PATTERN="@certificate|certificate-.*\\.test\\.ts"
|
|
ARGS=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--all)
|
|
TEST_PATTERN="@certificate|certificate-.*\\.test\\.ts"
|
|
shift
|
|
;;
|
|
--checked-in)
|
|
TEST_PATTERN="certificate-generation-checked-in\\.test\\.ts"
|
|
shift
|
|
;;
|
|
--non-checked-in)
|
|
TEST_PATTERN="certificate-generation-non-checked-in\\.test\\.ts"
|
|
shift
|
|
;;
|
|
--management)
|
|
TEST_PATTERN="certificate-management\\.test\\.ts"
|
|
shift
|
|
;;
|
|
--journey)
|
|
TEST_PATTERN="trainer-journey-with-certificates\\.test\\.ts"
|
|
shift
|
|
;;
|
|
--no-headless)
|
|
HEADLESS=false
|
|
shift
|
|
;;
|
|
--verbose)
|
|
VERBOSE=true
|
|
shift
|
|
;;
|
|
--retry-failures)
|
|
RETRY_FAILURES=true
|
|
shift
|
|
;;
|
|
--html-report)
|
|
REPORTER="html"
|
|
shift
|
|
;;
|
|
--help)
|
|
show_usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Build the command line arguments
|
|
if [ "$HEADLESS" = true ]; then
|
|
ARGS="$ARGS --headed false"
|
|
else
|
|
ARGS="$ARGS --headed"
|
|
fi
|
|
|
|
if [ "$VERBOSE" = true ]; then
|
|
ARGS="$ARGS --debug"
|
|
fi
|
|
|
|
if [ "$RETRY_FAILURES" = true ]; then
|
|
ARGS="$ARGS --retries=1"
|
|
fi
|
|
|
|
# Add reporter argument
|
|
ARGS="$ARGS --reporter=$REPORTER"
|
|
|
|
# Change to the project root directory
|
|
cd "$PROJECT_ROOT" || { echo "Failed to change to project root directory"; exit 1; }
|
|
|
|
# Run the tests
|
|
echo "Running certificate tests with pattern: $TEST_PATTERN"
|
|
echo "Arguments: $ARGS"
|
|
|
|
# Execute the tests
|
|
npx playwright test --config=playwright.config.ts --grep="$TEST_PATTERN" $ARGS
|
|
|
|
# Check exit status
|
|
EXIT_CODE=$?
|
|
|
|
# Display test results
|
|
if [ $EXIT_CODE -eq 0 ]; then
|
|
echo "Certificate tests completed successfully!"
|
|
else
|
|
echo "Certificate tests failed with exit code: $EXIT_CODE"
|
|
fi
|
|
|
|
exit $EXIT_CODE |