
| Current Path : /var/www/html/store/web/core/modules/ckeditor5/tests/src/FunctionalJavascript/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/store/web/core/modules/ckeditor5/tests/src/FunctionalJavascript/JSTranslationTest.php |
<?php
declare(strict_types = 1);
namespace Drupal\Tests\ckeditor5\FunctionalJavascript;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\media\Traits\MediaTypeCreationTrait;
/**
* Tests for CKEditor 5 plugins using Drupal's translation system.
*
* @group ckeditor5
* @internal
*/
class JSTranslationTest extends CKEditor5TestBase {
use MediaTypeCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'language',
'locale',
'media_library',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Create a sample media entity to be embedded.
$this->createMediaType('image', ['id' => 'image', 'label' => 'Image']);
}
/**
* Integration test to ensure that CKEditor 5 Plugins translations are loaded.
*/
public function test(): void {
$page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
$this->createNewTextFormat($page, $assert_session);
$this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-drupalMedia'));
$this->click('#edit-filters-media-embed-status');
$assert_session->assertWaitOnAjaxRequest();
$this->triggerKeyUp('.ckeditor5-toolbar-item-drupalMedia', 'ArrowDown');
$assert_session->assertWaitOnAjaxRequest();
$this->saveNewTextFormat($page, $assert_session);
$langcode = 'fr';
ConfigurableLanguage::createFromLangcode($langcode)->save();
$this->config('system.site')->set('default_langcode', $langcode)->save();
// Visit a page that will trigger a JavaScript file parsing for
// translatable strings.
$this->drupalGet('node/add');
$this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
// Ensure a string from the CKEditor 5 plugin is picked up by translation.
// @see core/modules/ckeditor5/js/ckeditor5_plugins/drupalMedia/src/drupalmediatoolbar.js
$locale_storage = $this->container->get('locale.storage');
$string = $locale_storage->findString(['source' => 'Drupal Media toolbar', 'context' => '']);
$this->assertNotEmpty($string, 'String from JavaScript file saved.');
}
}