Skip to content

test: token-free PHPUnit + Playwright E2E suite#75

Open
akzmoudud wants to merge 1 commit into
fix/16-post-gemini-bugfixesfrom
feat/test-suite
Open

test: token-free PHPUnit + Playwright E2E suite#75
akzmoudud wants to merge 1 commit into
fix/16-post-gemini-bugfixesfrom
feat/test-suite

Conversation

@akzmoudud

Copy link
Copy Markdown
Contributor

Summary

A token-free test suite for the free plugin, modelled on dokan-lite — no test ever calls the real Gemini/Veo API, so CI runs for $0. Design recorded in docs/adr/0002-token-free-test-strategy.md.

PHPUnit — 27 tests

Boots real WP + WooCommerce (bin-less, via wp-phpunit). The one server-side Gemini path (customer try-on) is stubbed with a pre_http_request filter, plus a network guard so nothing unstubbed can reach the internet. Covers every REST controller (settings, generate/try-on, promotion, dashboard/usage, product, video-thumbnail), bulk try-on, container/provider wiring, and the promo-banner 30-day dismissal logic.

Playwright E2E — @wordpress/env, one suite, dokan-style @lite/@pro tags

  • @lite (Pro off, 10): dashboard nav, enhancer image generation (browser page.route Gemini stub), image-config field→request combinations (2K/4K model-upgrade, background, apparel), promo banner / plugins-screen link / sidebar Upgrade, settings save.
  • @pro (Pro on, 7): promo touchpoints hidden when Pro is active, video generation via a stubbed Veo operation + fake URI + a committed 1.7 KB MP4, and video-config combinations (aspect ratio, duration, prompt). tryaura-pro is mapped into wp-env; the license is simulated in the test-guard mu-plugin (no license server in CI).

How to run

  • PHPUnit: composer test
  • E2E (from tests/pw): npm ci && npm run env:start, then npm run test:lite / npm run test:pro

Token-free by construction

Both Gemini paths are stubbed (browser page.route; server pre_http_request) and a guard blocks any unstubbed call. The returned images/video are hand-authored fixtures (a 1×1 PNG, a 1.7 KB MP4) — the tests assert the plugin's own request-building and response-handling, never real AI output. See ADR 0002 for the trade-off (fixture drift) and rationale.

Notes

  • Base is fix/16-post-gemini-bugfixes (the code under test); retarget to main after that merges.
  • The @pro license simulation is test-only (in tests/pw/mu-plugins, gated on tryaura-pro being active) — the real key was rejected by the license server, so features are simulated as licensed for CI.
  • Combination coverage is representative, not exhaustive; the harness (setImageConfig/setVideoConfig + request capture) makes adding more a few lines each.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UL9nyXmJTkPB7QmT7jTKGF

Adds a dokan-lite-style test suite that never spends a Gemini token
(docs/adr/0002-token-free-test-strategy.md).

PHPUnit (27) — boots real WP + WooCommerce; the try-on Gemini call is
stubbed via a pre_http_request filter plus a network guard so nothing can
reach the API. Covers every REST controller (settings, generate/try-on,
promotion, dashboard/usage, product, video-thumbnail), bulk try-on,
container wiring, and the promo-banner 30-day dismissal logic.

Playwright E2E on @wordpress/env — one suite, dokan-style @lite/@Pro tags:
- @lite (Pro off, 10): dashboard nav, enhancer image generation (browser
  page.route Gemini stub), image-config field->request combinations, the
  promo banner / plugins-screen link / sidebar Upgrade, settings save.
- @Pro  (Pro on, 7): promo touchpoints hidden when Pro is active, video
  generation via a stubbed Veo operation + fake-URI + a committed 1.7 KB
  MP4, and video-config combinations. tryaura-pro is mapped into wp-env;
  the license is simulated in the test-guard mu-plugin (no license server
  in CI).

Run: composer test  |  (tests/pw) npm run test:lite / npm run test:pro

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UL9nyXmJTkPB7QmT7jTKGF
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 71025ea4-0b70-4429-967b-e13b4cca02b4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/test-suite

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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