public function ClaroLayoutBuilderTest::testContextualLinks in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/FunctionalTests/Theme/ClaroLayoutBuilderTest.php \Drupal\FunctionalTests\Theme\ClaroLayoutBuilderTest::testContextualLinks()
- 10 core/tests/Drupal/FunctionalTests/Theme/ClaroLayoutBuilderTest.php \Drupal\FunctionalTests\Theme\ClaroLayoutBuilderTest::testContextualLinks()
Tests the layout builder has expected contextual links with Claro.
See also
File
- core/
tests/ Drupal/ FunctionalTests/ Theme/ ClaroLayoutBuilderTest.php, line 71
Class
- ClaroLayoutBuilderTest
- Tests the layout builder with the Claro theme.
Namespace
Drupal\FunctionalTests\ThemeCode
public function testContextualLinks() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer node fields',
'access contextual links',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// From the manage display page, go to manage the layout.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$assert_session
->linkNotExists('Manage layout');
$assert_session
->fieldDisabled('layout[allow_custom]');
$this
->drupalPostForm(NULL, [
'layout[enabled]' => TRUE,
], 'Save');
$assert_session
->linkExists('Manage layout');
$this
->clickLink('Manage layout');
// Add a new block.
$assert_session
->linkExists('Add block');
$this
->clickLink('Add block');
$assert_session
->linkExists('Powered by Drupal');
$this
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is the label');
$page
->checkField('settings[label_display]');
$page
->pressButton('Add block');
// Test that the block has the contextual class applied and the container
// for contextual links.
$assert_session
->elementExists('css', 'div.block-system-powered-by-block.contextual-region div[data-contextual-id]');
// Ensure other blocks do not have contextual links.
$assert_session
->elementExists('css', 'div.block-page-title-block');
$assert_session
->elementNotExists('css', 'div.block-page-title-block.contextual-region div[data-contextual-id]');
}