# Live DDEV acceptance

These opt-in tests use the normal local WordPress database and the actual image
tool configured in KSF settings. They are separate from the disposable PHPUnit
database. `site.php` refuses to operate outside a `.ddev.site` WP-CLI installation.
The default source IDs select 36 existing images from the current wp-dev library.

The commands create 120 copied attachments, two public test pages, a temporary
administrator/session, and temporary GreenShift settings. They preserve the original
files, check original SHA-256 hashes, and restore/delete only their own image records.
State and the original wp-config.php are kept in a private container `/tmp` directory.
The browser obtains a temporary WordPress cookie in memory and uses the actual
admin page/REST route. Neither conversion responses nor browser fetch are mocked.

Use these commands from the plugin directory with local Composer/npm dependencies
and a Playwright-compatible Chromium already installed. Set `KSF_CHROMIUM` when
Chromium is outside the default local Playwright cache. `KSF_LIVE_ARTIFACTS` selects
the host output directory. The CDN URL below is this environment's DDEV direct
HTTPS port; set `KSF_LIVE_CDN_URL` if it differs.

```bash
ddev snapshot --name=ksf-live-before-20261016
ddev exec wp eval-file /var/www/html/wp-content/plugins/kind-site-framework/tests/Live/site.php prepare 120
node tests/Live/browser.cjs sample
node tests/Live/browser.cjs library

# A temporary, real caching plugin. Skipping KSF during installation avoids
# unrelated security notifications and baseline rebuilds for this test plugin.
ddev exec wp plugin install wp-super-cache --activate --skip-plugins=kind-site-framework
node tests/Live/browser.cjs cache
node tests/Live/browser.cjs restore
node tests/Live/browser.cjs retained

ddev exec wp eval-file /var/www/html/wp-content/plugins/kind-site-framework/tests/Live/site.php cleanup
ddev exec wp eval-file /var/www/html/wp-content/plugins/kind-site-framework/tests/Live/site.php finish-files
ddev exec wp plugin uninstall wp-super-cache --deactivate --skip-plugins=kind-site-framework
ddev exec wp eval-file /var/www/html/wp-content/plugins/kind-site-framework/tests/Live/site.php finish-files
```

Only install/uninstall that temporary cache plugin when it was absent before the
test. The supplied execution record did so. A database snapshot also allows full
rollback of incidental plugin options/transients; restore the saved wp-config.php
and cache drop-ins as above because a database snapshot does not restore files.

The `library` pass closes a real processing tab, then temporarily points the helper
URL at a closed local port to exercise three real connection failures. It restores
the configured helper URL in `finally`, retries failed rows, and continues the queue.
If a run is terminated externally during that step, `site.php outage off` restores
the original helper URL before any further requests.

The cache pass requires an actual `X-WP-Super-Cache` HIT header, verifies anonymous
page delivery, and checks the plugin's CDN rewrite against a local HTTPS alias.
This is a CDN integration check, not an external CDN edge/cache-invalidation test.
Restoration retains WebP files until stale page/CSS references have been cleared.
The restored pages must match original image URLs, displayed dimensions, alt text,
backgrounds and attachment metadata. The retained-file pass verifies old WebP URLs
still return HTTP 200 with `image/webp` after restoration.
