FIX: Allow plugins to provide test directories with transpiled `.js`

FIX: Allow plugins to provide test directories with transpiled .js

diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb
index 302076e..20419fe 100644
--- a/lib/plugin/instance.rb
+++ b/lib/plugin/instance.rb
@@ -548,6 +548,9 @@ class Plugin::Instance
       if transpile_js
         DiscourseJsProcessor.plugin_transpile_paths << root_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
         DiscourseJsProcessor.plugin_transpile_paths << admin_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
+
+        test_path = "#{root_dir_name}/test/javascripts"
+        DiscourseJsProcessor.plugin_transpile_paths << test_path.sub(Rails.root.to_s, '').sub(/^\/*/, '')
       end
     end
 
diff --git a/test/javascripts/plugin_tests.js.erb b/test/javascripts/plugin_tests.js.erb
index a7b2f9a..5709a19 100644
--- a/test/javascripts/plugin_tests.js.erb
+++ b/test/javascripts/plugin_tests.js.erb
@@ -12,8 +12,9 @@
   Discourse.plugins.each do |p|
     root_path = "#{File.dirname(p.path)}/test/javascripts"
 
-    Dir.glob(root_path + '/**/**.es6').each do |f|
-      require_asset(f)
-    end
+    to_glob = [root_path + '/**/**.es6']
+    to_glob << (root_path + '/**/**.js') if p.transpile_js
+
+    Dir.glob(to_glob) { |f| require_asset(f) }
   end
 %>

GitHub sha: 7f8c5cf7

1 Like