Skip to content

Add comprehensive test coverage (PHP, JS, E2E)#88

Merged
kraftbj merged 10 commits intotrunkfrom
test-coverage-audit
Mar 16, 2026
Merged

Add comprehensive test coverage (PHP, JS, E2E)#88
kraftbj merged 10 commits intotrunkfrom
test-coverage-audit

Conversation

@kraftbj
Copy link
Collaborator

@kraftbj kraftbj commented Mar 6, 2026

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:

  • +180 PHP tests (5 new files): REST endpoints, assets class, HTML parsing, plugin functions, plugin class internals
  • +168 JS tests (7 new files): HTML parser utils, component structure verification, hooks, media grid/thumbnail utilities
  • +25 E2E tests (6 specs): Auth, editor loading, content scraping, publishing, media handling, categories/tags
  • E2E infrastructure: Playwright setup, auth helpers, CI workflow job
  • 14 tests removed: Brittle style assertions, test.todo placeholders, one tautological test
  • 4 tests fixed: Replaced tautological/vacuous assertions with meaningful ones

Test counts

Layer Before After
PHP 75 255
JS 119 287
E2E 0 25
Total 194 567

Caveats

  • All tests were generated by Claude and reviewed by validation agents, not humans
  • JS component tests primarily use a source-reading pattern (verifying code structure) rather than React rendering

Test plan

  • composer install && vendor/bin/phpunit passes (255 tests)
  • npm run test:js passes (287 tests)
  • npm run env:start && npm run test:e2e passes (25 tests)
  • CI workflow runs all three suites on PR

kraftbj added 5 commits March 6, 2026 23:17
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
@kraftbj kraftbj requested a review from Copilot March 6, 2026 23:03
@kraftbj kraftbj added this to the 2.0.2 milestone Mar 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.todo scaffolding.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kraftbj kraftbj marked this pull request as ready for review March 16, 2026 22:07
@kraftbj kraftbj merged commit 64a2507 into trunk Mar 16, 2026
3 of 7 checks passed
@kraftbj kraftbj deleted the test-coverage-audit branch March 16, 2026 22:11
kraftbj added a commit that referenced this pull request Mar 16, 2026
The test_suggested_post_format_link test was added in the test coverage
audit (PR #88) expecting 'link', but PR #96 separately removed link
format auto-suggestion. Update the test to expect '' instead.

See #94
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.

2 participants