mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Support for running theme test with Ember CLI (second attempt)
This PR includes support for running theme tests in legacy ember production envrionments.
This commit is contained in:
@@ -13,9 +13,11 @@ module ApplicationHelper
|
||||
@extra_body_classes ||= Set.new
|
||||
end
|
||||
|
||||
def discourse_config_environment
|
||||
def discourse_config_environment(testing: false)
|
||||
|
||||
# TODO: Can this come from Ember CLI somehow?
|
||||
{ modulePrefix: "discourse",
|
||||
config = {
|
||||
modulePrefix: "discourse",
|
||||
environment: Rails.env,
|
||||
rootURL: Discourse.base_path,
|
||||
locationType: "auto",
|
||||
@@ -32,7 +34,16 @@ module ApplicationHelper
|
||||
version: "#{Discourse::VERSION::STRING} #{Discourse.git_version}",
|
||||
exportApplicationGlobal: true
|
||||
}
|
||||
}.to_json
|
||||
}
|
||||
|
||||
if testing
|
||||
config[:environment] = "test"
|
||||
config[:locationType] = "none"
|
||||
config[:APP][:autoboot] = false
|
||||
config[:APP][:rootElement] = '#ember-testing'
|
||||
end
|
||||
|
||||
config.to_json
|
||||
end
|
||||
|
||||
def google_universal_analytics_json(ua_domain_name = nil)
|
||||
|
||||
@@ -1,6 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module QunitHelper
|
||||
|
||||
def vendor_theme_tests
|
||||
return preload_script("vendor-theme-tests") if @legacy_ember
|
||||
preload_script("vendor")
|
||||
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
|
||||
|
||||
def theme_tests
|
||||
theme = Theme.find_by(id: request.env[:resolved_theme_id])
|
||||
return "" if theme.blank?
|
||||
|
||||
Reference in New Issue
Block a user