Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Application extends App implements IBootstrap {
/** @psalm-suppress PossiblyUnusedMethod */
public function __construct() {
parent::__construct(self::APP_ID);
\OCP\Util::addScript('files', 'search');
}

public function register(IRegistrationContext $context): void {
Expand Down
2 changes: 2 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public function index(): TemplateResponse {
$this->getCustomClientURL()
);

Util::addScript('files', 'search');

return new TemplateResponse(
Application::APP_ID,
'index',
Expand Down
30 changes: 30 additions & 0 deletions tests/Controller/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ protected function setUp(): void {
$this->l10nFactory->expects($this->atMost(1))
->method('getLanguages')
->willReturn($this->mockAvailableLanguages);

$this->resetUtilState();
}

protected function tearDown(): void {
$this->resetUtilState();
parent::tearDown();
}

/**
* Reset Util script and style state for clean test isolation
*/
private function resetUtilState(): void {
\OC_Util::$scripts = [];
\OC_Util::$styles = [];
self::invokePrivate(\OCP\Util::class, 'scripts', [[]]);
self::invokePrivate(\OCP\Util::class, 'scriptDeps', [[]]);
}

/**
Expand Down Expand Up @@ -395,4 +412,17 @@ public function testIndexProvidesInitialStateWithCustomClientURLs() {

$this->controller->index();
}

public function testFileSearchScriptInjection(): void {
$scripts = Util::getScripts();

$this->assertNotContains('files/js/search', $scripts, 'File search script should NOT be injected');

$this->controller->index();

$scripts = Util::getScripts();

$this->assertContains('files/l10n/en', $scripts, 'File search script i18n should be injected');
$this->assertContains('files/js/search', $scripts, 'File search script should be injected');
}
}
Loading