[(object) ['iso' => 'en']],
'attributes' => (object) [
'en' => (object) [
'content' => '<a href="#">Link</a>',
'html_code' => null,
],
],
'decodeHtml' => $decodeHtml,
'defaultLanguageContent' => $defaultLanguageContent,
])->render();
expect($html)->toContain('"#"');
expect($html)->not->toContain('"#"');
});
it('normalizes encoded html before persisting a block', function () {
$controller = app(BlockController::class);
$reflection = new ReflectionMethod($controller, 'normalizePrevodPayload');
$reflection->setAccessible(true);
$normalized = $reflection->invoke($controller, [
'en' => [
'content' => '<a href="#">Link</a>',
],
]);
expect($normalized['en']['content'])->toBe('Link');
});
it('renders frontend language tabs in the block editor', function () {
View::addNamespace('plugin.block', base_path('packages/klevze/Plugins/Blocks/Resources/views'));
ActiveLanguage::shouldReceive('getList')
->once()
->with('fp')
->andReturn(collect([
(object) ['iso' => 'en', 'name' => 'English'],
(object) ['iso' => 'sl', 'name' => 'Slovenian'],
]));
$html = view('plugin.block::form.translation', [
'languages' => [(object) ['iso' => 'en']],
'attributes' => (object) [
'en' => (object) ['content' => '', 'html_code' => null],
],
'decodeHtml' => fn ($value) => (string) $value,
'defaultLanguageContent' => '',
])->render();
expect($html)->toContain('nav nav-tabs');
expect($html)->toContain('English');
expect($html)->toContain('Slovenian');
});
it('preserves iframe query parameters while removing actual event attributes', function () {
$html = '';
$sanitized = SecurityHelper::sanitizeInput($html);
expect($sanitized)->toContain('responsive=true');
expect($sanitized)->not->toContain('resptrue');
expect($sanitized)->not->toContain('onload=');
});