Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b6abfbf
Migrate basic.spec.ts
mgascam Sep 29, 2025
4c04db1
Migrate shopper-checkout-purchase with ctp disabled
mgascam Sep 29, 2025
78b3787
Migrate shopper-checkout-purchase with card testing protection enabled
mgascam Sep 29, 2025
46baa33
Migrate shopper-wc-blocks-checkout-purchase.spec.ts
mgascam Sep 29, 2025
3dc5e92
Migrate shopper-checkout-failures.spec.ts
mgascam Sep 29, 2025
9c7dcd9
Migrate shopper-wc-blocks-checkout-failures
mgascam Sep 29, 2025
0554ada
Migrate shopper-checkout-save-card-and-purchase spec
mgascam Sep 29, 2025
7c610e1
Add auth fixture and use it in basic spec
mgascam Sep 30, 2025
7939c85
Use auth fixture in shopper checkout spec
mgascam Sep 30, 2025
959866a
Use auth fixture in blocks purchase
mgascam Sep 30, 2025
071dd82
Use auth fixture in the shopper-checkout-failures.spec
mgascam Sep 30, 2025
4cc7717
Use auth fixture in shopper-wc-blocks-checkout-failures
mgascam Sep 30, 2025
0782a34
Use auth fixture in shopper-checkout-save-card-and-purchase spec
mgascam Sep 30, 2025
a9e85fa
Migrate shopper-wc-blocks-saved-card-checkout-and-usage spec
mgascam Sep 30, 2025
88e2bd8
Migrate shopper-pay-for-order. spec
mgascam Sep 30, 2025
4686bf3
Migrate shopper-checkout-purchase-site-editor spec
mgascam Sep 30, 2025
9b2709c
Migrate shopper-checkout-cart-coupon spec
mgascam Sep 30, 2025
d6bc8fd
Migrate shopper-myaccount-payment-methods-add-fail spec
mgascam Sep 30, 2025
8ebb645
Migrate shopper-checkout-purchase-with-upe-methods spec
mgascam Sep 30, 2025
299e7f0
MIgrate klarna-checkout-purchase spec
mgascam Sep 30, 2025
de4ac98
Migrate alipay-checkout-purchase spec
mgascam Sep 30, 2025
d98f588
Migrate shopper-bnpls-checkout spec
mgascam Sep 30, 2025
4269615
Migrate multi-currency-checkout spec
mgascam Sep 30, 2025
d1c7fda
Migrate shopper-multi-currency-widget spec
mgascam Sep 30, 2025
39c3487
Increase timeout for beforeAll in shopper multi-currency widget spec
mgascam Sep 30, 2025
2c3a159
WIP: Migrate shopper-myaccount-saved-cards.spec.ts
mgascam Sep 30, 2025
2874e31
MIgrate shopper-myaccount-saved-cards spec
mgascam Sep 30, 2025
ef2d9ea
Support running single spec
mgascam Oct 1, 2025
300f674
Merge branch 'dev/qit-e2e-workflows' into dev/qit-e2e-shopper-specs-m…
mgascam Oct 1, 2025
b9054fc
Merge branch 'dev/qit-e2e-workflows' into dev/qit-e2e-shopper-specs-m…
mgascam Oct 6, 2025
3c034ec
Refactor E2E runner script to improve path handling and default spec …
mgascam Oct 6, 2025
5800720
Add shopper tags to E2E tests for improved categorization
mgascam Oct 6, 2025
ff8fe09
Refactor E2E tests to remove conditional describe and use consistent …
mgascam Oct 7, 2025
b54f1c8
Merge branch 'dev/qit-e2e-workflows' into dev/qit-e2e-shopper-specs-m…
mgascam Oct 7, 2025
783be6b
Update QIT bootstrap volume path in configuration
mgascam Oct 7, 2025
8c7db83
Merge branch 'dev/qit-e2e-workflows' into dev/qit-e2e-shopper-specs-m…
mgascam Oct 8, 2025
e16aa7e
Merge branch 'dev/qit-e2e-workflows' into dev/qit-e2e-shopper-specs-m…
mgascam Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 136 additions & 17 deletions tests/qit/e2e-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ if [[ -f "$QIT_ROOT/config/local.env" ]]; then
. "$QIT_ROOT/config/local.env"
fi

# If QIT_BINARY is not set, default to ./vendor/bin/qit
QIT_BINARY=${QIT_BINARY:-./vendor/bin/qit}

echo "Running E2E tests..."

# Change to project root directory to build plugin
Expand Down Expand Up @@ -81,15 +78,8 @@ else
echo "$CURRENT_SIG" > "$BUILD_HASH_FILE"
fi

# Change to QIT directory so qit.yml is automatically found
cd "$QIT_ROOT"

# Convert relative QIT_BINARY path to absolute for directory change compatibility
if [[ "$QIT_BINARY" = ./* ]]; then
QIT_CMD="$WCP_ROOT/$QIT_BINARY"
else
QIT_CMD="$QIT_BINARY"
fi
# QIT CLI is installed via composer as a dev dependency
QIT_CMD="./vendor/bin/qit"

# Build environment arguments for local development
env_args=()
Expand All @@ -105,11 +95,140 @@ if [[ -n "${E2E_JP_USER_TOKEN:-}" ]]; then
env_args+=( --env "E2E_JP_USER_TOKEN=${E2E_JP_USER_TOKEN}" )
fi

# Run QIT E2E tests (qit.yml automatically loaded from current directory)
echo "Running QIT E2E tests for local development..."
# Determine the desired spec target. Defaults to the whole suite unless
# overridden via the first positional argument (if it is not an option) or
# the WCP_E2E_SPEC environment variable.
SPEC_TARGET=${WCP_E2E_SPEC:-tests/qit/e2e}
TEST_TAG=""
declare -a FORWARDED_ARGS=()

# Parse arguments to extract spec target and optional --tag
while [[ $# -gt 0 ]]; do
case "$1" in
--tag=*)
TEST_TAG="${1#*=}"
shift
;;
--tag)
TEST_TAG="$2"
shift 2
;;
--*)
FORWARDED_ARGS+=("$1")
shift
;;
*)
# First non-option argument is the spec target
if [[ -z "${SPEC_TARGET_SET:-}" ]]; then
SPEC_TARGET="$1"
SPEC_TARGET_SET=1
fi
shift
;;
esac
done

# Normalize paths to work from project root
# Handle various input formats and convert them to paths QIT can use
normalize_path() {
local input="$1"

# If path exists as-is from project root, use it
if [[ -e "$input" ]]; then
echo "$input"
return 0
fi

# Try prefixing with tests/qit/
if [[ -e "tests/qit/$input" ]]; then
echo "tests/qit/$input"
return 0
fi

# Try prefixing with tests/qit/e2e/
if [[ -e "tests/qit/e2e/$input" ]]; then
echo "tests/qit/e2e/$input"
return 0
fi

# If it looks like it starts with e2e/, try tests/qit/e2e/
if [[ "$input" == e2e/* ]] && [[ -e "tests/qit/$input" ]]; then
echo "tests/qit/$input"
return 0
fi

# If just a filename (no path separators), search for it in e2e directory
if [[ "$input" != */* ]]; then
local found
found=$(find tests/qit/e2e -name "$input" -type f | head -1)
if [[ -n "$found" ]]; then
echo "$found"
return 0
fi
fi

# Path not found
echo "$input"
return 1
}

SPEC_TARGET=$(normalize_path "$SPEC_TARGET") || {
echo "Unable to locate spec target: $SPEC_TARGET" >&2
exit 1
}

# Determine if we're running a specific file or directory
PW_OPTIONS=""
if [[ -f "$SPEC_TARGET" ]]; then
# Running a specific spec file - pass it to Playwright via --pw_options
# QIT needs the e2e directory, Playwright needs the specific file
E2E_ROOT="tests/qit/e2e"

# Ensure spec is within e2e directory
case "$SPEC_TARGET" in
"$E2E_ROOT"/*)
# Extract the path relative to e2e directory
PW_OPTIONS="${SPEC_TARGET#$E2E_ROOT/}"
SPEC_TARGET="$E2E_ROOT"
;;
*)
echo "Specified spec file must reside within tests/qit/e2e" >&2
exit 1
;;
esac
fi

# Build the final command to execute QIT.
echo "Running QIT E2E tests for local development (target: ${SPEC_TARGET}${TEST_TAG:+ | tag: ${TEST_TAG}}${PW_OPTIONS:+ | pw_options: ${PW_OPTIONS}})..."

"$QIT_CMD" run:e2e woocommerce-payments ./e2e \
--source "$WCP_ROOT/woocommerce-payments.zip" \
QIT_CMD_ARGS=(
"$QIT_CMD" run:e2e woocommerce-payments "$SPEC_TARGET"
--config "$QIT_ROOT/qit.yml"
--source "$WCP_ROOT/woocommerce-payments.zip"
"${env_args[@]}"
)

# Add tag filter if specified
if [[ -n "$TEST_TAG" ]]; then
QIT_CMD_ARGS+=( --pw_test_tag="${TEST_TAG}" )
fi

if [[ -n "$PW_OPTIONS" ]]; then
if (( ${#FORWARDED_ARGS[@]} )); then
for arg in "${FORWARDED_ARGS[@]}"; do
if [[ "$arg" == --pw_options || "$arg" == --pw_options=* ]]; then
echo "Do not combine a spec file with manual --pw_options overrides." >&2
exit 1
fi
done
fi
QIT_CMD_ARGS+=( --pw_options "$PW_OPTIONS" )
fi

if (( ${#FORWARDED_ARGS[@]} )); then
QIT_CMD_ARGS+=( "${FORWARDED_ARGS[@]}" )
fi

"${QIT_CMD_ARGS[@]}"

echo "QIT E2E foundation tests completed!"
echo "QIT E2E tests completed!"
68 changes: 0 additions & 68 deletions tests/qit/e2e/basic.spec.js

This file was deleted.

108 changes: 92 additions & 16 deletions tests/qit/e2e/bootstrap/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,90 @@ echo "Setting up WooPayments for E2E testing..."
# Ensure environment is marked as development so dev-only CLI commands are available
wp config set WP_ENVIRONMENT_TYPE development --quiet 2>/dev/null || true

# Create a test product for payment testing
PRODUCT_ID=$(wp post create \
--post_title="Test Product for Payments" \
--post_content="A simple test product for QIT payment testing" \
--post_status=publish \
--post_type=product \
--porcelain)

# Set product meta data properly
wp post meta update $PRODUCT_ID _price "10.00"
wp post meta update $PRODUCT_ID _regular_price "10.00"
wp post meta update $PRODUCT_ID _virtual "yes"
wp post meta update $PRODUCT_ID _manage_stock "no"

# Ensure WooCommerce checkout page exists and is properly configured
wp option update woocommerce_checkout_page_id $(wp post list --post_type=page --post_name=checkout --field=ID --format=ids)
echo "Installing WordPress importer for sample data..."
if ! wp plugin is-installed wordpress-importer >/dev/null 2>&1; then
wp plugin install wordpress-importer --activate
else
wp plugin activate wordpress-importer
fi

WC_SAMPLE_DATA_PATH=$(wp eval 'echo trailingslashit( WP_CONTENT_DIR ) . "plugins/woocommerce/sample-data/sample_products.xml";' 2>/dev/null)
if [ -z "$WC_SAMPLE_DATA_PATH" ]; then
echo "Unable to resolve WooCommerce sample data path; skipping import."
else
if [ -f "$WC_SAMPLE_DATA_PATH" ]; then
echo "Importing WooCommerce sample products from $WC_SAMPLE_DATA_PATH ..."
wp import "$WC_SAMPLE_DATA_PATH" --authors=skip
else
echo "Sample data file not found at $WC_SAMPLE_DATA_PATH; skipping import."
fi
fi

# Ensure WooCommerce core pages exist and capture IDs
echo "Ensuring WooCommerce core pages exist..."
wp wc --user=admin tool run install_pages >/dev/null 2>&1 || true

CHECKOUT_PAGE_ID=$(wp option get woocommerce_checkout_page_id)
CART_PAGE_ID=$(wp option get woocommerce_cart_page_id)

if [ -z "$CHECKOUT_PAGE_ID" ] || [ "$CHECKOUT_PAGE_ID" = "0" ]; then
CHECKOUT_PAGE_ID=$(wp post list --post_type=page --name=checkout --field=ID --format=ids)
fi

if [ -z "$CART_PAGE_ID" ] || [ "$CART_PAGE_ID" = "0" ]; then
CART_PAGE_ID=$(wp post list --post_type=page --name=cart --field=ID --format=ids)
fi

# Default to shortcode-based templates for classic checkout/cart flows
if [ -n "${CHECKOUT_PAGE_ID}" ] && [ -n "${CART_PAGE_ID}" ]; then
echo "Configuring classic checkout and cart pages..."

CHECKOUT_SHORTCODE="<!-- wp:shortcode -->[woocommerce_checkout]<!-- /wp:shortcode -->"
CART_SHORTCODE="<!-- wp:shortcode -->[woocommerce_cart]<!-- /wp:shortcode -->"

# Provision a dedicated WooCommerce Blocks checkout clone if it does not exist yet
CHECKOUT_WCB_PAGE_ID=$(wp post list --post_type=page --name=checkout-wcb --field=ID --format=ids)
if [ -z "$CHECKOUT_WCB_PAGE_ID" ]; then
echo "Creating WooCommerce Blocks checkout page..."
CHECKOUT_WCB_PAGE_ID=$(wp post create \
--from-post="$CHECKOUT_PAGE_ID" \
--post_type=page \
--post_title="Checkout WCB" \
--post_status=publish \
--post_name="checkout-wcb" \
--porcelain)
else
echo "WooCommerce Blocks checkout page already exists (ID: $CHECKOUT_WCB_PAGE_ID)"
fi

wp post update "$CART_PAGE_ID" --post_content="$CART_SHORTCODE"
wp post update "$CHECKOUT_PAGE_ID" --post_content="$CHECKOUT_SHORTCODE"
wp post meta update "$CHECKOUT_PAGE_ID" _wp_page_template "template-fullwidth.php" >/dev/null 2>&1 || true
if [ -n "$CHECKOUT_WCB_PAGE_ID" ]; then
wp post meta update "$CHECKOUT_WCB_PAGE_ID" _wp_page_template "template-fullwidth.php" >/dev/null 2>&1 || true
fi
fi

# Double check option points to the classic checkout page
if [ -n "$CHECKOUT_PAGE_ID" ]; then
wp option update woocommerce_checkout_page_id "$CHECKOUT_PAGE_ID"
fi

# Configure WooCommerce for testing
wp option update woocommerce_currency "USD"
wp option update woocommerce_enable_guest_checkout "yes"
wp option update woocommerce_force_ssl_checkout "no"
wp option set woocommerce_checkout_company_field "optional" --quiet 2>/dev/null || true
wp option set woocommerce_coming_soon "no" --quiet 2>/dev/null || true
wp option set woocommerce_store_pages_only "no" --quiet 2>/dev/null || true

# Ensure Storefront theme is active for consistent storefront markup
if ! wp theme is-installed storefront > /dev/null 2>&1; then
wp theme install storefront --force
fi
wp theme activate storefront



# Create a test customer
wp user create testcustomer [email protected] \
Expand Down Expand Up @@ -84,4 +147,17 @@ wp option set wcpaydev_proxy 0 --quiet 2>/dev/null || true
# Disable onboarding redirect for E2E testing
wp option set wcpay_should_redirect_to_onboarding 0 --quiet 2>/dev/null || true

echo "Dismissing fraud protection welcome tour in E2E tests"
wp option set wcpay_fraud_protection_welcome_tour_dismissed 1 --quiet 2>/dev/null || true

echo "Resetting coupons and creating standard free coupon"
wp post delete $(wp post list --post_type=shop_coupon --format=ids) --force --quiet 2>/dev/null || true
wp db query "DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT ID FROM wp_posts)" --skip-column-names 2>/dev/null || true
wp wc --user=admin shop_coupon create \
--code=free \
--amount=100 \
--discount_type=percent \
--individual_use=true \
--free_shipping=true

echo "WooPayments configuration completed"
Loading
Loading