Skip to content

Conversation

@osbre
Copy link
Collaborator

@osbre osbre commented Apr 14, 2025

(In progress. Will force-push and mark as "Ready" when finished)


Note

Introduce full E2E testing pipeline and browser tests, while refactoring plugin internals (settings/hooks, tracking rules, script registry, admin page) and scoping the settings UI.

  • CI/CD & Test Infra
    • Add E2E Tests GitHub Actions workflow running WordPress on FrankenPHP with MySQL, PHPUnit, Panther/Zenstruck Browser; caches WP/composer; uploads artifacts.
    • Add Dockerized runtime: .github/docker/Dockerfile and Caddyfile for FrankenPHP; introduce phpunit.xml.
    • Update release workflow to pnpm v10.
    • NPM scripts for Playwright and test setup; bump Tailwind plugins/versions; add lockfile updates.
  • Backend/Plugin Refactor:
    • Replace TrackingPolicyTrackingRules and ScriptManagerScriptRegistry; introduce WordPressHooks and WordPressSettings for WP integration.
    • Replace settings PageSettings/AdminPage and enhance WordPressPageIntegration contract; wire up in simple-analytics.php.
    • Update Plugin to DI-based boot flow, activation/uninstall using new settings/hooks; script registration via new registry; add role/IP exclusion logic.
  • Admin UI
    • Scope Tailwind to .sa-settings; remove declarative shadow DOM wrapper; link stylesheet directly; set important in tailwind.config.js.
    • Adjust resources/css/settings.css and UI layout accordingly.
  • Tests
    • Add browser tests under tests/Browser/* and test kernel; composer dev deps for PHPUnit/Panther/Zenstruck; .gitignore additions.

Written by Cursor Bugbot for commit 71d0a9f. This will update automatically on new commits. Configure here.

@osbre osbre marked this pull request as draft April 14, 2025 03:29
@adriaandotcom adriaandotcom mentioned this pull request Jul 29, 2025
@adriaandotcom
Copy link
Contributor

shaquille-o-neal-oh-can-t-wait-wxqx9am5b3t2n74l

15s
Run ./vendor/bin/phpunit
  ./vendor/bin/phpunit
  shell: /usr/bin/bash -e {0}
  env:
    WP_VERSION: 6.7
    WP_SITE_URL: http://localhost:8100
    WP_DB_NAME: wordpress
    WP_DB_USER: root
    WP_DB_PASS: root
    WP_DB_HOST: 127.0.0.1
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
    PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
PHPUnit 12.4.0 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.14
Configuration: /home/runner/work/wordpress-plugin/wordpress-plugin/phpunit.xml

.E                                                                  2 / 2 (100%)

Saved Browser Artifacts:

  test_adds_script_with_ignored_pages
    Saved Source Files:
      * ./var/browser/source/error_Tests-Browser-PluginSettingsTest__test_adds_script_with_ignored_pages__0.html:
    Saved Console Logs:
      * ./var/browser/console-logs/error_Tests-Browser-PluginSettingsTest__test_adds_script_with_ignored_pages__0.log:
    Saved Screenshots:
      * ./var/browser/screenshots/error_Tests-Browser-PluginSettingsTest__test_adds_script_with_ignored_pages__0.png:

Time: 00:14.918, Memory: 22.00 MB

There was 1 error:

1) Tests\Browser\PluginSettingsTest::test_adds_script_with_ignored_pages
Behat\Mink\Exception\ElementNotFoundException: Form field with id|name|label|value|placeholder "simpleanalytics_ignore_pages" not found.

/home/runner/work/wordpress-plugin/wordpress-plugin/vendor/behat/mink/src/Element/TraversableElement.php:163
/home/runner/work/wordpress-plugin/wordpress-plugin/vendor/zenstruck/browser/src/Browser.php:214
/home/runner/work/wordpress-plugin/wordpress-plugin/tests/Browser/PluginSettingsTest.php:25

ERRORS!
Tests: 2, Assertions: 6, Errors: 1.
Error: Process completed with exit code 2.
@adriaandotcom adriaandotcom marked this pull request as ready for review November 28, 2025 06:15
@adriaandotcom
Copy link
Contributor

Hey @osbre, I fixed the bug with AI, but I have no clue if it also broke something. Would you mind checking?

… settings

The `test_adds_script_with_ignored_pages` test assumed the plugin was already
active from a previous test, but PHPUnit tests run in isolation and execution
order isn't guaranteed.

- Add `activatePluginIfNeeded()` helper to BrowserTestCase that conditionally
  activates the plugin only if not already active
- Update `test_adds_script_with_ignored_pages` to use the helper

This ensures the test works regardless of execution order or whether the plugin
is already activated.
@osbre
Copy link
Collaborator Author

osbre commented Nov 28, 2025

I'll take it from here, thank you @adriaandotcom!

It's nice to see the CI pass at this stage. Here's a bit history on the previous progress:

At first, I completed all the test cases in PestPHP's newest browsing testing feature, which uses Playwright underneath. Unfortunately, I had some of the weirdest instability issues and browser failures where they shouldn't have been. The tests were passing, but once I re-ran them 8 times on GitHub CI, they would start failing. I couldn't figure out what was the reason for spontaneous timeouts, so I started by replacing the web server from PHP's built-in one to FrankenPHP. It didn't solve it. I made the decision to move away from anything powered by Playwright. Currently, I'm in the process of rewriting it to Symfony's Panther and zenstruck/browser library and seeing whether I'd be able to get rid of random timeouts this way. Although now that I look at it, the shadow dom likely played a role here.

@osbre osbre marked this pull request as draft November 28, 2025 11:10
@adriaandotcom
Copy link
Contributor

Sounds good @osbre, let me know if you need any help!

@osbre osbre removed the request for review from Maimunar December 9, 2025 20:32
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