Theme Modules: Added easier way to insert HTML head content

This commit is contained in:
Dan Brown
2026-03-08 10:26:00 +00:00
parent 27240be499
commit 151823b84e
5 changed files with 57 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
namespace Tests\Theme;
use BookStack\Facades\Theme;
use BookStack\Util\CspService;
use Tests\TestCase;
class ThemeModuleTest extends TestCase
@@ -220,6 +221,23 @@ class ThemeModuleTest extends TestCase
});
}
public function test_module_can_provide_head_content()
{
$this->usingModuleFolder(function (string $moduleFolderPath) {
mkdir($moduleFolderPath . '/head', 0777, true);
file_put_contents($moduleFolderPath . '/head/hello.html', '<meta name="beans" content="hello"><script>hellofromcustomscript</script>');
$this->refreshApplication();
$cspService = $this->app->make(CspService::class);
$nonce = $cspService->getNonce();
$resp = $this->asAdmin()->get('/');
$resp->assertSee('<meta name="beans" content="hello">', false);
$resp->assertSee('<script nonce="' . $nonce . '">hellofromcustomscript</script>', false);
});
}
protected function usingModuleFolder(callable $callback): void
{
$this->usingThemeFolder(function (string $themeFolder) use ($callback) {