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-3635: Patch core to render internal links' title. #1440

Merged
merged 2 commits into from
Jun 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
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
"build/themes/contrib/{$name}": ["type:drupal-theme"]
},
"patches": {
"drupal/core": {
"https://www.drupal.org/project/drupal/issues/3151609": "https://www.drupal.org/files/issues/2023-12-11/link_internal_as_text_v10-3151609_0.patch"
},
"drupal/drupal-driver": {
"allow-date-only-date-fields": "https://patch-diff.githubusercontent.com/raw/jhedstrom/DrupalDriver/pull/235.patch"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% include '@ecl-twig/link' with {
link: {
type: 'standalone',
label: item.content['#url'].toString(),
label: (item.content['#title'] is defined) ? item.content['#title'] : item.content['#url'].toString(),
path: item.content['#url'],
external: item.content['#url'].toString()|is_external_url,
icon_path: ecl_icon_path
Expand Down
28 changes: 28 additions & 0 deletions tests/src/Functional/ContentProjectRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Drupal\Tests\oe_theme\Functional;

use Behat\Mink\Element\NodeElement;
use Drupal\node\Entity\Node;
use Drupal\oe_content_entity\Entity\CorporateEntityInterface;
use Drupal\oe_content_entity_organisation\Entity\OrganisationInterface;
use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert;
Expand Down Expand Up @@ -272,6 +273,33 @@ public function testProjectRendering(): void {
$this->assertCount(1, $stakeholder_sub_headers);
$this->assertEquals($stakeholder_sub_headers[0]->getText(), 'Coordinators');
$this->assertStakeholderOrganisationRendering($project_stakeholders, 'coordinator');
// Create a node to be used as website reference.
Node::create([
'type' => 'oe_page',
'title' => 'Test page node',
'body' => 'Body',
'oe_subject' => 'http://data.europa.eu/uxp/1000',
'oe_author' => 'http://publications.europa.eu/resource/authority/corporate-body/COMMU',
'oe_content_content_owner' => 'http://publications.europa.eu/resource/authority/corporate-body/COMMU',
])->save();
$coordinator_organisation->set('oe_website', ['uri' => 'internal:/node/2'])->save();
$this->drupalGet($node->toUrl());

$field_list_assert = new FieldListAssert();
$first_field_list_expected_values = [
'items' => [
[
'label' => 'Address',
'body' => 'Address coordinator, 1001 Brussels, Belgium',
], [
'label' => 'Website',
'body' => 'Test page node',
],
],
];
$field_list_wrapper = $project_stakeholders->find('css', '.ecl-u-flex-grow-1.ecl-u-type-color-dark');
$field_list_html = $field_list_wrapper->getHtml();
$field_list_assert->assertPattern($first_field_list_expected_values, $field_list_html);

// Load logo that is unpublished and assert that is not rendered.
$media = $this->getStorage('media')->loadByProperties(['name' => 'Test image coordinator']);
Expand Down
34 changes: 34 additions & 0 deletions tests/src/Kernel/ContactRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Drupal\Tests\oe_theme\Kernel;

use Drupal\node\Entity\Node;
use Drupal\oe_content_entity\Entity\CorporateEntityInterface;
use Drupal\oe_content_entity_contact\Entity\ContactInterface;
use Drupal\Tests\oe_theme\PatternAssertions\FieldListAssert;
Expand Down Expand Up @@ -96,6 +97,39 @@ public function testFullView(): void {
];
$field_list_assert->assertPattern($expected_values, $this->renderRoot($build));

// Create a page node with a translation.
$node = Node::create([
'type' => 'oe_page',
'title' => 'Test page node',
'body' => 'Body',
'oe_subject' => 'http://data.europa.eu/uxp/1000',
'oe_author' => 'http://publications.europa.eu/resource/authority/corporate-body/COMMU',
'oe_content_content_owner' => 'http://publications.europa.eu/resource/authority/corporate-body/COMMU',
]);
$node->save();
$node->addTranslation('bg', ['title' => 'Test page node bg']);
$node->save();

// Add the node as Website and assert its title.
$contact->addTranslation('bg', ['name' => "$name bg"]);
$contact->set('oe_website', ['uri' => 'internal:/node/1'])->save();
$build = $this->contactViewBuilder->view($contact, 'full');
$expected_values['items'][1] = [
'label' => 'Website',
'body' => 'Test page node',
];
// Assert bulgarian translation.
$build = $this->contactViewBuilder->view($contact, 'full', 'bg');
$expected_values['items'][1] = [
'label' => 'Website',
'body' => 'Test page node bg',
];
// Reset the array website value to english value.
$expected_values['items'][1] = [
'label' => 'Website',
'body' => 'Test page node',
];

// Add and assert Email field.
$contact->set('oe_email', "$name@example.com")->save();
$build = $this->contactViewBuilder->view($contact, 'full');
Expand Down