E2e

From wp-media/imagify-plugin · View interactive version

E2e is an AI agent skill from the GitHub repository wp-media/imagify-plugin. Run E2E smoke tests (basic) or full acceptance + regression suite (extended).

How to use this skill

Skill file

E2E SKILL

Config loading

Read AGENTS.md → Project Configuration for every value this skill needs (local URL, boot

command, settings page, repo, test commands). Do not expect values to be injected — this skill is

standalone and no orchestrator supplies them.

The values used below: local environment http://localhost:8888 (admin / password), booted with

bash bin/dev-up.sh. Tests/e2e/specs/ is the permanent reviewed suite — QA runs do not write to it.

This skill provides end-to-end test execution at two tiers. The difference is scope and depth, not

tooling — browser driving belongs to whichever e2e-qa-tester agent the installed pipeline provides

(currently a playwright-cli based one), with curl for API-level checks.


Tier 1 — Basic

Purpose: behavioral verification and smoke tests. Fast enough to fit inside a planning

agent's execution window.

Invokers:

writing the spec. Use to confirm: does the current feature behave as described in the

issue? What does the current API or AJAX endpoint return for the scenario being changed?

Anti-rationalization table

| You'll be tempted to say | Why you can't |

|---|---|

| "The environment probably isn't up, I'll skip" | Run bash bin/dev-up.sh. It's idempotent. If it fails, log SKIP with the reason — do not silently omit the step. |

| "The change is backend-only, no need to smoke it" | The primary happy path must be verified. A backend change with no observable behavior change still needs a confirming assertion. |

| "I already read the code, I know it works" | "Seems right" never closes a task. Run the scenario. |

| "One scenario is too slow for this stage" | Basic tier is exactly one primary scenario. The cost is acceptable. |

Basic tier process

  1. Boot the environment (idempotent — safe to run if already up):

```bash

bash bin/dev-up.sh

```

If the script exits non-zero, set status: "SKIP", note the reason, and do not block

the pipeline.

  1. Run the primary happy path scenario from the spec or grooming plan.

Backend / AJAX / REST:

```bash

# Public REST or AJAX

curl -s -X POST http://localhost:8888/wp-admin/admin-ajax.php \

-H "Cookie: $(cat .wp-session-cookie 2>/dev/null)" \

-d 'action=<action>&nonce=...'

# Cache headers

curl -sI http://localhost:8888/ | grep -E '(x-cache|cf-cache)'

```

Browser (settings page, dashboard notices, interactive UI):

Drive the browser with whatever tooling the installed pipeline provides — currently

playwright-cli via Bash. Do not delegate to e2e-qa-tester at this tier (that is the

extended tier path). Log in at http://localhost:8888/wp-login.php as admin / password,

navigate to the target page, and read the page snapshot to confirm the expected element or

text is present.

Take at most 1–2 screenshots if helpful, but do not publish them at this tier.

  1. Report:

```json

{

"status": "PASS|FAIL|SKIP",

"scenarios_tested": ["Settings page loads without errors after enabling X option"],

"details": "Logged in as admin, navigated to http://localhost:8888/wp-admin/options-general.php?page=imagify, confirmed no JS console errors and X toggle present"

}

```

SKIP: bash bin/dev-up.sh failed or environment unreachable. Record reason. Do not block

the pipeline.

Basic tier boundaries


Tier 2 — Extended

Purpose: full acceptance criteria coverage, regression testing, edge cases, visual

comparison, and Playwright spec authoring with screenshot evidence.

Invoker: qa-engineer only.

Execution: the qa-engineer agent delegates browser flows to the e2e-qa-tester

sub-agent, which handles Playwright MCP driving, temporary spec authoring under

.e2e-temp/, screenshot publishing via the commit-SHA method, and clean-up.

The qa-engineer agent itself handles:

Strategy selection, report format, browser flow execution, and spec authoring belong to the

installed pipeline's qa-engineer and e2e-qa-tester agents — read those agent definitions for

details.

Spec and screenshot lifecycle belongs to the pipeline's e2e-qa-tester — follow whatever it does

(currently: temporary specs kept outside the repo, screenshots published to a gist). Do not commit

QA-run artefacts to the branch.

Tests/e2e/specs/ is the permanent, reviewed suite: everything in it runs in CI on every future

PR. Adding to it is a deliberate authoring task with review, never a side effect of a QA run. If a

QA run produces a flow worth keeping, say so in the report and let a human decide.


When to use which tier

| Invoker | Tier | Purpose |

|---|---|---|

| grooming-agent | Basic | Verify a behavioral assumption before writing the spec |

| qa-engineer | Extended | Full acceptance criteria + regression + screenshots |


Project-specific notes

```bash

npx @wordpress/env run cli wp plugin list --name=imagify

```

```typescript

test.skip( ! process.env.IMAGIFY_TESTS_API_KEY, 'IMAGIFY_TESTS_API_KEY not set' );

```

| Area | URL |

|---|---|

| Settings | /wp-admin/options-general.php?page=imagify |

| Bulk optimization | /wp-admin/upload.php?page=imagify-bulk-optimization |

| Custom folders (Files) | /wp-admin/upload.php?page=imagify-files |

| Media library (list) | /wp-admin/upload.php?mode=list |


License, quota, and API guards

Optimization behavior is gated behind license, API-key, and quota checks. Before claiming a feature

works or is broken, check whether one of these short-circuited the tested path.

| Guard | Function | Location |

|---|---|---|

| API reachable | Imagify_Requirements::is_api_up() | inc/classes/class-imagify-requirements.php:225 |

| API key valid | Imagify_Requirements::is_api_key_valid() | inc/classes/class-imagify-requirements.php:258 |

| Over quota | Imagify_Requirements::is_over_quota() | inc/classes/class-imagify-requirements.php:299 |

| API key valid (wrapper) | imagify_is_api_key_valid() | inc/functions/api.php:340 |

| API key valid (deprecated) | imagify_valid_key() | inc/deprecated/deprecated.php:206 |

Check the precondition first. bin/dev-seed.sh seeds IMAGIFY_TESTS_API_KEY into the

imagify_settings option. A result of 1 means the key is present and the API-key guards are not

blockers:

npx @wordpress/env run cli wp option get imagify_settings --format=json | grep -c '"api_key":"[^"]\+'

Reporting rule. If a guard on the tested path evaluates false locally, report cannot verify

citing its file:line. Never claim a behavioral pass through a blocked guard, and never report a

failure for a feature that was merely gated. Structural claims (file exists, hook registered) stay

verifiable.


Spec conventions

assertions, so CI passes while nothing is tested. Assert hard instead, with a message naming the

seed command that fixes the environment.

screenshotElement() helper from Tests/e2e/fixtures/screenshot.ts. A screenshot taken at

page-load position captures the top of the page rather than the feature under test, which is zero

evidence and misleads reviewers.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.