Acceptance test: WordPress with the Tachyon plugin
The unit, oracle and remote smoke suites test the Worker against URLs written by hand. The acceptance test starts from WordPress instead. It installs humanmade/tachyon-plugin 0.11.1 (commit 652ecd2, the version ADR 0006 targets) and uploads images through WP-CLI. It then asks WordPress which image URLs and dimensions it would put in a page, and fetches each URL from a deployed Worker.
What it checks
Section titled “What it checks”For four fixtures (a 2400×1600 JPEG, a 1000×1500 PNG with alpha, a 1600×900 WebP and a 200×120 JPEG that is smaller than every intermediate size), the test collects URLs from the plugin’s three output paths:
| Source | Cases |
|---|---|
wp_get_attachment_image_src | thumbnail, medium, medium_large, large, full, [300, 200], [1000, 1000] |
wp_get_attachment_image_srcset( …, 'large' ) | Every candidate, by its w descriptor |
the_content | An <img class="wp-image-N size-medium"> and every srcset candidate the filter adds |
Every URL must:
- start with
TACHYON_URL(so the plugin rewrote it), - return
200with the attachment’s MIME type andCache-Control: max-age=31536000, - decode to the width WordPress declares, and to the declared height when WordPress declares one.
srcsetcandidates declare only a width. Content images are checked against the inserted size, because the plugin removeswidthandheightfrom content<img>tags and addsdata-recalc-dims.
The test fails if the plugin is inactive, if TACHYON_URL differs from the one WordPress uses, or if any fixture produced no cases.
Prerequisites
Section titled “Prerequisites”- WP-CLI for a WordPress install the test may change. On a multisite, the test creates its own sub-site. On a single site, set
WP_SITE_URLto a site you can add media to. - A deployed Worker with
TACHYON_ORIGIN=r2and an emptyTACHYON_KEY_PREFIX. - Wrangler logged in to the account that owns the Worker’s R2 bucket.
prepareuploads the Originals withwrangler r2 object put --remote. - Node dependencies installed (
npm ci). The fixtures are generated with Sharp.
Environment
Section titled “Environment”| Variable | Default | Purpose |
|---|---|---|
TACHYON_URL | (required) | What the plugin rewrites the uploads base URL to, e.g. https://<worker>/uploads. Loaded with wp --require=tests/acceptance/tachyon-url.php, so wp-config.php is never edited |
WP_CLI | wp | Shell command that runs WP-CLI for the target install |
WP_SITE_URL | the TACHYON_ACCEPTANCE_SLUG sub-site | Existing site to use instead of creating a sub-site |
TACHYON_ACCEPTANCE_SLUG | tachyon-acceptance | Sub-site slug on a multisite |
TACHYON_ACCEPTANCE_BUCKET | tachyon-uploads | R2 bucket bound to the Worker as BUCKET |
TACHYON_ACCEPTANCE_KEEP_PLUGIN | unset | Set to keep tachyon-plugin installed on cleanup |
export TACHYON_URL=https://<worker>/uploadsnode tests/acceptance/wp-site.mjs preparenpm run test:acceptancenode tests/acceptance/wp-site.mjs cleanup # optionalprepare can be re-run. It deletes earlier acceptance attachments and their R2 objects before importing fresh ones. npm run test:acceptance does not change WordPress or R2, so you can repeat it after redeploying the Worker.
Local (by Flywheel)
Section titled “Local (by Flywheel)”A bare wp does not reach Local’s database. Point WP_CLI at the wrapper from the wp-cli-local skill, which runs WP-CLI with the site’s PHP and MySQL socket. Install it with npx skills add soderlind/skills --skill wp-cli-local, and run the commands from inside the site’s directory:
cd ~/Sites/<site>/app/public/wp-content/plugins/tachyon-edgeexport WP_CLI="bash ~/.agents/skills/wp-cli-local/scripts/wp"export TACHYON_URL=https://tachyon-edge.<account>.workers.dev/uploadsnode tests/acceptance/wp-site.mjs preparenpm run test:acceptanceWhat prepare changes
Section titled “What prepare changes”- Creates the sub-site
/<TACHYON_ACCEPTANCE_SLUG>/unlessWP_SITE_URLis set. If another network plugin fatals in a site-creation hook after the site exists,preparecarries on with the site. - Installs
tachyon-pluginfrom the pinned GitHub archive if it is missing, fails unless the installed version is0.11.1, and activates it on the test site only. - Imports the four fixtures with
wp media importand marks them with the_tachyon_acceptancepost meta. - Uploads each Original to R2. The key is the path of the plugin’s URL for the attachment. On a multisite, the plugin strips
/sites/Nfrom the uploads base URL before rewriting it, so a sub-site file becomesuploads/sites/N/YYYY/MM/<file>.
cleanup reverses all four steps. It deletes the plugin unless TACHYON_ACCEPTANCE_KEEP_PLUGIN is set. If you had tachyon-plugin installed before the test, set that variable.
| File | Role |
|---|---|
| tests/acceptance/wp-site.mjs | prepare and cleanup |
| tests/acceptance/tachyon-url.php | Defines TACHYON_URL from the environment for wp --require |
| tests/acceptance/cases.php | wp eval-file script that prints the cases as one TACHYON_CASES {json} line |
| tests/acceptance/acceptance.ts | Jest suite that fetches every case. Excluded from npm test |
📦 Source: soderlind/tachyon-edge · Edit on GitHub