Add comprehensive test coverage (PHP, JS, E2E)#88
Merged
Conversation
Automated coverage audit identified gaps and generated tests: - 5 new PHP test files (+180 tests): REST endpoints, assets class, HTML parsing, plugin functions, plugin class internals - 7 new JS test files (+168 tests): HTML parser utils, component verification, hooks, media utilities - 6 new E2E specs (+28 tests): auth, editor, scraping, publishing, media, categories/tags - Playwright infrastructure: config, auth helpers, CI workflow job - Removed 14 low-value tests (brittle style assertions, test.todo placeholders, tautological assertion) - Fixed 4 vacuous/conditional assertions in existing tests
The default branch is trunk, not main. Update CI workflow to match and add this to CLAUDE.md for future reference.
getByLabel('Password') matches both the password input and the
"Show password" button. Use #user_pass for the input directly.
Also fix createUser to check both stdout and stderr for the
"already exists" message since wp-env outputs it on stdout.
- Use regex route patterns (/press-this\/v1\/.../) instead of glob
patterns (**/wp-json/...) to match both pretty permalink and
?rest_route= URL formats used by wp-env
- Fix strict mode violations: use .first() for elements duplicated
by a11y live regions, use { exact: true } for tag tokens
- Fix page close race conditions: use Promise.all for click +
waitForResponse when route handler may trigger navigation
- Accept 404 status for unauthenticated REST endpoint (route not
discoverable without auth)
- Simplify media handling tests to avoid dependency on external
image loading for dimension filtering
- Remove flaky content-typing test that depends on block editor
keyboard interaction
- Fix createUser to check if user exists before creating
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a large set of AI-generated tests across PHP, JS unit tests, and new Playwright E2E coverage for the Press This plugin, plus CI support to run the new E2E suite.
Changes:
- Added new PHP/JS unit tests targeting REST endpoints, parsing utilities, and component/hook behavior.
- Introduced Playwright E2E test suite + config, along with CI workflow job to run it.
- Removed placeholder/brittle style-assertion tests and
test.todoscaffolding.
Reviewed changes
Copilot reviewed 29 out of 31 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/verification/issue-verification.test.js | Removes manual/todo-based “issue verification” scaffolding tests. |
| tests/utils/html-parser.test.js | Adds JS unit tests for html-parser utilities (escaping, metadata parsing, suggested content). |
| tests/styles/responsive.test.js | Removes SCSS string-based responsive assertions. |
| tests/styles/header-light-theme.test.js | Removes SCSS string-based header theme assertions. |
| tests/php/test-sanitization-error-handling.php | Tightens an assertion to always validate WP_Error shape; removes a tautological filter test. |
| tests/php/test-rest-endpoints.php | Adds REST route registration/permission/handler coverage for Press This endpoints. |
| tests/php/test-post-type-filter.php | Replaces vacuous assertion with behavior-based post-type check. |
| tests/php/test-plugin-functions.php | Adds coverage for standalone plugin functions (proxy flags, URL validation, context guards). |
| tests/php/test-plugin-class-extended.php | Adds extended coverage of WP_Press_This_Plugin internals via reflection. |
| tests/php/test-html-parsing-extended.php | Adds extended coverage for HTML parsing helpers and edge cases. |
| tests/php/test-assets.php | Adds tests for Press_This_Assets settings/localization/registration/deps behavior. |
| tests/hooks/use-editor-setup.test.js | Adds source-reading tests for useEditorSetup hook structure/behavior. |
| tests/e2e/utils/auth.js | Adds Playwright auth helpers + logged-in fixture/state storage. |
| tests/e2e/publishing.spec.js | Adds E2E flows for draft save, publish, redirect behaviors, and error notices. |
| tests/e2e/media-handling.spec.js | Adds E2E coverage for scraped images → sidebar/panels visibility. |
| tests/e2e/editor-load.spec.js | Adds E2E coverage for editor load + essential UI elements. |
| tests/e2e/content-scraping.spec.js | Adds E2E coverage for scanning/scrape success + error states. |
| tests/e2e/categories-tags.spec.js | Adds E2E coverage for category selection + tag entry behaviors. |
| tests/e2e/auth-access.spec.js | Adds E2E coverage for authentication/access control and REST auth behavior. |
| tests/components/tags-helper-text.test.js | Removes brittle source/SCSS string assertions for tag helper text. |
| tests/components/ScrapedMediaPanel.test.js | Adds component/source-pattern tests and utility extraction checks. |
| tests/components/MediaThumbnail.test.js | Adds tests for thumbnail URL/media-type utilities and component accessibility patterns. |
| tests/components/MediaGrid.test.js | Adds tests for MediaGrid URL sanitization/dimension filtering and component patterns. |
| tests/components/FeaturedImagePanel.test.js | Adds source-reading tests for Featured Image panel structure/behavior. |
| tests/components/CategoryPanel.test.js | Adds source-reading tests for category panel filtering/add-new-category/accessibility patterns. |
| playwright.config.js | Adds Playwright configuration for local/CI E2E runs. |
| package.json | Adds Playwright dependency and e2e scripts; declares Node/NPM engine requirements. |
| package-lock.json | Locks Playwright and related dependency updates. |
| CLAUDE.md | Documents default branch name (trunk). |
| .gitignore | Ignores Playwright artifacts + PHPUnit result cache. |
| .github/workflows/test.yml | Adds CI job to run Playwright E2E suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 31 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fix: harden E2E auth validation and response guard
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is an experiment in AI-generated test coverage. It may or may not be accepted.
An automated audit identified gaps in the existing test suite and generated tests to fill them. The changes include:
test.todoplaceholders, one tautological testTest counts
Caveats
Test plan
composer install && vendor/bin/phpunitpasses (255 tests)npm run test:jspasses (287 tests)npm run env:start && npm run test:e2epasses (25 tests)