Skip to content

Add a seed endpoint so specs can set state, run cron, stub gateways and capture mail - #20

Open
iamprazol wants to merge 9 commits into
mainfrom
feat/state-seeding-helpers
Open

iamprazol wants to merge 9 commits into
mainfrom
feat/state-seeding-helpers

Conversation

@iamprazol

Copy link
Copy Markdown
Collaborator

What this does

Lets a spec put a disposable WordPress site into a state a click cannot reach, and read what the site tried to do in response, over HTTP on any engine. That is what payment webhooks, cron handlers, subscription rows and email specs need. Until now the PR gate asked for a spec for these changes and the harness could not write one, so the only way out was the qa-waived label.

A new QA-only mu-plugin, tgqa-seed.php, is staged next to the probe and answers to the same per-run token. It has five operations:

Operation Does
options Read named options; set options and get back what was there, so a restore is exact (including back to "not set").
cron Run a hook the product declared in seed_cron_hooks, in the request. Reports scheduled instead of requiring it.
rows Insert, select and delete in tables the product declared in seed_tables. Refuses undeclared tables, unknown columns, enum values MySQL would refuse, and unconditioned deletes.
stubs Answer outbound calls from a list: the Stripe SDK, and anything on wp_remote_* (PayPal). An unstubbed call to a stubbed host is refused and logged, never sent.
mail Record what wp_mail() is asked to send instead of sending it. Off until a spec turns it on.

A product opts in with seed_tables and seed_cron_hooks in .themegrill-qa/suite.json; boot-wp.mjs and run-suite.mjs stage them. Free runs now export TGQA_PROBE_URL too (it was pro-only). packages/core/mail.js is a dependency-free client for the mail operation. SUITE.md §2c documents all of it, including what Playground gets wrong.

Two workflow fixes found by running it in Actions

  • The suite jobs run on ubuntu-24.04. ubuntu-latest is now Ubuntu 26.04, which Playwright 1.57 cannot install Chromium on, so every product's suite would fail before running a spec.
  • suite.yml exports the seed endpoint's URL from the boot step. Without it every seeding spec skipped, and the run could go green with nothing tested.

Engine differences it works around, each measured on Playground

  • SQLite accepts any string in an ENUM column, so rows checks enum values against the real column.
  • ON DELETE CASCADE does not fire, so seeding helpers delete children first.
  • GET_LOCK() answers the string 1=1, which MySQL-written code reads as "not acquired". The mu-plugin rewrites it to 1 on SQLite only. The race a lock guards is therefore not testable there, and SUITE.md says so.

Verified

Used by 22 specs on UR (payment retry, Stripe and PayPal webhooks, a renewal invoice, chargebacks, the missed-payment backfill, and email). They pass in GitHub Actions against this branch: 59 of 62 tests on the last full run, every one of those specs green (themegrill/user-registration#1571). The two failures are unrelated UR tests. Each spec also fails on assertions when the code it guards is reverted.

Not verified, and for the reviewer

  • --engine wp-env stages no mu-plugins, so none of this runs there.
  • pro-suite.yml got the runner pin only; nothing here has run on a pro repo.
  • boot-wp.mjs exits 0 when a stale Playground already holds the port, then hands out a token the old server does not know, which shows up as 403s from the seed endpoint. Found, not fixed.
  • No version bump in .claude-plugin/marketplace.json is included, so local plugin users will not pick this up until one is added.

🤖 Generated with Claude Code

…n hook over HTTP, and publish the probe URL on free runs
… tables the product declares in suite.json seed_tables, refusing enum values MySQL would
…hat is attached even when the product does not schedule it
…veats that mail and cron can be driven through the seed endpoint
…04 and Playwright cannot install Chromium there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant