Skip to content

Feature :: D5 :: Tests :: 3PS :: Track C :: EX-02 StaticModule - #75

Merged
Jronk merged 5 commits into
mainfrom
50791-d5-3ps-tests-t3ps-ex-02-static-module
Aug 13, 2026
Merged

Feature :: D5 :: Tests :: 3PS :: Track C :: EX-02 StaticModule#75
Jronk merged 5 commits into
mainfrom
50791-d5-3ps-tests-t3ps-ex-02-static-module

Conversation

@robicse11127

Copy link
Copy Markdown
Contributor

Summary

This PR adds the EX-01 test harness for d5-extension-example-modules. All changes are confined to this plugin repo. No production module behavior is modified.

  • PHP: PHPUnit bootstrap via DIVI_PATH, plugin-local wp-tests-config.php, and three smoke tests.
  • JavaScript: RTL Jest setup, smoke Jest config, and one module.json smoke test.
  • Docs: README testing section with local env var and command instructions.

This harness unblocks EX-02–EX-05 module-specific tests.


What changed

PHP

File Purpose
phpunit.xml PHPUnit configuration
tests/php/bootstrap.php Loads polyfills, registers plugin, bootstraps Divi WP tests
tests/php/test-environment.php Shared env/path helpers
tests/php/wp-tests-config.php Plugin-local DB and WordPress config
tests/php/.env.example Local environment template
tests/php/PluginSmokeTest.php Smoke tests (file exists, constant, autoload)
composer.json phpunit/phpunit, yoast/phpunit-polyfills, composer test script

JavaScript

File Purpose
test-config/jest.smoke.config.js Lightweight smoke test config (EX-01)
test-config/jest-rtl-setup.js @testing-library/jest-dom matchers
test-config/jest.config.js Full module harness for upcoming tests (EX-02+)
test-config/babel-transformer.js Jest 28+ compatible transform output
src/components/static-module/__tests__/module-json.test.ts module.json smoke test
package.json npm test (smoke), npm run test:modules (full harness)

Other

File Purpose
README.md Testing prerequisites and commands
.gitignore Ignore .phpunit.result.cache

Test plan

  • Check out branch 50726-d5-3ps-trac-c-ex01
  • Copy tests/php/.env.example to tests/php/.env and set local paths
  • Use PHP 7.4 with mysqli enabled
  • Run composer install and npm install
  • Run composer test — expect 3 passing tests
  • Run npm test — expect 1 passing test
  • Confirm plugin still loads in Divi Visual Builder (no runtime regressions)

Local setup (example)

export PATH="/opt/homebrew/bin:$PATH"
export DIVI_PATH=/path/to/wp-content/themes/Divi
export DIVIDIR=$DIVI_PATH/includes/builder-5/visual-builder/build
export WPDIR=/path/to/wordpress/root

cd d5-extension-example-modules
cp tests/php/.env.example tests/php/.env
composer install
npm install
composer test
npm test

Verification report

Verified locally on 2026-06-30 using PHP 7.4.33 with mysqli and WordPress 6.9.

=== PHP version ===
PHP 7.4.33 (cli) (built: May 12 2026 16:03:08) ( NTS )
mysqli

=== composer test ===
> phpunit
PHPUnit memory_limit(setup)=128M
Installing...
Running as single site.

WordPress (installed): 6.9
PHPUnit 9.6.34 by Sebastian Bergmann and contributors.

...                                                                 3 / 3 (100%)

Time: 00:00.075, Memory: 141.00 MB

OK (3 tests, 4 assertions)

=== npm test ===
> d5-extension-example-modules@1.0.0 test
> wp-scripts test-unit-js --config ./test-config/jest.smoke.config.js

PASS src/components/static-module/__tests__/module-json.test.ts
  Static Module module.json smoke test
    ✓ parses with expected module metadata (4 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.14 s
Ran all test suites.

Verification results

Command Result Details
composer test PASS 3 tests, 4 assertions
npm test PASS 1 test suite, 1 test

PHP smoke tests

  1. Plugin main file exists on disk.
  2. D5_EXTENSION_EXAMPLE_MODULES_PATH constant is defined after bootstrap.
  3. MEE\Modules\StaticModule\StaticModule autoloads via Composer.

JS smoke test

  1. src/components/static-module/module.json parses with expected metadata (name, title, moduleClassName).

Notes for reviewers

  • PHPUnit bootstraps through Divi's existing WP test suite via DIVI_PATH (read-only; no Divi repo changes).
  • npm test runs the EX-01 smoke config only. npm run test:modules is the full Divi/WordPress Jest harness for upcoming module tests.
  • PHPUnit requires a PHP binary with the mysqli extension. Use PHP 7.4 if that is your local standard.
  • WooCommerce may be required by Divi's PHPUnit bootstrap depending on environment setup.
  • No GitHub Actions added (local-only execution per Track C v1 scope).

Out of scope

  • StaticModule, DynamicModule, Parent+Child, and D4Module test suites (EX-02–EX-05)
  • Manual Visual Builder checklist (EX-09)
  • Changes outside d5-extension-example-modules

Add PHP registration and FE snapshot tests plus metadata and RTL edit
snapshot coverage for StaticModule without changing module runtime code.

Co-authored-by: Cursor <cursoragent@cursor.com>
@etstaging
etstaging requested a review from rupakdhiman July 2, 2026 15:31
@robicse11127
robicse11127 changed the base branch from 50726-d5-3ps-tests-t3ps-ex-01-modules-test-harness to main July 3, 2026 05:54

@ayubadiputra ayubadiputra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@robicse11127 BTW, the npm test passed on my local, but not the composer test.

Image
There was 1 failure:

1) StaticModuleRenderTest::test_render_outputs_summary_html_snapshot
Failed asserting that two strings are equal.

Snapshots can be updated by passing `-d --update-snapshots` through PHPUnit's CLI arguments.
--- Expected
+++ Actual
@@ @@
 '<html><body>\n
-<div class="example_static_module_0 example_static_module et_pb_bg_layout_light et_pb_module"><div class="example_static_module__inner">\n
-<div class="example_static_module__image"><div>New</div></div>\n
+<div class="example_static_module_0 example_static_module et_pb_bg_layout_light et_pb_module et_flex_module"><div class="example_static_module__inner">\n
+<div class="example_static_module__image"><span class="example_static_module__badge">New</span></div>\n
 <div class="example_static_module__content-container">\n
-<div>Static module summary text for snapshot testing.</div>\n
+<div class="example_static_module__summary">Static module summary text for snapshot testing.</div>\n
 <div class="example_static_module__content"></div>\n
 </div>\n
 </div></div>\n
 <style>.example_static_module_0 {padding-top: 30px; padding-right: 30px; padding-bottom: 30px; padding-left: 30px;}\n
 .example_static_module_0 .example_static_module__content-container {text-align: start;}\n
-color: #ffffff;</style>\n
+.example_static_module_0 .example_static_module__badge {color: #ffffff;}</style>\n
 </body></html>\n
 '

/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/themes/Divi/includes/builder-5/server/__TESTS__/config/Helpers/Drivers/HtmlDriver.php:79
/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/themes/Divi/includes/builder-5/server/vendor/spatie/phpunit-snapshot-assertions/src/Snapshot.php:55
/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/themes/Divi/includes/builder-5/server/vendor/spatie/phpunit-snapshot-assertions/src/MatchesSnapshots.php:187
/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/themes/Divi/includes/builder-5/server/__TESTS__/config/TestCases/DiviWPUnitTest.php:513
/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/themes/Divi/includes/builder-5/server/__TESTS__/config/TestCases/DiviWPUnitTest.php:496
/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/plugins/d5-extension-example-modules/tests/php/Snapshot/StaticModuleRenderTest.php:67
/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/plugins/d5-extension-example-modules/vendor/phpunit/phpunit/src/TextUI/Command.php:146
/Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/plugins/d5-extension-example-modules/vendor/phpunit/phpunit/src/TextUI/Command.php:99
phpvfscomposer:///Users/ayubadiputra/Local Sites/etdev-d5-review/app/public/wp-content/plugins/d5-extension-example-modules/vendor/phpunit/phpunit/phpunit:106

FAILURES!
Tests: 10, Assertions: 18, Failures: 1.
Script phpunit handling the test event returned with error code 1

FYI, composer test on main branch is passed on my local which means my setup is correct. However, the composer test on this PR branch is failed.

… Divi (#50791)

Update the PHP HTML snapshot to match newer Divi element render output so composer test passes in the ET review environment.

Co-authored-by: Cursor <cursoragent@cursor.com>
@robicse11127

Copy link
Copy Markdown
Contributor Author

@ayubadiputra I have updated the snapshots. Hopefully it will pass at your end as well.

Thanks.

@robicse11127
robicse11127 requested a review from ayubadiputra July 5, 2026 11:12
@ayubadiputra

Copy link
Copy Markdown
Member

@robicse11127 Thanks! All passed,

@ayubadiputra ayubadiputra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@bitfade bitfade left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@robicse11127 please resolve merge conflicts.

Integrate DynamicModule test stack from main while preserving StaticModule
EX-02 smoke and module test configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>
@robicse11127
robicse11127 requested a review from bitfade July 13, 2026 10:02
@robicse11127

Copy link
Copy Markdown
Contributor Author

@bitfade I have resolved the conflicts. Please check it once.

Thanks.

@robicse11127

Copy link
Copy Markdown
Contributor Author

@bitfade It been stuck for a while now. Please check it once you may.

Thanks.

@DeepHiveET

Copy link
Copy Markdown

DeepHive Agent Merge (observe)

Mode: observe — no merge / no redispatch executed.

Would leave for humans (stay in Dev Review).

Reason: human CHANGES_REQUESTED is open

Signals

  • dh=unknown (stale vs head)
  • codex=unknown (no codex handoff comment yet)
  • bugbot=unknown (bugbot has not commented)
  • escalation=clean
  • ci=unknown
  • humanChangesRequested=true

@Jronk
Jronk merged commit 3c0da76 into main Aug 13, 2026
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.

5 participants