refactor: Fix #1277 + Cache components' JS/CSS scripts at class creation (#1283)

* refactor: Cache components' JS and CSS scripts at class creation time

* refactor: add test for no template_rendered signal for component with no template
This commit is contained in:
Juro Oravec 2025-07-03 12:27:21 +02:00 committed by GitHub
parent 007009a480
commit c692b7a310
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 138 additions and 58 deletions

View file

@ -96,3 +96,19 @@ class TestTemplateSignal:
templates_used = _get_templates_used_to_render(template)
assert "slotted_template.html" in templates_used
assert "simple_template.html" in templates_used
@djc_test(parametrize=PARAMETRIZE_CONTEXT_BEHAVIOR)
@with_template_signal
def test_template_rendered_skipped_when_no_template(self, components_settings):
class EmptyComponent(Component):
pass
registry.register("empty", EmptyComponent)
template_str: types.django_html = """
{% load component_tags %}
{% component 'empty' / %}
"""
template = Template(template_str, name="root")
templates_used = _get_templates_used_to_render(template)
assert templates_used == ["root"]