FIX: Theme tests should work in production (#13333)

The `ember_jquery` bundle contains production builds of Ember and jQuery
which doesn't work with tests. This commits introduces a new
`theme_qunit_vendor` bundle which is copy of the `vendor` bundle but
doesn't contain `ember_jquery`.

This commit is a partial revert of
409c8585e4
This commit is contained in:
Osama Sayegh 2021-06-08 22:03:59 +03:00 committed by GitHub
parent a27de199b7
commit 940eb28e31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 15 deletions

View File

@ -0,0 +1,6 @@
// discourse-skip-module
//= require env
//= require jquery.debug
//= require ember.debug
//= require discourse-loader

View File

@ -0,0 +1,15 @@
// discourse-skip-module
//= require qunit
//= require ember-qunit
//= require fake_xml_http_request
//= require route-recognizer
//= require pretender
// These are not loaded in prod or development
// But we need them for testing handlebars templates in qunit
//= require handlebars
//= require ember-template-compiler
//= require sinon
//= require break_string

View File

@ -1,15 +1,37 @@
// discourse-skip-module
// This bundle contains the same dependencies as app/assets/javascripts/vendor.js
// minus ember_jquery.
// ember_jquery doesn't work with theme tests in production because it
// contains production builds of Ember and jQuery, so we have a separate bundle
// caled theme_qunit_ember_jquery which contains a debug build for Ember and jQuery.
// We don't put theme_qunit_ember_jquery in this bundle because it would make the
// bundle too big and cause OOM exceptions during rebuilds for self-hosters on
// low-end machines.
//= require qunit
//= require ember-qunit
//= require fake_xml_http_request
//= require route-recognizer
//= require pretender
//= require logster
// These are not loaded in prod or development
// But we need them for testing handlebars templates in qunit
//= require handlebars
//= require ember-template-compiler
//= require template_include.js
//= require sinon
//= require break_string
//= require message-bus
//= require jquery.ui.widget.js
//= require Markdown.Converter.js
//= require bootbox.js
//= require popper.js
//= require bootstrap-modal.js
//= require caret_position
//= require jquery.color.js
//= require jquery.fileupload.js
//= require jquery.iframe-transport.js
//= require jquery.tagsinput.js
//= require jquery.sortable.js
//= require lodash.js
//= require mousetrap.js
//= require mousetrap-global-bind.js
//= require rsvp.js
//= require show-html.js
//= require buffered-proxy
//= require jquery.autoellipsis-1.0.10
//= require virtual-dom
//= require virtual-dom-amd
//= require intersection-observer
//= require discourse-shims
//= require pretty-text-bundle

View File

@ -7,8 +7,9 @@
<%= discourse_stylesheet_link_tag(:desktop, theme_ids: nil) %>
<%= discourse_stylesheet_link_tag(:test_helper, theme_ids: nil) %>
<%= preload_script "locales/en" %>
<%= preload_script "vendor" %>
<%= preload_script "discourse/tests/theme_qunit_ember_jquery" %>
<%= preload_script "discourse/tests/theme_qunit_vendor" %>
<%= preload_script "discourse/tests/theme_qunit_tests_vendor" %>
<%= preload_script "markdown-it-bundle" %>
<%= preload_script "application" %>
<%- Discourse.find_plugin_js_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, request: request).each do |file| %>

View File

@ -173,8 +173,10 @@ module Discourse
confirm-new-email/bootstrap.js
onpopstate-handler.js
embed-application.js
discourse/tests/theme_qunit_helper.js
discourse/tests/theme_qunit_ember_jquery.js
discourse/tests/theme_qunit_vendor.js
discourse/tests/theme_qunit_tests_vendor.js
discourse/tests/theme_qunit_helper.js
discourse/tests/test_starter.js
}

View File

@ -98,8 +98,9 @@ describe QunitController do
expect(response.body).to include("/stylesheets/desktop_")
expect(response.body).to include("/stylesheets/test_helper_")
expect(response.body).to include("/assets/locales/en.js")
expect(response.body).to include("/assets/vendor.js")
expect(response.body).to include("/assets/discourse/tests/theme_qunit_ember_jquery.js")
expect(response.body).to include("/assets/discourse/tests/theme_qunit_vendor.js")
expect(response.body).to include("/assets/discourse/tests/theme_qunit_tests_vendor.js")
expect(response.body).to include("/assets/markdown-it-bundle.js")
expect(response.body).to include("/assets/application.js")
expect(response.body).to include("/assets/admin.js")