3 namespace Drupal\Tests\content_translation\FunctionalJavascript;
5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
6 use Drupal\language\Entity\ConfigurableLanguage;
9 * Tests that contextual links are available for content translation.
11 * @group content_translation
13 class ContentTranslationContextualLinksTest extends WebDriverTestBase {
16 * The 'translator' user to use during testing.
18 * @var \Drupal\user\UserInterface
20 protected $translator;
25 public static $modules = ['content_translation', 'contextual', 'node'];
30 protected function setUp() {
33 // Set up an additional language.
34 ConfigurableLanguage::createFromLangcode('es')->save();
36 // Create a content type.
37 $this->drupalCreateContentType(['type' => 'page']);
39 // Enable content translation.
40 $this->drupalLogin($this->rootUser);
41 $this->drupalGet('admin/config/regional/content-language');
43 'entity_types[node]' => TRUE,
44 'settings[node][page][translatable]' => TRUE,
46 $this->drupalPostForm(NULL, $edit, t('Save configuration'));
47 $this->drupalLogout();
49 // Create a translator user.
51 'access contextual links',
53 'edit any page content',
54 'translate any entity',
56 $this->translator = $this->drupalCreateUser($permissions);
60 * Tests that a contextual link is available for translating a node.
62 public function testContentTranslationContextualLinks() {
63 $node = $this->drupalCreateNode(['type' => 'page', 'title' => 'Test']);
65 // Check that the translate link appears on the node page.
66 $this->drupalLogin($this->translator);
67 $this->drupalGet('node/' . $node->id());
68 $link = $this->assertSession()->waitForElement('css', '[data-contextual-id^="node:node=1"] .contextual-links a:contains("Translate")');
69 $this->assertContains('node/1/translations', $link->getAttribute('href'));