summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2022-01-18 09:06:19 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-01-18 12:53:14 +0100
commitdc8bb35e39388d41b1f38b6c5d0181224e075f16 (patch)
treecbe024d80ae19b1e7d298d951804d6d69dd8784f /tests/staticfiles_tests
parentfac26684fd6228669a38104502a2f7b76340ebd2 (diff)
downloaddjango-dc8bb35e39388d41b1f38b6c5d0181224e075f16.tar.gz
Fixed #33446 -- Added CSS source map support to ManifestStaticFilesStorage.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/project/documents/cached/source_map.css2
-rw-r--r--tests/staticfiles_tests/project/documents/cached/source_map.css.map1
-rw-r--r--tests/staticfiles_tests/project/documents/cached/source_map_sensitive.css2
-rw-r--r--tests/staticfiles_tests/test_storage.py24
4 files changed, 29 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/project/documents/cached/source_map.css b/tests/staticfiles_tests/project/documents/cached/source_map.css
new file mode 100644
index 0000000000..dcd65da596
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/cached/source_map.css
@@ -0,0 +1,2 @@
+* {outline: 1px solid red;}
+/*# sourceMappingURL=source_map.css.map */
diff --git a/tests/staticfiles_tests/project/documents/cached/source_map.css.map b/tests/staticfiles_tests/project/documents/cached/source_map.css.map
new file mode 100644
index 0000000000..9e26dfeeb6
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/cached/source_map.css.map
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/tests/staticfiles_tests/project/documents/cached/source_map_sensitive.css b/tests/staticfiles_tests/project/documents/cached/source_map_sensitive.css
new file mode 100644
index 0000000000..a1b23bb316
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/cached/source_map_sensitive.css
@@ -0,0 +1,2 @@
+* {outline: 1px solid red;}
+/*# sOuRcEMaPpInGURL=source_map.css.map */
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py
index 41d98d4332..62484205b7 100644
--- a/tests/staticfiles_tests/test_storage.py
+++ b/tests/staticfiles_tests/test_storage.py
@@ -212,6 +212,30 @@ class TestHashedFiles:
self.assertIn(b"other.d41d8cd98f00.css", content)
self.assertPostCondition()
+ def test_css_source_map(self):
+ relpath = self.hashed_file_path('cached/source_map.css')
+ self.assertEqual(relpath, 'cached/source_map.b2fceaf426aa.css')
+ with storage.staticfiles_storage.open(relpath) as relfile:
+ content = relfile.read()
+ self.assertNotIn(b'/*# sourceMappingURL=source_map.css.map */', content)
+ self.assertIn(
+ b'/*# sourceMappingURL=source_map.css.99914b932bd3.map */',
+ content,
+ )
+ self.assertPostCondition()
+
+ def test_css_source_map_sensitive(self):
+ relpath = self.hashed_file_path('cached/source_map_sensitive.css')
+ self.assertEqual(relpath, 'cached/source_map_sensitive.456683f2106f.css')
+ with storage.staticfiles_storage.open(relpath) as relfile:
+ content = relfile.read()
+ self.assertIn(b'/*# sOuRcEMaPpInGURL=source_map.css.map */', content)
+ self.assertNotIn(
+ b'/*# sourceMappingURL=source_map.css.99914b932bd3.map */',
+ content,
+ )
+ self.assertPostCondition()
+
def test_js_source_map(self):
relpath = self.hashed_file_path('cached/source_map.js')
self.assertEqual(relpath, 'cached/source_map.cd45b8534a87.js')