From 0a3ef8b74bffc9b1cb6ef21695037d52aabd3ee1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?John=20Molakvo=C3=A6?= Date: Wed, 28 Dec 2022 19:08:54 +0100 Subject: [PATCH] Fixing tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/appinfo/routes.php | 14 +- apps/files/lib/Controller/ApiController.php | 2 +- apps/files/lib/Controller/ViewController.php | 14 +- apps/files/lib/Service/UserConfig.php | 11 +- .../tests/Controller/ApiControllerTest.php | 7 +- .../tests/Controller/ViewControllerTest.php | 24 +- apps/files/tests/js/appSpec.js | 244 ------------------ apps/files/tests/js/filelistSpec.js | 30 +-- apps/files/tests/js/filesummarySpec.js | 9 +- build/files-checker.php | 1 + 10 files changed, 56 insertions(+), 300 deletions(-) delete mode 100644 apps/files/tests/js/appSpec.js diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 0fc494d1173..60ba6afdf7a 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -39,6 +39,13 @@ namespace OCA\Files\AppInfo; use OCA\Files\Controller\OpenLocalEditorController; +// Legacy routes above +/** @var $this \OC\Route\Router */ +$this->create('files_ajax_download', 'apps/files/ajax/download.php') + ->actionInclude('files/ajax/download.php'); +$this->create('files_ajax_list', 'apps/files/ajax/list.php') + ->actionInclude('files/ajax/list.php'); + /** @var Application $application */ $application = \OC::$server->query(Application::class); $application->registerRoutes( @@ -207,10 +214,3 @@ $application->registerRoutes( ], ] ); - -/** @var $this \OC\Route\Router */ - -$this->create('files_ajax_download', 'apps/files/ajax/download.php') - ->actionInclude('files/ajax/download.php'); -$this->create('files_ajax_list', 'apps/files/ajax/list.php') - ->actionInclude('files/ajax/list.php'); diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 76597b7a018..f2329fc384b 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -289,7 +289,7 @@ class ApiController extends Controller { * @param string|bool $value * @return JSONResponse */ - public function setConfig(string $key, string|bool $value): JSONResponse { + public function setConfig(string $key, $value): JSONResponse { try { $this->userConfig->setConfig($key, (string)$value); } catch (\InvalidArgumentException $e) { diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 4e81b630bab..ea589807767 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -175,13 +175,13 @@ class ViewController extends Controller { */ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) { - // if ($fileid !== null && $dir === '') { - // try { - // return $this->redirectToFile($fileid); - // } catch (NotFoundException $e) { - // return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); - // } - // } + if ($fileid !== null && $dir === '') { + try { + return $this->redirectToFile($fileid); + } catch (NotFoundException $e) { + return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); + } + } $nav = new \OCP\Template('files', 'appnavigation', ''); diff --git a/apps/files/lib/Service/UserConfig.php b/apps/files/lib/Service/UserConfig.php index 7ccf7008512..3a498805910 100644 --- a/apps/files/lib/Service/UserConfig.php +++ b/apps/files/lib/Service/UserConfig.php @@ -42,8 +42,7 @@ class UserConfig { ]; protected IConfig $config; - /** @var \OCP\IUser|null */ - protected mixed $user = null; + protected ?IUser $user = null; public function __construct(IConfig $config, IUserSession $userSession) { $this->config = $config; @@ -81,7 +80,7 @@ class UserConfig { * @param string $key a valid config key * @return string|bool */ - private function getDefaultConfigValue(string $key): string|bool { + private function getDefaultConfigValue(string $key) { foreach (self::ALLOWED_CONFIGS as $config) { if ($config['key'] === $key) { return $config['default']; @@ -94,11 +93,11 @@ class UserConfig { * Set a user config * * @param string $key - * @param string $value + * @param string|bool $value * @throws \Exception * @throws \InvalidArgumentException */ - public function setConfig($key, $value) { + public function setConfig(string $key, $value): void { if ($this->user === null) { throw new \Exception('No user logged in'); } @@ -129,7 +128,7 @@ class UserConfig { } $userId = $this->user->getUID(); - $userConfigs = array_map(function(string $key) use ($userId): string|bool { + $userConfigs = array_map(function(string $key) use ($userId) { $value = $this->config->getUserValue($userId, Application::APP_ID, $key, $this->getDefaultConfigValue($key)); // If the default is expected to be a boolean, we need to cast the value if (is_bool($this->getDefaultConfigValue($key))) { diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php index 64c70fb2de6..6df3f46c5a9 100644 --- a/apps/files/tests/Controller/ApiControllerTest.php +++ b/apps/files/tests/Controller/ApiControllerTest.php @@ -28,6 +28,7 @@ namespace OCA\Files\Controller; use OCA\Files\Service\TagService; +use OCA\Files\Service\UserConfig; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\Files\File; @@ -67,6 +68,8 @@ class ApiControllerTest extends TestCase { private $config; /** @var Folder|\PHPUnit\Framework\MockObject\MockObject */ private $userFolder; + /** @var UserConfig|\PHPUnit\Framework\MockObject\MockObject */ + private $userConfig; protected function setUp(): void { parent::setUp(); @@ -95,6 +98,7 @@ class ApiControllerTest extends TestCase { $this->userFolder = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); + $this->userConfig = $this->createMock(UserConfig::class); $this->apiController = new ApiController( $this->appName, @@ -104,7 +108,8 @@ class ApiControllerTest extends TestCase { $this->preview, $this->shareManager, $this->config, - $this->userFolder + $this->userFolder, + $this->userConfig ); } diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index bd178ec1f44..a9aab4fbf4b 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -34,6 +34,7 @@ namespace OCA\Files\Tests\Controller; use OCA\Files\Activity\Helper; use OCA\Files\Controller\ViewController; +use OCA\Files\Service\UserConfig; use OCP\App\IAppManager; use OCP\AppFramework\Http; use OCP\AppFramework\Services\IInitialState; @@ -87,6 +88,8 @@ class ViewControllerTest extends TestCase { private $templateManager; /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */ private $shareManager; + /** @var UserConfig|\PHPUnit\Framework\MockObject\MockObject */ + private $userConfig; protected function setUp(): void { parent::setUp(); @@ -109,6 +112,7 @@ class ViewControllerTest extends TestCase { $this->initialState = $this->createMock(IInitialState::class); $this->templateManager = $this->createMock(ITemplateManager::class); $this->shareManager = $this->createMock(IManager::class); + $this->userConfig = $this->createMock(UserConfig::class); $this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController') ->setConstructorArgs([ 'files', @@ -124,6 +128,7 @@ class ViewControllerTest extends TestCase { $this->initialState, $this->templateManager, $this->shareManager, + $this->userConfig, ]) ->setMethods([ 'getStorageInfo', @@ -166,7 +171,6 @@ class ViewControllerTest extends TestCase { $nav->assign('usage', '123 B'); $nav->assign('quota', 100); $nav->assign('total_space', '100 B'); - $nav->assign('webdav_url', 'http://localhost/remote.php/dav/files/testuser1/'); $nav->assign('navigationItems', [ 'files' => [ 'id' => 'files', @@ -178,6 +182,7 @@ class ViewControllerTest extends TestCase { 'icon' => '', 'type' => 'link', 'classes' => '', + 'expanded' => false, 'unread' => 0, ], 'recent' => [ @@ -190,6 +195,7 @@ class ViewControllerTest extends TestCase { 'icon' => '', 'type' => 'link', 'classes' => '', + 'expanded' => false, 'unread' => 0, ], 'favorites' => [ @@ -211,8 +217,7 @@ class ViewControllerTest extends TestCase { 'order' => 6, 'folderPosition' => 1, 'name' => 'test1', - 'icon' => 'files', - 'quickaccesselement' => 'true', + 'icon' => 'folder', ], [ 'name' => 'test2', @@ -222,8 +227,7 @@ class ViewControllerTest extends TestCase { 'dir' => '/test2/', 'order' => 7, 'folderPosition' => 2, - 'icon' => 'files', - 'quickaccesselement' => 'true', + 'icon' => 'folder', ], [ 'name' => 'sub4', @@ -233,8 +237,7 @@ class ViewControllerTest extends TestCase { 'dir' => '/test3/sub4', 'order' => 8, 'folderPosition' => 3, - 'icon' => 'files', - 'quickaccesselement' => 'true', + 'icon' => 'folder', ], [ 'name' => 'sub6', @@ -244,8 +247,7 @@ class ViewControllerTest extends TestCase { 'dir' => '/test5/sub6/', 'order' => 9, 'folderPosition' => 4, - 'icon' => 'files', - 'quickaccesselement' => 'true', + 'icon' => 'folder', ], ], 'expanded' => false, @@ -261,6 +263,7 @@ class ViewControllerTest extends TestCase { 'icon' => '', 'type' => 'link', 'classes' => '', + 'expanded' => false, 'unread' => 0, ], 'trashbin' => [ @@ -273,6 +276,7 @@ class ViewControllerTest extends TestCase { 'icon' => '', 'type' => 'link', 'classes' => 'pinned', + 'expanded' => false, 'unread' => 0, ], 'shareoverview' => [ @@ -405,7 +409,7 @@ class ViewControllerTest extends TestCase { ], ], 'hiddenFields' => [], - 'showgridview' => false + 'showgridview' => null ] ); $policy = new Http\ContentSecurityPolicy(); diff --git a/apps/files/tests/js/appSpec.js b/apps/files/tests/js/appSpec.js deleted file mode 100644 index d5c793c4d24..00000000000 --- a/apps/files/tests/js/appSpec.js +++ /dev/null @@ -1,244 +0,0 @@ -/** -* @copyright 2014 Vincent Petry - * - * @author John Molakvoæ - * @author Vincent Petry - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -describe('OCA.Files.App tests', function() { - var App = OCA.Files.App; - var pushStateStub; - var replaceStateStub; - var parseUrlQueryStub; - - beforeEach(function() { - $('#testArea').append( - '
' + - '
' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' - ); - - OCA.Files.fileActions = new OCA.Files.FileActions(); - - pushStateStub = sinon.stub(OC.Util.History, 'pushState'); - replaceStateStub = sinon.stub(OC.Util.History, 'replaceState'); - parseUrlQueryStub = sinon.stub(OC.Util.History, 'parseUrlQuery'); - parseUrlQueryStub.returns({}); - - App.initialize(); - }); - afterEach(function() { - App.destroy(); - - pushStateStub.restore(); - replaceStateStub.restore(); - parseUrlQueryStub.restore(); - }); - - describe('initialization', function() { - it('initializes the default file list with the default file actions', function() { - expect(App.fileList).toBeDefined(); - expect(App.fileList.fileActions.actions.all).toBeDefined(); - expect(App.fileList.$el.is('#app-content-files')).toEqual(true); - }); - }); - - describe('URL handling', function() { - it('pushes the state to the URL when current app changed directory', function() { - $('#app-content-files').trigger(new $.Event('changeDirectory', {dir: 'sub dir'})); - expect(pushStateStub.calledOnce).toEqual(true); - var params = OC.parseQueryString(pushStateStub.getCall(0).args[0]); - expect(params.dir).toEqual('sub dir'); - expect(params.view).not.toBeDefined(); - - $('li[data-id=other]>a').click(); - pushStateStub.reset(); - - $('#app-content-other').trigger(new $.Event('changeDirectory', {dir: 'sub dir'})); - expect(pushStateStub.calledOnce).toEqual(true); - params = OC.parseQueryString(pushStateStub.getCall(0).args[0]); - expect(params.dir).toEqual('sub dir'); - expect(params.view).toEqual('other'); - }); - it('replaces the state to the URL when fileid is known', function() { - $('#app-content-files').trigger(new $.Event('changeDirectory', {dir: 'sub dir'})); - expect(pushStateStub.calledOnce).toEqual(true); - var params = OC.parseQueryString(pushStateStub.getCall(0).args[0]); - expect(params.dir).toEqual('sub dir'); - expect(params.view).not.toBeDefined(); - expect(replaceStateStub.notCalled).toEqual(true); - - parseUrlQueryStub.returns({dir: 'sub dir'}); - - $('#app-content-files').trigger(new $.Event('afterChangeDirectory', {dir: 'sub dir', fileId: 123})); - - expect(pushStateStub.calledOnce).toEqual(true); - expect(replaceStateStub.calledOnce).toEqual(true); - params = OC.parseQueryString(replaceStateStub.getCall(0).args[0]); - expect(params.dir).toEqual('sub dir'); - expect(params.view).not.toBeDefined(); - expect(params.fileid).toEqual('123'); - }); - describe('onpopstate', function() { - it('sends "urlChanged" event to current app', function() { - var handler = sinon.stub(); - $('#app-content-files').on('urlChanged', handler); - App._onPopState({view: 'files', dir: '/somedir'}); - expect(handler.calledOnce).toEqual(true); - expect(handler.getCall(0).args[0].view).toEqual('files'); - expect(handler.getCall(0).args[0].dir).toEqual('/somedir'); - }); - it('sends "show" event to current app and sets navigation', function() { - var showHandlerFiles = sinon.stub(); - var showHandlerOther = sinon.stub(); - var hideHandlerFiles = sinon.stub(); - var hideHandlerOther = sinon.stub(); - $('#app-content-files').on('show', showHandlerFiles); - $('#app-content-files').on('hide', hideHandlerFiles); - $('#app-content-other').on('show', showHandlerOther); - $('#app-content-other').on('hide', hideHandlerOther); - App._onPopState({view: 'other', dir: '/somedir'}); - expect(showHandlerFiles.notCalled).toEqual(true); - expect(hideHandlerFiles.calledOnce).toEqual(true); - expect(showHandlerOther.calledOnce).toEqual(true); - expect(hideHandlerOther.notCalled).toEqual(true); - - showHandlerFiles.reset(); - showHandlerOther.reset(); - hideHandlerFiles.reset(); - hideHandlerOther.reset(); - - App._onPopState({view: 'files', dir: '/somedir'}); - expect(showHandlerFiles.calledOnce).toEqual(true); - expect(hideHandlerFiles.notCalled).toEqual(true); - expect(showHandlerOther.notCalled).toEqual(true); - expect(hideHandlerOther.calledOnce).toEqual(true); - - expect(App.navigation.getActiveItem()).toEqual('files'); - expect($('#app-content-files').hasClass('hidden')).toEqual(false); - expect($('#app-content-other').hasClass('hidden')).toEqual(true); - }); - it('does not send "show" or "hide" event to current app when already visible', function() { - var showHandler = sinon.stub(); - var hideHandler = sinon.stub(); - $('#app-content-files').on('show', showHandler); - $('#app-content-files').on('hide', hideHandler); - App._onPopState({view: 'files', dir: '/somedir'}); - expect(showHandler.notCalled).toEqual(true); - expect(hideHandler.notCalled).toEqual(true); - }); - it('state defaults to files app with root dir', function() { - var handler = sinon.stub(); - parseUrlQueryStub.returns({}); - $('#app-content-files').on('urlChanged', handler); - App._onPopState(); - expect(handler.calledOnce).toEqual(true); - expect(handler.getCall(0).args[0].view).toEqual('files'); - expect(handler.getCall(0).args[0].dir).toEqual('/'); - }); - it('activates files app if invalid view is passed', function() { - App._onPopState({view: 'invalid', dir: '/somedir'}); - - expect(App.navigation.getActiveItem()).toEqual('files'); - expect($('#app-content-files').hasClass('hidden')).toEqual(false); - }); - }); - describe('navigation', function() { - it('switches the navigation item and panel visibility when onpopstate', function() { - App._onPopState({view: 'other', dir: '/somedir'}); - expect(App.navigation.getActiveItem()).toEqual('other'); - expect($('#app-content-files').hasClass('hidden')).toEqual(true); - expect($('#app-content-other').hasClass('hidden')).toEqual(false); - expect($('li[data-id=files] > a').hasClass('active')).toEqual(false); - expect($('li[data-id=other] > a').hasClass('active')).toEqual(true); - - App._onPopState({view: 'files', dir: '/somedir'}); - - expect(App.navigation.getActiveItem()).toEqual('files'); - expect($('#app-content-files').hasClass('hidden')).toEqual(false); - expect($('#app-content-other').hasClass('hidden')).toEqual(true); - expect($('li[data-id=files] > a').hasClass('active')).toEqual(true); - expect($('li[data-id=other] > a').hasClass('active')).toEqual(false); - }); - it('clicking on navigation switches the panel visibility', function() { - $('li[data-id=other] > a').click(); - expect(App.navigation.getActiveItem()).toEqual('other'); - expect($('#app-content-files').hasClass('hidden')).toEqual(true); - expect($('#app-content-other').hasClass('hidden')).toEqual(false); - expect($('li[data-id=files] > a').hasClass('active')).toEqual(false); - expect($('li[data-id=other] > a').hasClass('active')).toEqual(true); - - $('li[data-id=files] > a').click(); - expect(App.navigation.getActiveItem()).toEqual('files'); - expect($('#app-content-files').hasClass('hidden')).toEqual(false); - expect($('#app-content-other').hasClass('hidden')).toEqual(true); - expect($('li[data-id=files] > a').hasClass('active')).toEqual(true); - expect($('li[data-id=other] > a').hasClass('active')).toEqual(false); - }); - it('clicking on navigation sends "show" and "urlChanged" event', function() { - var handler = sinon.stub(); - var showHandler = sinon.stub(); - $('#app-content-other').on('urlChanged', handler); - $('#app-content-other').on('show', showHandler); - $('li[data-id=other] > a').click(); - expect(handler.calledOnce).toEqual(true); - expect(handler.getCall(0).args[0].view).toEqual('other'); - expect(handler.getCall(0).args[0].dir).toEqual('/'); - expect(showHandler.calledOnce).toEqual(true); - }); - it('clicking on activate navigation only sends "urlChanged" event', function() { - var handler = sinon.stub(); - var showHandler = sinon.stub(); - $('#app-content-files').on('urlChanged', handler); - $('#app-content-files').on('show', showHandler); - $('li[data-id=files] > a').click(); - expect(handler.calledOnce).toEqual(true); - expect(handler.getCall(0).args[0].view).toEqual('files'); - expect(handler.getCall(0).args[0].dir).toEqual('/'); - expect(showHandler.notCalled).toEqual(true); - }); - }); - describe('viewer mode', function() { - it('toggles the sidebar when viewer mode is enabled', function() { - $('#app-content-files').trigger( - new $.Event('changeViewerMode', {viewerModeEnabled: true} - )); - expect($('#app-navigation').hasClass('hidden')).toEqual(true); - expect($('.app-files').hasClass('viewer-mode no-sidebar')).toEqual(true); - - $('#app-content-files').trigger( - new $.Event('changeViewerMode', {viewerModeEnabled: false} - )); - - expect($('#app-navigation').hasClass('hidden')).toEqual(false); - expect($('.app-files').hasClass('viewer-mode no-sidebar')).toEqual(false); - }); - }); - }); -}); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index a302121ae0d..cd3510c2faa 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -515,9 +515,9 @@ describe('OCA.Files.FileList tests', function() { }); it('toggles the list\'s class when toggling hidden files', function() { expect(fileList.$el.hasClass('hide-hidden-files')).toEqual(false); - filesConfig.set('showhidden', false); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false }); expect(fileList.$el.hasClass('hide-hidden-files')).toEqual(true); - filesConfig.set('showhidden', true); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true }) expect(fileList.$el.hasClass('hide-hidden-files')).toEqual(false); }); }); @@ -1371,7 +1371,7 @@ describe('OCA.Files.FileList tests', function() { expect($('.files-fileList tr').length).toEqual(20); }); it('renders the full first page despite hidden rows', function() { - filesConfig.set('showhidden', false); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false }); var files = _.map(generateFiles(0, 23), function(data) { return _.extend(data, { name: '.' + data.name @@ -1385,7 +1385,7 @@ describe('OCA.Files.FileList tests', function() { expect($('.files-fileList tr').length).toEqual(25); }); it('renders the full first page despite hidden rows', function() { - filesConfig.set('showhidden', true); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true }); var files = _.map(generateFiles(0, 23), function(data) { return _.extend(data, { name: '.' + data.name @@ -1817,18 +1817,6 @@ describe('OCA.Files.FileList tests', function() { $('#app-content-files').trigger(new $.Event('urlChanged', {view: 'files', dir: '/somedir'})); expect(fileList.getCurrentDirectory()).toEqual('/somedir'); }); - it('reloads the list when leaving hidden state', function() { - var reloadStub = sinon.stub(fileList, 'reload'); - - // First show should not trigger - $('#app-content-files').trigger(new $.Event('show')); - expect(reloadStub.calledOnce).toEqual(false); - - // Second show should! - $('#app-content-files').trigger(new $.Event('show')); - expect(reloadStub.calledOnce).toEqual(true); - reloadStub.restore(); - }); it('refreshes breadcrumb after update', function() { var setDirSpy = sinon.spy(fileList.breadcrumb, 'setDirectory'); fileList.changeDirectory('/anothersubdir'); @@ -2014,7 +2002,7 @@ describe('OCA.Files.FileList tests', function() { expect($('.select-all').prop('checked')).toEqual(false); }); it('Selecting all files also selects hidden files when invisible', function() { - filesConfig.set('showhidden', false); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false }); var $tr = fileList.add(new FileInfo({ name: '.hidden', type: 'dir', @@ -2103,7 +2091,7 @@ describe('OCA.Files.FileList tests', function() { expect($summary.text()).toEqual('Name'); }); it('Displays the number of hidden files in selection summary if hidden files are invisible', function() { - filesConfig.set('showhidden', false); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false }); var $tr = fileList.add(new FileInfo({ name: '.hidden', type: 'dir', @@ -2115,7 +2103,7 @@ describe('OCA.Files.FileList tests', function() { expect($summary.text()).toEqual('2 folders and 3 files (including 1 hidden)'); }); it('Does not displays the number of hidden files in selection summary if hidden files are visible', function() { - filesConfig.set('showhidden', true); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true }); var $tr = fileList.add(new FileInfo({ name: '.hidden', type: 'dir', @@ -2127,7 +2115,7 @@ describe('OCA.Files.FileList tests', function() { expect($summary.text()).toEqual('2 folders and 3 files'); }); it('Toggling hidden file visibility updates selection summary', function() { - filesConfig.set('showhidden', false); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false }); var $tr = fileList.add(new FileInfo({ name: '.hidden', type: 'dir', @@ -2137,7 +2125,7 @@ describe('OCA.Files.FileList tests', function() { $('.select-all').click(); var $summary = $('.column-name a.name>span:first'); expect($summary.text()).toEqual('2 folders and 3 files (including 1 hidden)'); - filesConfig.set('showhidden', true); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true }); expect($summary.text()).toEqual('2 folders and 3 files'); }); it('Select/deselect files shows/hides file actions', function() { diff --git a/apps/files/tests/js/filesummarySpec.js b/apps/files/tests/js/filesummarySpec.js index 8692b8b14aa..8bc7bd8f995 100644 --- a/apps/files/tests/js/filesummarySpec.js +++ b/apps/files/tests/js/filesummarySpec.js @@ -204,7 +204,8 @@ describe('OCA.Files.FileSummary tests', function() { }); it('renders hidden count section when hidden files are hidden', function() { - config.set('showhidden', false); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false }); + summary.add({name: 'abc', type: 'file', size: 256000}); summary.add({name: 'def', type: 'dir', size: 100}); summary.add({name: '.hidden', type: 'dir', size: 512000}); @@ -217,7 +218,8 @@ describe('OCA.Files.FileSummary tests', function() { expect($container.find('.filesize').text()).toEqual('750 KB'); }); it('does not render hidden count section when hidden files exist but are visible', function() { - config.set('showhidden', true); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true }); + summary.add({name: 'abc', type: 'file', size: 256000}); summary.add({name: 'def', type: 'dir', size: 100}); summary.add({name: '.hidden', type: 'dir', size: 512000}); @@ -229,7 +231,8 @@ describe('OCA.Files.FileSummary tests', function() { expect($container.find('.filesize').text()).toEqual('750 KB'); }); it('does not render hidden count section when no hidden files exist', function() { - config.set('showhidden', false); + window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false }); + summary.add({name: 'abc', type: 'file', size: 256000}); summary.add({name: 'def', type: 'dir', size: 100}); summary.update(); diff --git a/build/files-checker.php b/build/files-checker.php index 23c089c591a..30927718811 100644 --- a/build/files-checker.php +++ b/build/files-checker.php @@ -93,6 +93,7 @@ $expectedFiles = [ 'tsconfig.json', 'vendor-bin', 'version.php', + 'webpack.common.js', 'webpack.config.js', 'webpack.modules.js', ]; -- 2.39.5