fabiocaccamo / django-admin-interface

:superhero: :zap: django's default admin interface with superpowers - customizable themes, popup windows replaced by modals and many other features.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add tests for default django templates that are overridden.

fabiocaccamo opened this issue · comments

Problem

Some features require template changes that now work correctly, but may become incompatible with future django releases.

Solution

Discover incompatibility issues as soon as possible using the CI by comparing the default django template (this will run for each supported django version in the CI) with a list of templates that we know are compatible with this library.
Doing this, any future change to an overridden template will immediately result in a CI failure, very easy to discover and debug.


Here there are all default django admin templates that are overridden by this package:
https://github.com/fabiocaccamo/django-admin-interface/tree/main/admin_interface/templates/admin

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar

Is your idea to add special comments like {# begin d-a-i custom code #} around added lines?
What about changed lines?

No, it's too hard comparing customized templates with the original ones, my idea is this:

Preparation

  • For each django version supported (also when adding new versions)
    • For each admin template that is overwritten by this library
      • copy template code from django repo to a path like
        tests/data/templates/admin/base_site.html.django-{{ django_version }}

Tests

  • For each template in this library that overrides a django admin template
    • Load the django original template that has been overwritten as string from the django installed in the current test environment
    • Expect the loaded template to match any template in
      tests/data/templates/admin/{{ template_name }}.django-{{ django_version }}
    • If a matching template is not found CI fails

What do you think about it?

Ah I understand, it’s an automated comparison of a saved copy with the upstream file! Plan seems good.