Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWPP-4693: Allow 'mark' tag for page header introduction field. #1496

Merged
merged 2 commits into from
Sep 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function getIntroductionMetadata(string $field_name): array {
// We strip the tags because the ECL component expects only one paragraph
// of text and the field is using a text format which adds paragraph tags.
'#type' => 'inline_template',
'#template' => '{{ summary|render|striptags("<strong><a><em><svg><use><span><sub><sup><u>")|raw }}',
'#template' => '{{ summary|render|striptags("<strong><a><em><svg><use><span><sub><sup><u><mark>")|raw }}',
'#context' => [
'summary' => [
'#type' => 'processed_text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Drupal\Tests\oe_theme_helper\Functional;

use Drupal\filter\Entity\FilterFormat;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;

Expand Down Expand Up @@ -68,18 +69,26 @@ public function setUp(): void {
'view latest version',
'view any unpublished content',
]);

FilterFormat::create([
22Alexandra marked this conversation as resolved.
Show resolved Hide resolved
'format' => 'full_html',
'name' => 'Full HTML',
])->save();
}

/**
* Tests that the correct metadata is retrieved on node view routes.
*/
public function testNodeRoutes(): void {
// Create a published revision for a node.
$published_revision_body = $this->randomString();
$published_revision_body = '<u>Custom page</u> introduction with <sub>rich</sub><sup>text</sup><mark>highlighted</mark>.';
22Alexandra marked this conversation as resolved.
Show resolved Hide resolved
$node = $this->drupalCreateNode([
'type' => 'test',
'moderation_state' => 'published',
'body' => $published_revision_body,
'body' => [
'value' => $published_revision_body,
'format' => 'full_html',
],
]);
// Save the revision url for later access.
$first_revision_url = $node->toUrl('revision');
Expand All @@ -95,7 +104,7 @@ public function testNodeRoutes(): void {
// Verify that the page header block is shown in the node canonical route
// and contains the correct revision text.
$this->drupalGet($node->toUrl());
$this->assertSession()->elementTextContains('css', '.ecl-page-header__description', $published_revision_body);
$this->assertEquals($published_revision_body, $this->getSession()->getPage()->find('css', '.ecl-page-header__description')->getHtml());

// Verify that the block is also shown in the latest version route with the
// correct draft revision loaded.
Expand All @@ -104,7 +113,7 @@ public function testNodeRoutes(): void {

// Verify also for the node single revision route.
$this->drupalGet($first_revision_url);
$this->assertSession()->elementTextContains('css', '.ecl-page-header__description', $published_revision_body);
$this->assertEquals($published_revision_body, $this->getSession()->getPage()->find('css', '.ecl-page-header__description')->getHtml());
}

}