public function ComponentAttributeTest::testAllowedAttributes in Layout Builder Component Attributes 1.1.x
Same name and namespace in other branches
- 1.2.x tests/src/FunctionalJavascript/ComponentAttributeTest.php \Drupal\Tests\layout_builder_component_attributes\FunctionalJavascript\ComponentAttributeTest::testAllowedAttributes()
- 1.0.x tests/src/FunctionalJavascript/ComponentAttributeTest.php \Drupal\Tests\layout_builder_component_attributes\FunctionalJavascript\ComponentAttributeTest::testAllowedAttributes()
Tests allowed attributes (both form render and page render).
File
- tests/
src/ FunctionalJavascript/ ComponentAttributeTest.php, line 271
Class
- ComponentAttributeTest
- Class ComponentAttributeTest.
Namespace
Drupal\Tests\layout_builder_component_attributes\FunctionalJavascriptCode
public function testAllowedAttributes() {
$this
->getSession()
->resizeWindow(1200, 2000);
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
// Initially, populate all fields. This also verifies they are rendered.
$this
->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
$this
->resetLayoutBuilderLayout();
$this
->clickContextualLink('.layout-builder-block', 'Manage attributes');
$assert_session
->assertWaitOnAjaxRequest();
$page
->find('xpath', '//details[contains(@id, "edit-block-attributes")]')
->click();
$page
->fillField('block_attributes[id]', 'block-id-test');
$page
->fillField('block_attributes[class]', 'block-class-test');
$page
->fillField('block_attributes[style]', 'color: blue;');
$page
->fillField('block_attributes[data]', 'data-block-test|test-value');
$page
->find('xpath', '//details[contains(@id, "edit-block-title-attributes")]')
->click();
$page
->fillField('block_title_attributes[id]', 'block-title-id-test');
$page
->fillField('block_title_attributes[class]', 'block-title-class-test');
$page
->fillField('block_title_attributes[style]', 'color: white;');
$page
->fillField('block_title_attributes[data]', 'data-block-title-test|test-value-title');
$page
->find('xpath', '//details[contains(@id, "edit-block-content-attributes")]')
->click();
$page
->fillField('block_content_attributes[id]', 'block-content-id-test');
$page
->fillField('block_content_attributes[class]', 'block-content-class-test');
$page
->fillField('block_content_attributes[style]', 'color: red;');
$page
->fillField('block_content_attributes[data]', 'data-block-content-test|test-value-content');
$page
->pressButton('Update');
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save layout');
// Verify Block Attributes.
$attributes = [
'id' => 'block-id-test',
'class' => 'block-class-test',
'style' => 'color: blue;',
'data-block-test' => 'test-value',
];
$this
->verifyAllowedAttributes('block_attributes', $attributes);
// Verify Block Title Attributes.
$attributes = [
'id' => 'block-title-id-test',
'class' => 'block-title-class-test',
'style' => 'color: white;',
'data-block-title-test' => 'test-value-title',
];
$this
->verifyAllowedAttributes('block_title_attributes', $attributes);
// Verify Block Content Attributes.
$attributes = [
'id' => 'block-content-id-test',
'class' => 'block-content-class-test',
'style' => 'color: red;',
'data-block-content-test' => 'test-value-content',
];
$this
->verifyAllowedAttributes('block_content_attributes', $attributes);
}