Browse Source

test: fix test failure by allowing preview only for non-special mime types

Assisted-By: Copilot <copilot@github.com>
rugk 1 tuần trước cách đây
mục cha
commit
eeee4ef8b8
1 tập tin đã thay đổi với 10 bổ sung11 xóa
  1. 10 11
      js/test/AttachmentViewer.js

+ 10 - 11
js/test/AttachmentViewer.js

@@ -38,7 +38,7 @@ describe('AttachmentViewer', function () {
                             mimePrefix === 'audio/' ||
                             mimePrefix === 'video/' ||
                             mimeType.match(/\/pdf/i)
-                        ),
+                        ) && mimeType.match(/^[a-z0-9][a-z0-9.-]*[a-z0-9]\/[a-z0-9][a-z0-9.+-]*[a-z0-9]$/),
                         results = [],
                         result = '';
                     // text node of attachment will truncate at null byte
@@ -279,16 +279,15 @@ describe('AttachmentViewer', function () {
     });
 
     function mockCreateObjectUrl(includeType = true) {
-        if (typeof window.URL.createObjectURL === 'undefined') {
-            Object.defineProperty(
-                window.URL,
-                'createObjectURL',
-                {
-                    value: function (blob) {
-                        return 'blob:' + (includeType ? blob.type : location.origin) + '/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed';;
-                    }
+        Object.defineProperty(
+            window.URL,
+            'createObjectURL',
+            {
+                configurable: true,
+                value: function (blob) {
+                    return 'blob:' + (includeType ? blob.type : location.origin) + '/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed';
                 }
-            );
-        }
+            }
+        );
     }
 });