summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2021-01-26 23:10:00 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-02 12:21:21 +0200
commite32722d1606794f0a85d74811e53a0336a1ce305 (patch)
treed34bd8cc26240fa5446a30f41ff2fb30f6f5dd96 /tests/staticfiles_tests
parent9ee693bd6cf4074f04ec51c6f3cfe87cad392f12 (diff)
downloaddjango-e32722d1606794f0a85d74811e53a0336a1ce305.tar.gz
Fixed #32383 -- Added source map support to ManifestStaticFilesStorage.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/project/documents/cached/source_map.js1
-rw-r--r--tests/staticfiles_tests/project/documents/cached/source_map.js.map1
-rw-r--r--tests/staticfiles_tests/project/documents/cached/source_map_sensitive.js1
-rw-r--r--tests/staticfiles_tests/test_storage.py24
4 files changed, 27 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/project/documents/cached/source_map.js b/tests/staticfiles_tests/project/documents/cached/source_map.js
new file mode 100644
index 0000000000..b37c5e5701
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/cached/source_map.js
@@ -0,0 +1 @@
+//# sourceMappingURL=source_map.js.map
diff --git a/tests/staticfiles_tests/project/documents/cached/source_map.js.map b/tests/staticfiles_tests/project/documents/cached/source_map.js.map
new file mode 100644
index 0000000000..9e26dfeeb6
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/cached/source_map.js.map
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/tests/staticfiles_tests/project/documents/cached/source_map_sensitive.js b/tests/staticfiles_tests/project/documents/cached/source_map_sensitive.js
new file mode 100644
index 0000000000..d60c76b4f6
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/cached/source_map_sensitive.js
@@ -0,0 +1 @@
+//# sOuRcEMaPpInGURL=source_map.js.map
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py
index 7ae88e6c68..c6e2c48d93 100644
--- a/tests/staticfiles_tests/test_storage.py
+++ b/tests/staticfiles_tests/test_storage.py
@@ -216,6 +216,30 @@ class TestHashedFiles:
self.assertIn(b"other.d41d8cd98f00.css", content)
self.assertPostCondition()
+ def test_js_source_map(self):
+ relpath = self.hashed_file_path('cached/source_map.js')
+ self.assertEqual(relpath, 'cached/source_map.9371cbb02a26.js')
+ with storage.staticfiles_storage.open(relpath) as relfile:
+ content = relfile.read()
+ self.assertNotIn(b'//# sourceMappingURL=source_map.js.map', content)
+ self.assertIn(
+ b'//# sourceMappingURL=source_map.js.99914b932bd3.map',
+ content,
+ )
+ self.assertPostCondition()
+
+ def test_js_source_map_sensitive(self):
+ relpath = self.hashed_file_path('cached/source_map_sensitive.js')
+ self.assertEqual(relpath, 'cached/source_map_sensitive.5da96fdd3cb3.js')
+ with storage.staticfiles_storage.open(relpath) as relfile:
+ content = relfile.read()
+ self.assertIn(b'//# sOuRcEMaPpInGURL=source_map.js.map', content)
+ self.assertNotIn(
+ b'//# sourceMappingURL=source_map.js.99914b932bd3.map',
+ content,
+ )
+ self.assertPostCondition()
+
@override_settings(
STATICFILES_DIRS=[os.path.join(TEST_ROOT, 'project', 'faulty')],
STATICFILES_FINDERS=['django.contrib.staticfiles.finders.FileSystemFinder'],