2021-04-12 08:02:58 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module QunitHelper
|
2022-01-13 15:16:34 -05:00
|
|
|
|
|
|
|
def vendor_theme_tests
|
|
|
|
return preload_script("vendor-theme-tests") if @legacy_ember
|
2022-02-14 06:21:39 -05:00
|
|
|
preload_vendor_scripts
|
2022-01-13 15:16:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def support_bundles
|
|
|
|
result = []
|
|
|
|
if Rails.env.production? || @legacy_ember
|
|
|
|
result << preload_script("discourse/tests/test-support-rails")
|
|
|
|
result << preload_script("discourse/tests/test-helpers-rails")
|
|
|
|
else
|
|
|
|
result << preload_script("test-support")
|
|
|
|
result << preload_script("test-helpers")
|
|
|
|
end
|
|
|
|
result.join("\n").html_safe
|
|
|
|
end
|
|
|
|
|
|
|
|
def boot_bundles
|
|
|
|
result = []
|
|
|
|
if @legacy_ember
|
|
|
|
result << preload_script("discourse/tests/test_starter")
|
|
|
|
elsif @is_proxied
|
|
|
|
result << preload_script("scripts/discourse-test-listen-boot")
|
|
|
|
result << preload_script("scripts/discourse-boot")
|
|
|
|
else
|
|
|
|
result << preload_script("discourse-test-listen-boot")
|
|
|
|
result << preload_script("discourse-boot")
|
|
|
|
end
|
|
|
|
result.join("\n").html_safe
|
|
|
|
end
|
|
|
|
|
2021-04-12 08:02:58 -04:00
|
|
|
def theme_tests
|
2021-06-15 02:57:17 -04:00
|
|
|
theme = Theme.find_by(id: request.env[:resolved_theme_id])
|
2021-04-28 16:12:08 -04:00
|
|
|
return "" if theme.blank?
|
2021-04-12 08:02:58 -04:00
|
|
|
|
2021-04-28 16:12:08 -04:00
|
|
|
_, 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 src='#{src}'></script>".html_safe
|
2021-04-12 08:02:58 -04:00
|
|
|
end
|
|
|
|
end
|