Merge pull request #15607 from edx/ari/webpack-commons-all-pages
include webpack commons bundle on all pages
This commit is contained in:
@@ -19,7 +19,7 @@ class TextbookIndexTestCase(CourseTestCase):
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
# we don't have resp.context right now,
|
||||
# due to bugs in our testing harness :(
|
||||
if resp.context:
|
||||
if resp.context and resp.context.get('course'):
|
||||
self.assertEqual(resp.context['course'], self.course)
|
||||
|
||||
def test_view_index_xhr(self):
|
||||
|
||||
@@ -66,6 +66,8 @@ TEST_ROOT = path('test_root')
|
||||
|
||||
# Want static files in the same dir for running on jenkins.
|
||||
STATIC_ROOT = TEST_ROOT / "staticfiles"
|
||||
INSTALLED_APPS = tuple(app for app in INSTALLED_APPS if app != 'webpack_loader')
|
||||
INSTALLED_APPS += ('openedx.tests.util.webpack_loader',)
|
||||
WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json"
|
||||
|
||||
GITHUB_REPO_ROOT = TEST_ROOT / "data"
|
||||
|
||||
@@ -62,6 +62,8 @@ from openedx.core.djangolib.js_utils import (
|
||||
|
||||
<%static:js group='base_vendor'/>
|
||||
|
||||
<%static:webpack entry="commons"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.baseUrl = "${settings.STATIC_URL | n, js_escaped_string}";
|
||||
require.config({
|
||||
|
||||
@@ -94,21 +94,18 @@ source, template_path = Loader(engine).load_template_source(path)
|
||||
<%
|
||||
from django.template import Template, Context
|
||||
from webpack_loader.exceptions import WebpackLoaderBadStatsError
|
||||
try:
|
||||
return Template("""
|
||||
{% load render_bundle from webpack_loader %}
|
||||
{% render_bundle "commons" %}
|
||||
{% render_bundle entry %}
|
||||
<script type="text/javascript">
|
||||
{% autoescape off %}{{ body }}{% endautoescape %}
|
||||
</script>
|
||||
""").render(Context({
|
||||
'entry': entry,
|
||||
'body': capture(caller.body)
|
||||
}))
|
||||
except (IOError, WebpackLoaderBadStatsError) as e:
|
||||
# Don't break Mako template rendering if the bundle or webpack-stats can't be found, but log it
|
||||
logger.error('[LEARNER-1938] {error}'.format(error=e))
|
||||
return Template("""
|
||||
{% load render_bundle from webpack_loader %}
|
||||
{% render_bundle entry %}
|
||||
{% if body %}
|
||||
<script type="text/javascript">
|
||||
{% autoescape off %}{{ body }}{% endautoescape %}
|
||||
</script>
|
||||
{% endif %}
|
||||
""").render(Context({
|
||||
'entry': entry,
|
||||
'body': capture(caller.body)
|
||||
}))
|
||||
%>
|
||||
</%def>
|
||||
|
||||
|
||||
@@ -1967,6 +1967,7 @@ YOUTUBE = {
|
||||
YOUTUBE_API_KEY = None
|
||||
|
||||
################################### APPS ######################################
|
||||
|
||||
INSTALLED_APPS = (
|
||||
# Standard ones that are always installed...
|
||||
'django.contrib.auth',
|
||||
|
||||
@@ -113,6 +113,8 @@ NOSE_PLUGINS = [
|
||||
TEST_ROOT = path("test_root")
|
||||
# Want static files in the same dir for running on jenkins.
|
||||
STATIC_ROOT = TEST_ROOT / "staticfiles"
|
||||
INSTALLED_APPS = tuple(app for app in INSTALLED_APPS if app != 'webpack_loader')
|
||||
INSTALLED_APPS += ('openedx.tests.util.webpack_loader',)
|
||||
WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json"
|
||||
|
||||
STATUS_MESSAGE_PATH = TEST_ROOT / "status_message.json"
|
||||
|
||||
@@ -81,6 +81,8 @@ from pipeline_mako import render_require_js_path_overrides
|
||||
<%static:js group='lms_bootstrap'/>
|
||||
% endif
|
||||
|
||||
<%static:webpack entry="commons"/>
|
||||
|
||||
<script>
|
||||
window.baseUrl = "${settings.STATIC_URL | n, js_escaped_string}";
|
||||
(function (require) {
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
{% endwith %}
|
||||
|
||||
</div>
|
||||
{% load render_bundle from webpack_loader %}
|
||||
{% render_bundle "commons" %}
|
||||
|
||||
{% javascript 'base_application' %}
|
||||
|
||||
|
||||
0
openedx/tests/util/__init__.py
Normal file
0
openedx/tests/util/__init__.py
Normal file
0
openedx/tests/util/webpack_loader/__init__.py
Normal file
0
openedx/tests/util/webpack_loader/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
This module mocks the external package django-webpack-loader within
|
||||
python unittest execution, so python tests have no dependency on
|
||||
frontend assets. See LEARNER-1938 for further details.
|
||||
"""
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def render_bundle(bundle_name):
|
||||
"""
|
||||
This is the only webpack_loader function we call directly.
|
||||
"""
|
||||
return ''
|
||||
Reference in New Issue
Block a user