DEV: Remove ember-cli flags from the backend (#17147)

…and other auxiliary code

* Restore `QUNIT_EMBER_CLI` flag warning
* Add `ALLOW_EMBER_CLI_PROXY_BYPASS`
This commit is contained in:
Jarek Radosz
2022-06-20 16:33:05 +02:00
committed by GitHub
parent 6f27c50287
commit 2c1fc28d00
19 changed files with 67 additions and 197 deletions

View File

@@ -102,7 +102,7 @@ class ApplicationController < ActionController::Base
end
def ember_cli_required?
Rails.env.development? && ENV['NO_EMBER_CLI'] != '1' && request.headers['X-Discourse-Ember-CLI'] != 'true'
Rails.env.development? && ENV["ALLOW_EMBER_CLI_PROXY_BYPASS"] != "1" && request.headers['X-Discourse-Ember-CLI'] != 'true'
end
def application_layout

View File

@@ -8,16 +8,6 @@ class QunitController < ApplicationController
}
layout false
def is_ember_cli_proxy?
request.headers["HTTP_X_DISCOURSE_EMBER_CLI"] == "true"
end
# only used in non-ember-cli test / dev
def index
raise Discourse::NotFound.new if is_ember_cli_proxy? || EmberCli.enabled?
raise Discourse::InvalidAccess.new if Rails.env.production?
end
def theme
raise Discourse::NotFound.new if !can_see_theme_qunit?

View File

@@ -136,11 +136,9 @@ module ApplicationHelper
end
def preload_script(script)
script = EmberCli.transform_name(script)
scripts = [script]
if EmberCli.enabled? && chunks = EmberCli.script_chunks[script]
if chunks = EmberCli.script_chunks[script]
scripts.push(*chunks)
end

View File

@@ -1,33 +1,6 @@
# frozen_string_literal: true
module QunitHelper
def vendor_theme_tests
if EmberCli.enabled?
preload_script("vendor")
else
preload_script("vendor-theme-tests")
end
end
def support_bundles
result = [
preload_script("discourse/tests/test-support-rails"),
preload_script("discourse/tests/test-helpers-rails")
].join("\n").html_safe
end
def boot_bundles
result = []
if EmberCli.enabled?
result << preload_script("scripts/discourse-test-listen-boot")
result << preload_script("scripts/discourse-boot")
else
result << preload_script("discourse/tests/test_starter")
end
result.join("\n").html_safe
end
def theme_tests
theme = Theme.find_by(id: request.env[:resolved_theme_id])
return "" if theme.blank?

View File

@@ -28,7 +28,7 @@
<%= preload_script_url ExtraLocalesController.url('overrides') %>
<%- end %>
<%= preload_script "vendor" %>
<%= preload_script "application" %>
<%= preload_script "discourse" %>
<%- Discourse.find_plugin_js_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, request: request).each do |file| %>
<%= preload_script file %>
<%- end %>
@@ -57,7 +57,6 @@
<meta name="apple-itunes-app" content="app-id=<%= SiteSetting.ios_app_id %><%= ios_app_argument %>">
<%- end %>
<%= yield :head %>
<%= build_plugin_html 'server:before-head-close' %>
@@ -118,7 +117,6 @@
</form>
<% end %>
<script defer src="<%= script_asset_path "start-discourse" %>"></script>
<%= yield :data %>

View File

@@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>QUnit Test Runner</title>
<%= discourse_color_scheme_stylesheets %>
<%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>
<%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %>
<%= preload_script "locales/#{I18n.locale}" %>
<%= preload_script "vendor" %>
<%= preload_script "application" %>
<%= preload_script "admin" %>
<%= preload_script "wizard" %>
<%= preload_script "discourse/tests/test-support-rails" %>
<%= preload_script "discourse/tests/test-helpers-rails" %>
<%= preload_script "discourse/tests/active-plugins" %>
<%= preload_script "discourse/tests/core-tests" %>
<%= preload_script "discourse/tests/plugin-tests" %>
<%= preload_script "discourse/tests/test_starter" %>
<%= csrf_meta_tags %>
<meta property="og:title" content="">
<meta property="og:url" content="">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

View File

@@ -7,12 +7,13 @@
<%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>
<%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %>
<%= preload_script "locales/#{I18n.locale}" %>
<%= vendor_theme_tests %>
<%= preload_script "application" %>
<%= preload_script "vendor" %>
<%= preload_script "discourse" %>
<%= preload_script "admin" %>
<%= preload_script "discourse/tests/active-plugins" %>
<%= preload_script "admin-plugins" %>
<%= support_bundles %>
<%= preload_script "test-support" %>
<%= preload_script "test-helpers" %>
<%= theme_translations_lookup %>
<%= theme_js_lookup %>
<%= theme_lookup("head_tag") %>
@@ -33,12 +34,7 @@
<%- end %>
</head>
<body>
<%- if !@suggested_themes %>
<%- if !EmberCli.enabled? %>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<%- end %>
<%- else %>
<%- if @suggested_themes %>
<h2>Theme QUnit Test Runner</h2>
<%- if @suggested_themes.size == 0 %>
<p>Cannot find any theme tests.</p>
@@ -51,6 +47,7 @@
<%- end %>
</body>
<%- if !@suggested_themes %>
<%= boot_bundles %>
<%= preload_script "scripts/discourse-test-listen-boot" %>
<%= preload_script "scripts/discourse-boot" %>
<%- end %>
</html>