discourse/app/helpers/qunit_helper.rb
David Taylor c7dce90f43
DEV: Switch to using standard ember-cli test bundle (#23337)
Previously we were patching ember-cli so that it would split the test bundle into two halves: the helpers, and the tests themselves. This was done so that we could use the helpers for `/theme-qunit` without needing to load all the core tests. This patch has proven problematic to maintain, and will become even harder under Embroider.

This commit removes the patch, so that ember-cli goes back to generating a single `tests.js` bundle. This means that core test definitions will now be included in the bundle when using `/theme-qunit`, and so this commit also updates our test module filter to exclude them from the run. This is the same way that we handle plugin tests on the regular `/tests` route, and is fully supported by qunit.

For now, this keeps `/theme-qunit` working in both development and production environments. However, we are very likely to drop support in production as part of the move to Embroider.
2023-09-04 17:09:55 +01:00

17 lines
490 B
Ruby

# frozen_string_literal: true
module QunitHelper
def theme_tests
theme = Theme.find_by(id: request.env[:resolved_theme_id])
return "" if theme.blank?
_, digest = theme.baked_js_tests_with_digest
src =
"#{GlobalSetting.cdn_url}" \
"#{Discourse.base_path}" \
"/theme-javascripts/tests/#{theme.id}-#{digest}.js" \
"?__ws=#{Discourse.current_hostname}"
"<script defer src='#{src}' data-theme-id='#{theme.id}'></script>".html_safe
end
end