]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files): Adjust files list jsunit tests for file size bugfix 40638/head
authorFerdinand Thiessen <opensource@fthiessen.de>
Tue, 26 Sep 2023 11:06:02 +0000 (13:06 +0200)
committerFerdinand Thiessen <opensource@fthiessen.de>
Tue, 26 Sep 2023 11:06:02 +0000 (13:06 +0200)
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
apps/files/tests/js/fileUploadSpec.js
apps/files/tests/js/filelistSpec.js
apps/files/tests/js/filesummarySpec.js
apps/files/tests/js/mainfileinfodetailviewSpec.js

index e15514b39e2246275f08ac60b83363f106e89af6..fa7ee1f5d074794baf7b95c1e0ffcc8f3901a31b 100644 (file)
@@ -113,7 +113,7 @@ describe('OC.Upload tests', function() {
                });
                it('does not add file if it exceeds free space', function(done) {
                        var result;
-                       $('#free_space').val(1000);
+                       $('#free_space').val(1024);
 
                        failStub.callsFake(function(){
                                expect(failStub.calledOnce).toEqual(true);
index b7f9fb2ff39d21436d218cf371153dd930d03eeb..3d80591fd144374c563558bb09c942dab29cc407 100644 (file)
@@ -539,7 +539,7 @@ describe('OCA.Files.FileList tests', function() {
                        expect($summary.find('.fileinfo').text()).toEqual('2 files');
                        expect($summary.find('.dirinfo').hasClass('hidden')).toEqual(false);
                        expect($summary.find('.fileinfo').hasClass('hidden')).toEqual(false);
-                       expect($summary.find('.filesize').text()).toEqual('70 KB');
+                       expect($summary.find('.filesize').text()).toEqual('69 KB');
                        expect(fileList.isEmpty).toEqual(false);
                });
                it('Shows empty content when removing last file', function() {
@@ -609,7 +609,7 @@ describe('OCA.Files.FileList tests', function() {
                                expect($summary.find('.fileinfo').text()).toEqual('1 file');
                                expect($summary.find('.dirinfo').hasClass('hidden')).toEqual(false);
                                expect($summary.find('.fileinfo').hasClass('hidden')).toEqual(false);
-                               expect($summary.find('.filesize').text()).toEqual('58 KB');
+                               expect($summary.find('.filesize').text()).toEqual('57 KB');
                                expect(fileList.isEmpty).toEqual(false);
                                expect($('.files-filestable thead th').hasClass('hidden')).toEqual(false);
                                expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(true);
@@ -1138,7 +1138,7 @@ describe('OCA.Files.FileList tests', function() {
                        expect($summary.hasClass('hidden')).toEqual(false);
                        expect($summary.find('.dirinfo').text()).toEqual('1 folder');
                        expect($summary.find('.fileinfo').text()).toEqual('3 files');
-                       expect($summary.find('.filesize').text()).toEqual('70 KB');
+                       expect($summary.find('.filesize').text()).toEqual('69 KB');
                });
                it('shows headers, summary and hide empty content message after setting files', function(){
                        fileList.setFiles(testFiles);
index 22c95abd30772e97378dfd04a0a6ae6eab5062d8..03f39304a8919739bcc31578759026cc9d50cc5b 100644 (file)
@@ -39,7 +39,7 @@ describe('OCA.Files.FileSummary tests', function() {
                s.setSummary({
                        totalDirs: 5,
                        totalFiles: 2,
-                       totalSize: 256000
+                       totalSize: 256*1024,
                });
                expect($container.hasClass('hidden')).toEqual(false);
                expect($container.find('.dirinfo').text()).toEqual('5 folders');
@@ -60,9 +60,9 @@ describe('OCA.Files.FileSummary tests', function() {
                s.setSummary({
                        totalDirs: 5,
                        totalFiles: 2,
-                       totalSize: 256000
+                       totalSize: 256*1024
                });
-               s.add({type: 'file', size: 256000});
+               s.add({type: 'file', size: 256*1024});
                s.add({type: 'dir', size: 100});
                s.update();
                expect($container.hasClass('hidden')).toEqual(false);
@@ -71,16 +71,16 @@ describe('OCA.Files.FileSummary tests', function() {
                expect($container.find('.filesize').text()).toEqual('512 KB');
                expect(s.summary.totalDirs).toEqual(6);
                expect(s.summary.totalFiles).toEqual(3);
-               expect(s.summary.totalSize).toEqual(512100);
+               expect(s.summary.totalSize).toEqual(512*1024 + 100);
        });
        it('decreases summary when removing files', function() {
                var s = new FileSummary($container);
                s.setSummary({
                        totalDirs: 5,
                        totalFiles: 2,
-                       totalSize: 256000
+                       totalSize: 256*1024
                });
-               s.remove({type: 'file', size: 128000});
+               s.remove({type: 'file', size: 128*1024});
                s.remove({type: 'dir', size: 100});
                s.update();
                expect($container.hasClass('hidden')).toEqual(false);
@@ -89,7 +89,7 @@ describe('OCA.Files.FileSummary tests', function() {
                expect($container.find('.filesize').text()).toEqual('128 KB');
                expect(s.summary.totalDirs).toEqual(4);
                expect(s.summary.totalFiles).toEqual(1);
-               expect(s.summary.totalSize).toEqual(127900);
+               expect(s.summary.totalSize).toEqual(128*1024 - 100);
        });
 
        it('renders filtered summary as text', function() {
@@ -97,7 +97,7 @@ describe('OCA.Files.FileSummary tests', function() {
                s.setSummary({
                        totalDirs: 5,
                        totalFiles: 2,
-                       totalSize: 256000,
+                       totalSize: 256*1024,
                        filter: 'foo'
                });
                expect($container.hasClass('hidden')).toEqual(false);
@@ -121,11 +121,11 @@ describe('OCA.Files.FileSummary tests', function() {
                s.setSummary({
                        totalDirs: 5,
                        totalFiles: 2,
-                       totalSize: 256000,
+                       totalSize: 256*1024,
                        filter: 'foo'
                });
-               s.add({name: 'bar.txt', type: 'file', size: 256000});
-               s.add({name: 'foo.txt', type: 'file', size: 256001});
+               s.add({name: 'bar.txt', type: 'file', size: 256*1024});
+               s.add({name: 'foo.txt', type: 'file', size: 256*1024 + 1});
                s.add({name: 'bar', type: 'dir', size: 100});
                s.add({name: 'foo', type: 'dir', size: 102});
                s.update();
@@ -136,18 +136,18 @@ describe('OCA.Files.FileSummary tests', function() {
                expect($container.find('.filesize').text()).toEqual('512 KB');
                expect(s.summary.totalDirs).toEqual(6);
                expect(s.summary.totalFiles).toEqual(3);
-               expect(s.summary.totalSize).toEqual(512103);
+               expect(s.summary.totalSize).toEqual(512*1024 + 1 + 102);
        });
        it('decreases filtered summary when removing files', function() {
                var s = new FileSummary($container);
                s.setSummary({
                        totalDirs: 5,
                        totalFiles: 2,
-                       totalSize: 256000,
+                       totalSize: 256*1024,
                        filter: 'foo'
                });
-               s.remove({name: 'bar.txt', type: 'file', size: 128000});
-               s.remove({name: 'foo.txt', type: 'file', size: 127999});
+               s.remove({name: 'bar.txt', type: 'file', size: 128*1024});
+               s.remove({name: 'foo.txt', type: 'file', size: 128*1024 - 1});
                s.remove({name: 'bar', type: 'dir', size: 100});
                s.remove({name: 'foo', type: 'dir', size: 98});
                s.update();
@@ -158,7 +158,7 @@ describe('OCA.Files.FileSummary tests', function() {
                expect($container.find('.filesize').text()).toEqual('128 KB');
                expect(s.summary.totalDirs).toEqual(4);
                expect(s.summary.totalFiles).toEqual(1);
-               expect(s.summary.totalSize).toEqual(127903);
+               expect(s.summary.totalSize).toEqual(256*1024 - (128*1024 - 1) - 98);
        });
        it('properly sum up pending folder sizes after adding', function() {
                var s = new FileSummary($container);
@@ -206,9 +206,9 @@ describe('OCA.Files.FileSummary tests', function() {
                it('renders hidden count section when hidden files are hidden', function() {
                        window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false });
 
-                       summary.add({name: 'abc', type: 'file', size: 256000});
+                       summary.add({name: 'abc', type: 'file', size: 256*1024});
                        summary.add({name: 'def', type: 'dir', size: 100});
-                       summary.add({name: '.hidden', type: 'dir', size: 512000});
+                       summary.add({name: '.hidden', type: 'dir', size: 512*1024});
                        summary.update();
                        expect($container.hasClass('hidden')).toEqual(false);
                        expect($container.find('.dirinfo').text()).toEqual('2 folders');
@@ -220,9 +220,9 @@ describe('OCA.Files.FileSummary tests', function() {
                it('does not render hidden count section when hidden files exist but are visible', function() {
                        window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true });
 
-                       summary.add({name: 'abc', type: 'file', size: 256000});
+                       summary.add({name: 'abc', type: 'file', size: 256*1024});
                        summary.add({name: 'def', type: 'dir', size: 100});
-                       summary.add({name: '.hidden', type: 'dir', size: 512000});
+                       summary.add({name: '.hidden', type: 'dir', size: 512*1024});
                        summary.update();
                        expect($container.hasClass('hidden')).toEqual(false);
                        expect($container.find('.dirinfo').text()).toEqual('2 folders');
@@ -233,7 +233,7 @@ describe('OCA.Files.FileSummary tests', function() {
                it('does not render hidden count section when no hidden files exist', function() {
                        window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false });
 
-                       summary.add({name: 'abc', type: 'file', size: 256000});
+                       summary.add({name: 'abc', type: 'file', size: 256*1024});
                        summary.add({name: 'def', type: 'dir', size: 100});
                        summary.update();
                        expect($container.hasClass('hidden')).toEqual(false);
index b63c36199a662b2855dc6654c7dcbaeeef157aa4..5793db8fb98d5f400a8ec2f48c8c8af3b06924e5 100644 (file)
@@ -62,7 +62,7 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
                        view.setFileInfo(testFileInfo);
                        expect(view.$el.find('.fileName h3').text()).toEqual('One.txt');
                        expect(view.$el.find('.fileName h3').attr('title')).toEqual('One.txt');
-                       expect(view.$el.find('.size').text()).toEqual('123.5 MB');
+                       expect(view.$el.find('.size').text()).toEqual('117.7 MB');
                        expect(view.$el.find('.size').attr('title')).toEqual('123456789 bytes');
                        expect(view.$el.find('.date').text()).toEqual('seconds ago');
                        expect(view.$el.find('.date').attr('title')).toEqual(dateExpected);