Commit e0df42f4 authored by Liam Morland's avatar Liam Morland Committed by Igor Biki
Browse files

RT-1184659: Test that when related links have a title it is the link text

parent 77843117
......@@ -1221,31 +1221,36 @@ class UwWcmsBasicTest extends BrowserTestBase {
break;
case 'Related links':
// Add a second link.
// Add a second and third link.
$this->click('#edit-settings-block-form-field-uw-rl-related-link-add-more');
$this->click('#edit-settings-block-form-field-uw-rl-related-link-add-more');
// Create Related links block.
$edit = [
'edit-settings-label' => $this->randomString(),
// Internal link.
// Internal link with title.
'edit-settings-block-form-field-uw-rl-related-link-0-uri' => 'entity:node/1',
'edit-settings-block-form-field-uw-rl-related-link-0-title' => 'should-not-appear--uses-node-title',
'edit-settings-block-form-field-uw-rl-related-link-0-title' => $this->randomMachineName(),
// External link.
'edit-settings-block-form-field-uw-rl-related-link-1-uri' => 'https://www.sju.ca/',
// This needs to use randomMachineName() so that it has not
// double-quotes, which cannot be in XPath.
'edit-settings-block-form-field-uw-rl-related-link-1-title' => $this->randomMachineName(),
// Internal link without title.
'edit-settings-block-form-field-uw-rl-related-link-2-uri' => 'entity:node/1',
];
$this->submitForm($edit, 'Add block');
// Test that the Related links block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
// Internal link.
// Prefix used in related links XPath.
$xpath_prefix = '//div[contains(@class, "block-inline-blockuw-cbl-related-links")]/div[@class="item-list"]/ul/li';
$this->assertTrue((bool) $this->xpath($xpath_prefix . '/a[@href="' . base_path() . 'home" and text()="Home"]'));
$this->assertSession()->pageTextNotContains($edit['edit-settings-block-form-field-uw-rl-related-link-0-title']);
// Internal link with title.
$this->assertTrue((bool) $this->xpath($xpath_prefix . '/a[@href="' . base_path() . 'home" and text()="' . $edit['edit-settings-block-form-field-uw-rl-related-link-0-title'] . '"]'));
// External link.
$this->assertTrue((bool) $this->xpath($xpath_prefix . '/a[@href="' . $edit['edit-settings-block-form-field-uw-rl-related-link-1-uri'] . '" and text()="' . $edit['edit-settings-block-form-field-uw-rl-related-link-1-title'] . '"]'));
// Internal link without title.
$this->assertTrue((bool) $this->xpath($xpath_prefix . '/a[@href="' . base_path() . 'home" and text()="Home"]'));
unset($xpath_prefix);
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment