Update plugin handling in Ember CLI `testem` environment (PR #15319)

(to be rebased-and-merged)

DEV: Update plugin JS loading in Ember CLI testem environment

Previously we were adding /assets/discourse/tests/core_plugin_tests.js to the test html all the time. This works in development mode, but fails silently when using testem via the ember test CLI, because there is no proxy running.

This commit makes a few changes to fix this, and make it more useful:

  • Only renders the plugin <script> when in development mode, or when LOAD_PLUGINS=1 (matching core’s behavior)
  • Only loads plugin translations based on the same logic
  • When running via testem, and the above conditions are met, testem is configured to proxy core_plugin_tests.js through to a rails server. (port based on the UNICORN_PORT env variable)
  • Adds a descriptive error if the plugin <script> fails to load. This can happen if the rails server hasn’t been started
  • Updates the logic for testem browsers. Ember CLI always launches testem in “CI” mode. Instead, we can check process.env.CI.

DEV: Update rake qunit:test and rake plugin:qunit to use testem

For now this is still gated behind a QUNIT_EMBER_CLI=1 environment variable, but will eventually become the default so that we can remove run-qunit.js.


This is nice but unfortunately it’s going to conflict with my current work on getting theme tests to run in production. Any chance we could shelve it temporarily and try again then? Things are moving around a fair bit.

Ok, no problem. Let me know when your changes are ready, and I’ll rebase this branch onto them :+1:

(Rebased onto the latest testing changes in main)

Looks good but you, too, have the emoji problem!

:smiling_face_with_three_hearts: 🤦

Is this something we should merge now? or should we wait till post 2.8

Feels overall pretty low risk but a fair bit does change.

I think it’s safe to merge - it only touches test-environment code - nothing related to production. If there are no objections, I’ll merge at the start of my day tomorrow