Skip to content

Commit e757221

Browse files
superdav42claudecoderabbitai[bot]
authored
Add Settings API and more (#331)
* Move tracking opt-in to general settings and onboarding wizard * better error logging and handling of user accounts unable to connect to addon store * add recommended html attr * allow kses to be extended * add settings api * Fix problems with choosing country and state * Fix login redirect * Add support for pay what you want prices * Add support for pay what you want prices * Add support for pay what you want prices * set duration for manually created memberships * add duration restrictions for discount codes * make yoursite translatable * let users change their email * let networks login * fix error in multinetwork * fix extra chars * Apply suggestion from @superdav42 * Fix product tabs * Skip billing requirements for free trials, fix null product handling, add hooks documentation generator - Move cart assignment before validation so should_collect_payment() is available - Remove billing field requirements when payment is not needed (free trials) - Hide billing address fields via v-show when payment not collected - Handle 'autogenerate' site_url value in checkout - Add array_filter to prevent null products in template limits (3 locations) - Add sunrise.php mapping and SUNRISE config to wp-env - Add BerlinDB dynamic hooks documentation generator to build pipeline - Update encrypted secrets and translation file Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Skip billing validation when payment not required, code style fixes - Add should_collect_payment() method to Checkout class to determine payment requirements earlier in the flow - Only validate billing address when payment is actually being collected - Apply WordPress code style fixes to hooks documentation generator Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Address CodeRabbit review feedback and refactor Settings API PWYW fixes: - Add custom_amounts and pwyw_recurring to Cart in process_order() - Add missing pricing inputs to should_collect_payment() temporary cart - Remove v-bind:name suppression for PWYW duration fields in product edit - Update Product::is_recurring() to check pwyw_recurring_mode - Add wu_product_is_recurring filter for extensibility Settings API refactor: - Create save_setting() helper for DRY code - Add sanitize_setting_value() using Field API for proper sanitization - Add get_field_definition() to look up field definitions from Settings - Remove body_params from API logging to avoid storing sensitive data Grammar and text fixes: - "This products" → "These products" - "do not exist" → "does not exist" - Remove trailing space from "Force Synchronous Site Publication" Security improvements: - Add rel="noopener noreferrer" and esc_url() to privacy policy link Cleanup: - Delete stale inc/berlindb-dynamic-hooks.php duplicate - Fix changelog: separate 2.4.10 (released) from 2.4.11 (unreleased) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Enforce a strong password * Restructure E2E tests with programmatic setup and working checkout flows Replace fragile UI-based wizard setup with WP-CLI/PHP fixture approach: - Add PHP fixtures for DB tables, products, checkout form, trial products, and verification scripts - Create 000-setup, 010-manual-checkout-flow, 020-free-trial-flow specs - Fix wpCli command (npx wp-env instead of npm run env) and add wpCliFile - Remove broken checkout commands and old specs that used vague selectors - Remove domain-mapping-roles and plugin specs (incompatible with wp-env) - Fix wizard.spec.js: handle variable button text on installer steps, add missing recommended-plugins step, reset custom login page on setup - Remove WooCommerce addon from core .wp-env.json test plugins - Add env:fix-perms script for Docker permission issues All 15 tests across 7 specs pass reliably on consecutive runs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix PHPCS violations in E2E PHP fixtures Apply WordPress coding standards: escape echo output with esc_html(), use wp_json_encode() instead of json_encode(), fix spacing in function calls and arrays. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix e2e workflow: correct spec names, remove invalid CLI flags, fix error handling - Reference actual spec files (000-setup, 010-manual-checkout-flow, 020-free-trial-flow) instead of non-existent ones (checkout-registration, setup-wizard-complete, etc.) - Remove invalid Cypress CLI flags (--video, --screenshot-on-failure, --record, --reporter-options) that caused 'unknown option' errors - Remove continue-on-error from test steps so failures properly fail the job - Remove redundant 'Fail job if tests failed' step Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix searches * Add the doc * fix legacy * Use correct logic * Update test matrix to require PHP 8.2 minimum Remove PHP 7.4, 8.0, and 8.1 from the CI test matrix. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 4258c98 commit e757221

62 files changed

Lines changed: 6479 additions & 6291 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e.yml

Lines changed: 13 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -120,66 +120,24 @@ jobs:
120120
echo "Base URL: http://localhost:8889"
121121
cat cypress.env.json 2>/dev/null || echo "❌ cypress.env.json not found"
122122
123-
- name: Run Setup Wizard Test (Must Run First)
123+
- name: Run Setup Test (Must Run First)
124124
id: setup-test
125-
continue-on-error: true
126125
run: |
127-
echo "=== Starting Setup Wizard Test ==="
128-
129-
# Don't exit on errors - we want to capture the result
126+
echo "=== Starting Setup Test ==="
130127
npx cypress run \
131128
--config-file cypress.config.test.js \
132-
--spec "tests/e2e/cypress/integration/setup-wizard-complete.spec.js" \
133-
--browser ${{ matrix.browser }} \
134-
--reporter spec \
135-
--reporter-options "verbose=true" \
136-
--env "CYPRESS_CRASH_REPORTS=0" \
137-
--record false \
138-
--video true \
139-
--screenshot-on-failure true
140-
141-
CYPRESS_EXIT_CODE=$?
142-
143-
if [ $CYPRESS_EXIT_CODE -eq 0 ]; then
144-
echo "✅ Setup wizard test passed successfully"
145-
echo "setup_success=true" >> $GITHUB_OUTPUT
146-
else
147-
echo "❌ Setup wizard test failed with exit code $CYPRESS_EXIT_CODE"
148-
echo "Capturing detailed failure information..."
149-
echo "=== WordPress State ==="
150-
curl -I http://localhost:8889 || echo "WordPress not responding"
151-
echo "=== Test Files ==="
152-
ls -la tests/e2e/cypress/screenshots/ 2>/dev/null || echo "No screenshots directory"
153-
ls -la tests/e2e/cypress/videos/ 2>/dev/null || echo "No videos directory"
154-
echo "=== Docker Logs ==="
155-
docker logs $(docker ps -q --filter "name=tests-wordpress") 2>&1 | tail -10 || echo "No Docker logs"
156-
echo "=== File System ==="
157-
ls -la tests/e2e/cypress/integration/setup-wizard-complete.spec.js || echo "Setup test file missing"
158-
echo "setup_success=false" >> $GITHUB_OUTPUT
159-
fi
160-
161-
- name: Verify Setup Completed Successfully
162-
if: success()
163-
run: |
164-
echo "=== Verifying Setup Wizard Completion ==="
165-
# Test for setup completion indicators
166-
curl -s "http://localhost:8889/wp-admin/network/" | grep -i "ultimo\|dashboard" && echo "✅ Setup appears successful" || echo "⚠️ Setup verification unclear"
129+
--spec "tests/e2e/cypress/integration/000-setup.spec.js" \
130+
--browser ${{ matrix.browser }}
167131
168132
- name: Run Checkout Tests (After Setup)
169-
if: always() # Run checkout tests regardless of setup wizard result for debugging
170-
continue-on-error: true
133+
id: checkout-tests
171134
run: |
135+
set +e
172136
echo "=== Starting Checkout Tests ==="
173-
echo "Setup wizard result: ${GITHUB_OUTPUT}"
174-
echo "Setup success flag: ${{ steps.setup-test.outputs.setup_success }}"
175-
echo "Running checkout test suite (setup wizard success not required for debugging)..."
176137
177-
# Run all checkout tests in sequence
178138
CHECKOUT_TESTS=(
179-
"tests/e2e/cypress/integration/checkout-registration.spec.js"
180-
"tests/e2e/cypress/integration/checkout-validation.spec.js"
181-
"tests/e2e/cypress/integration/checkout-scenarios.spec.js"
182-
"tests/e2e/cypress/integration/checkout-confirmation.spec.js"
139+
"tests/e2e/cypress/integration/010-manual-checkout-flow.spec.js"
140+
"tests/e2e/cypress/integration/020-free-trial-flow.spec.js"
183141
)
184142
185143
TOTAL_FAILURES=0
@@ -190,13 +148,7 @@ jobs:
190148
npx cypress run \
191149
--config-file cypress.config.test.js \
192150
--spec "$TEST_SPEC" \
193-
--browser ${{ matrix.browser }} \
194-
--reporter spec \
195-
--reporter-options "verbose=true" \
196-
--env "CYPRESS_CRASH_REPORTS=0" \
197-
--record false \
198-
--video true \
199-
--screenshot-on-failure true
151+
--browser ${{ matrix.browser }}
200152
201153
CYPRESS_EXIT_CODE=$?
202154
@@ -209,14 +161,12 @@ jobs:
209161
done
210162
211163
if [ $TOTAL_FAILURES -gt 0 ]; then
212-
echo "❌ $TOTAL_FAILURES checkout tests failed"
213-
echo "Capturing failure information..."
214-
ls -la tests/e2e/cypress/screenshots/ 2>/dev/null || echo "No screenshots"
215-
ls -la tests/e2e/cypress/videos/ 2>/dev/null || echo "No videos"
216-
else
217-
echo "✅ All checkout tests passed successfully!"
164+
echo "❌ $TOTAL_FAILURES checkout test(s) failed"
165+
exit 1
218166
fi
219167
168+
echo "✅ All checkout tests passed!"
169+
220170
- name: Fix permissions for Cypress output
221171
if: always()
222172
run: sudo chown -R $USER:$USER tests/e2e/cypress
@@ -237,12 +187,6 @@ jobs:
237187
name: cypress-videos-${{ matrix.php }}-${{ matrix.browser }}
238188
path: tests/e2e/cypress/videos
239189

240-
- name: Fail job if tests failed
241-
if: failure()
242-
run: |
243-
echo "❌ One or more e2e tests failed."
244-
exit 1
245-
246190
- name: Stop WordPress Environment
247191
if: always()
248192
run: npm run env:stop

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"]
15+
php-version: ["8.2", "8.3", "8.4", "8.5"]
1616
services:
1717
mysql:
1818
image: mariadb:11.4

.wp-env.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
"."
88
],
99
"mappings": {
10-
"wp-content/mu-plugins/email-smtp-dev.php": "./mu-plugins/email-smtp-dev/email-smtp-dev.php"
10+
"wp-content/mu-plugins/email-smtp-dev.php": "./mu-plugins/email-smtp-dev/email-smtp-dev.php",
11+
"wp-content/sunrise.php": "./sunrise.php"
1112
},
1213
"config": {
1314
"WP_DEBUG": true,
1415
"WP_DEBUG_DISPLAY": true,
1516
"WP_DEBUG_LOG": true,
1617
"SCRIPT_DEBUG": true,
1718
"WP_MEMORY_LIMIT": "256M",
18-
"WP_MAX_MEMORY_LIMIT": "512M"
19+
"WP_MAX_MEMORY_LIMIT": "512M",
20+
"SUNRISE": true
1921
}
2022
},
2123
"tests": {
@@ -24,15 +26,17 @@
2426
"."
2527
],
2628
"mappings": {
27-
"wp-content/mu-plugins/email-smtp-test.php": "./mu-plugins/email-smtp-test/email-smtp-test.php"
29+
"wp-content/mu-plugins/email-smtp-test.php": "./mu-plugins/email-smtp-test/email-smtp-test.php",
30+
"wp-content/sunrise.php": "./sunrise.php"
2831
},
2932
"config": {
3033
"WP_DEBUG": true,
3134
"WP_DEBUG_DISPLAY": false,
3235
"WP_DEBUG_LOG": true,
3336
"SCRIPT_DEBUG": true,
3437
"WP_MEMORY_LIMIT": "256M",
35-
"WP_MAX_MEMORY_LIMIT": "512M"
38+
"WP_MAX_MEMORY_LIMIT": "512M",
39+
"SUNRISE": true
3640
}
3741
}
3842
}

0 commit comments

Comments
 (0)