Commit 82bba274 authored by xjm's avatar xjm

Issue #3018073 by tim.plunkett, kostyashupenko, mark_fullmer, johndevman,...

Issue #3018073 by tim.plunkett, kostyashupenko, mark_fullmer, johndevman, JacobSanford: Stop Using Title Case When Not Appropriate in Layout Builder UI
parent 56961ccf
......@@ -87,9 +87,9 @@ public function testLayoutModeration() {
$assert_session->checkboxChecked('revision');
$assert_session->fieldDisabled('revision');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$page->pressButton('Add Block');
$page->pressButton('Add block');
// Save the node as a draft. Revision count: 3.
$page->fillField('moderation_state[0][state]', 'draft');
$page->pressButton('Save layout');
......
......@@ -13,12 +13,12 @@
let layoutBuilderBlocksFiltered = false;
/**
* Provides the ability to filter the block listing in Add Block dialog.
* Provides the ability to filter the block listing in "Add block" dialog.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attach block filtering behavior to Add Block dialog.
* Attach block filtering behavior to "Add block" dialog.
*/
behaviors.layoutBuilderBlockFilter = {
attach(context) {
......
......@@ -174,20 +174,20 @@ protected function buildAddSectionLink(SectionStorageInterface $section_storage,
// layout or an empty layout.
if ($delta === count($section_storage)) {
if ($delta === 0) {
$title = $this->t('Add Section');
$title = $this->t('Add section');
}
else {
$title = $this->t('Add Section <span class="visually-hidden">at end of layout</span>');
$title = $this->t('Add section <span class="visually-hidden">at end of layout</span>');
}
}
// If the delta and the count are different, it is either the beginning of
// the layout or in between two sections.
else {
if ($delta === 0) {
$title = $this->t('Add Section <span class="visually-hidden">at start of layout</span>');
$title = $this->t('Add section <span class="visually-hidden">at start of layout</span>');
}
else {
$title = $this->t('Add Section <span class="visually-hidden">between @first and @second</span>', ['@first' => $delta, '@second' => $delta + 1]);
$title = $this->t('Add section <span class="visually-hidden">between @first and @second</span>', ['@first' => $delta, '@second' => $delta + 1]);
}
}
......@@ -274,7 +274,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
$build[$region]['layout_builder_add_block']['link'] = [
'#type' => 'link',
// Add one to the current delta since it is zero-indexed.
'#title' => $this->t('Add Block <span class="visually-hidden">in section @section, @region region</span>', ['@section' => $delta + 1, '@region' => $region_labels[$region]]),
'#title' => $this->t('Add block <span class="visually-hidden">in section @section, @region region</span>', ['@section' => $delta + 1, '@region' => $region_labels[$region]]),
'#url' => Url::fromRoute('layout_builder.choose_block',
[
'section_storage_type' => $storage_type,
......@@ -364,7 +364,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s
'data-dialog-renderer' => 'off_canvas',
],
],
// The section label is added to sections without a "Configure Section"
// The section label is added to sections without a "Configure section"
// link, and is only visible when the move block dialog is open.
'section_label' => [
'#markup' => $this->t('<span class="layout-builder__section-label" aria-hidden="true">Section @section</span>', ['@section' => $delta + 1]),
......
......@@ -28,7 +28,7 @@ public function getFormId() {
* {@inheritdoc}
*/
protected function submitLabel() {
return $this->t('Add Block');
return $this->t('Add block');
}
/**
......
......@@ -155,7 +155,7 @@ public function buildForm(array $form, FormStateInterface $form_state, SectionSt
$form['components_wrapper']['components'] = [
'#type' => 'table',
'#header' => [
$this->t('Block Label'),
$this->t('Block label'),
$this->t('Weight'),
],
'#tabledrag' => [
......
......@@ -55,9 +55,9 @@ public function testPlaceFieldBlockFromDifferentEntityType() {
// Place a field block for a user entity field.
$this->drupalGet('node/1/layout');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$page->clickLink('Name');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$page->pressButton('Save layout');
$this->drupalGet('node/1');
......
......@@ -62,11 +62,11 @@ public function testRenderByContextAwarePluginDelegate() {
// Add a block to the defaults.
$page->clickLink('Manage layout');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$page->fillField('settings[label]', 'Defaults block title');
$page->checkField('settings[label_display]');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$page->pressButton('Save layout');
$this->drupalGet('node/1');
......
......@@ -109,11 +109,11 @@ public function testOverrides() {
$assert_session->fieldNotExists('title[0][value]');
$assert_session->elementTextContains('css', '.layout-builder__message.layout-builder__message--overrides', 'You are editing the layout for this Bundle with section field content item. Edit the template for all Bundle with section field content items instead.');
$assert_session->linkExists('Edit the template for all Bundle with section field content items instead.');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$page->fillField('settings[label]', 'This is an override');
$page->checkField('settings[label_display]');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$page->pressButton('Save layout');
$assert_session->pageTextContains('This is an override');
......@@ -189,9 +189,9 @@ public function testPreserverEntityValues() {
// Create a layout override which will store the current node in the
// tempstore.
$page->clickLink('Layout');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$page->pressButton('Add Block');
$page->pressButton('Add block');
// Update the node to make a change that is not in the tempstore version.
$node = Node::load(1);
......@@ -264,13 +264,13 @@ public function testLayoutBuilderUi() {
$assert_session->pageTextContainsOnce('Placeholder for the "Extra label" field');
// Add a new block.
$assert_session->linkExists('Add Block');
$this->clickLink('Add 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');
$page->pressButton('Add block');
$assert_session->pageTextContains('Powered by Drupal');
$assert_session->pageTextContains('This is the label');
$assert_session->addressEquals("$field_ui_prefix/display/default/layout");
......@@ -301,7 +301,7 @@ public function testLayoutBuilderUi() {
$page->pressButton('Remove');
// Add a new section.
$this->clickLink('Add Section');
$this->clickLink('Add section');
$this->assertCorrectLayouts();
$assert_session->linkExists('Two column');
$this->clickLink('Two column');
......@@ -320,11 +320,11 @@ public function testLayoutBuilderUi() {
// Alter the defaults.
$this->drupalGet("$field_ui_prefix/display/default/layout");
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->linkExists('Title');
$this->clickLink('Title');
$page->pressButton('Add Block');
$page->pressButton('Add block');
// The title field is present.
$assert_session->elementExists('css', '.field--name-title');
$page->pressButton('Save layout');
......@@ -348,11 +348,11 @@ public function testLayoutBuilderUi() {
// Reverting the override returns it to the defaults.
$this->clickLink('Layout');
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->linkExists('ID');
$this->clickLink('ID');
$page->pressButton('Add Block');
$page->pressButton('Add block');
// The title field is present.
$assert_session->elementExists('css', '.field--name-nid');
$assert_session->pageTextContains('ID');
......@@ -525,8 +525,8 @@ public function testPluginDependencies() {
$this->drupalPostForm('admin/structure/types/manage/bundle_with_section_field/display', ['layout[enabled]' => TRUE], 'Save');
$assert_session->linkExists('Manage layout');
$this->clickLink('Manage layout');
$assert_session->linkExists('Add Section');
$this->clickLink('Add Section');
$assert_session->linkExists('Add section');
$this->clickLink('Add section');
$assert_session->linkExists('Layout plugin (with dependencies)');
$this->clickLink('Layout plugin (with dependencies)');
$assert_session->elementExists('css', '.layout--layout-test-dependencies-plugin');
......@@ -538,18 +538,18 @@ public function testPluginDependencies() {
$assert_session->elementExists('css', '.field--name-body');
// Add a menu block.
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->linkExists('My Menu');
$this->clickLink('My Menu');
$page->pressButton('Add Block');
$page->pressButton('Add block');
// Add another block alongside the menu.
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->linkExists('Powered by Drupal');
$this->clickLink('Powered by Drupal');
$page->pressButton('Add Block');
$page->pressButton('Add block');
// Assert that the blocks are visible, and save the layout.
$assert_session->pageTextContains('Powered by Drupal');
......@@ -595,11 +595,11 @@ public function testLayoutBuilderUiFullViewMode() {
// Customize the default view mode.
$this->drupalGet("$field_ui_prefix/display/default/layout");
$this->clickLink('Add Block');
$this->clickLink('Add block');
$this->clickLink('Powered by Drupal');
$page->fillField('settings[label]', 'This is the default view mode');
$page->checkField('settings[label_display]');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$assert_session->pageTextContains('This is the default view mode');
$page->pressButton('Save layout');
......@@ -618,11 +618,11 @@ public function testLayoutBuilderUiFullViewMode() {
$this->drupalPostForm("$field_ui_prefix/display/full", ['layout[enabled]' => TRUE], 'Save');
$this->drupalPostForm("$field_ui_prefix/display/full", ['layout[allow_custom]' => TRUE], 'Save');
$this->drupalGet("$field_ui_prefix/display/full/layout");
$this->clickLink('Add Block');
$this->clickLink('Add block');
$this->clickLink('Powered by Drupal');
$page->fillField('settings[label]', 'This is the full view mode');
$page->checkField('settings[label_display]');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$assert_session->pageTextContains('This is the full view mode');
$page->pressButton('Save layout');
......@@ -657,11 +657,11 @@ public function testLayoutBuilderUiFullViewMode() {
$assert_session->pageTextNotContains('This is the default view mode');
// Create an override of the full view mode.
$this->clickLink('Add Block');
$this->clickLink('Add block');
$this->clickLink('Powered by Drupal');
$page->fillField('settings[label]', 'This is an override of the full view mode');
$page->checkField('settings[label_display]');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$assert_session->pageTextContains('This is an override of the full view mode');
$page->pressButton('Save layout');
......@@ -695,11 +695,11 @@ public function testLayoutBuilderUiFullViewMode() {
$assert_session->pageTextNotContains('This is the default view mode');
// Recreate an override of the full view mode.
$this->clickLink('Add Block');
$this->clickLink('Add block');
$this->clickLink('Powered by Drupal');
$page->fillField('settings[label]', 'This is an override of the full view mode');
$page->checkField('settings[label_display]');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$assert_session->pageTextContains('This is an override of the full view mode');
$page->pressButton('Save layout');
......@@ -754,7 +754,7 @@ public function testLayoutBuilderChooseBlocksAlter() {
$this->clickLink('Manage layout');
// Add a new block.
$this->clickLink('Add Block');
$this->clickLink('Add block');
// Verify that blocks not modified are present.
$assert_session->linkExists('Powered by Drupal');
......@@ -773,13 +773,13 @@ public function testLayoutBuilderChooseBlocksAlter() {
$this->clickLink('Manage layout');
// Add a new section.
$this->clickLink('Add Section', 1);
$this->clickLink('Add section', 1);
$assert_session->linkExists('Two column');
$this->clickLink('Two column');
$assert_session->buttonExists('Add section');
$this->getSession()->getPage()->pressButton('Add section');
// Add a new block to second section.
$this->clickLink('Add Block', 1);
$this->clickLink('Add block', 1);
// Verify that Changed block is present on second section.
$assert_session->linkExists('Changed');
......@@ -855,9 +855,9 @@ public function testDeletedView() {
$assert_session->linkExists('Layout');
$this->clickLink('Layout');
$this->clickLink('Add Block');
$this->clickLink('Add block');
$this->clickLink('Test Block View');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$assert_session->pageTextContains('Test Block View');
$assert_session->elementExists('css', '.block-views-blocktest-block-view-block-1');
......@@ -891,7 +891,7 @@ public function testFormAlter() {
$page->pressButton('Save');
$page->clickLink('Manage layout');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$assert_session->pageTextContains('Layout Builder Storage: node.bundle_with_section_field.default');
$assert_session->pageTextContains('Layout Builder Section: layout_onecol');
......@@ -912,7 +912,7 @@ public function testCustomSectionAttributes() {
$this->drupalPostForm('admin/structure/types/manage/bundle_with_section_field/display/default', ['layout[enabled]' => TRUE], 'Save');
$page->clickLink('Manage layout');
$page->clickLink('Add Section');
$page->clickLink('Add section');
$page->clickLink('Layout Builder Test Plugin');
// See \Drupal\layout_builder_test\Plugin\Layout\LayoutBuilderTestPlugin::build().
$assert_session->elementExists('css', '.go-birds');
......@@ -940,10 +940,10 @@ public function testBlockPlaceholder() {
$this->drupalGet("$field_ui_prefix/display/default/layout");
// Add a block whose content is controlled by state and is empty by default.
$this->clickLink('Add Block');
$this->clickLink('Add block');
$this->clickLink('Test block caching');
$page->fillField('settings[label]', 'The block label');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$block_content = 'I am content';
$placeholder_content = 'Placeholder for the "The block label" block';
......@@ -1123,7 +1123,7 @@ public function testRemovingAllSections() {
$assert_session->elementsCount('css', '.layout-builder__add-section', 1);
// Add one section to the override.
$page->clickLink('Add Section');
$page->clickLink('Add section');
$page->clickLink('One column');
$assert_session->elementsCount('css', '.layout', 1);
$assert_session->elementsCount('css', '.layout-builder__add-block', 1);
......
......@@ -204,11 +204,11 @@ protected function addLayoutOverride() {
$assert_session->pageTextContains('The untranslated field value');
// Adjust the layout.
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->linkExists('Powered by Drupal');
$this->clickLink('Powered by Drupal');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$assert_session->pageTextContains('Powered by Drupal');
$assert_session->buttonExists('Save layout');
......
......@@ -53,11 +53,11 @@ public function testMultipleViewModes() {
$assert_session->pageTextNotContains('Powered by Drupal');
$this->drupalGet('node/1/layout');
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->linkExists('Powered by Drupal');
$this->clickLink('Powered by Drupal');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$page->pressButton('Save');
$assert_session->pageTextContains('Powered by Drupal');
......
......@@ -74,11 +74,11 @@ public function setUp() {
]);
$this->drupalGet('node/' . $this->node->id() . '/layout');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$page->fillField('settings[label]', 'This is an override');
$page->checkField('settings[label_display]');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$page->pressButton('Save layout');
$assert_session->pageTextContains('This is an override');
......
......@@ -68,8 +68,8 @@ public function testAddAjaxBlock() {
$assert_session->elementExists('css', '.field--name-body');
// Add a new block.
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->linkExists('TestAjax');
$this->clickLink('TestAjax');
......@@ -86,7 +86,7 @@ public function testAddAjaxBlock() {
}
}
// Then add the block.
$page->pressButton('Add Block');
$page->pressButton('Add block');
$assert_session->assertWaitOnAjaxRequest();
$block_elements = $this->cssSelect('.block-layout-builder-test-testajax');
// Should be exactly one of these in there.
......
......@@ -53,8 +53,8 @@ public function testBlockFilter() {
$assert_session->addressEquals("$field_ui_prefix/display/default/layout");
// Open the block listing.
$assert_session->linkExists('Add Block');
$this->clickLink('Add Block');
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
// Get all blocks, for assertions later.
......
......@@ -56,15 +56,15 @@ public function testValidationMessage() {
);
$this->clickElementWhenClickable($page->findLink('Manage layout'));
$assert_session->addressEquals($field_ui_prefix . '/display/default/layout');
$this->clickElementWhenClickable($page->findLink('Add Block'));
$this->clickElementWhenClickable($page->findLink('Add block'));
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas .block-categories'));
$this->clickElementWhenClickable($page->findLink('Powered by Drupal'));
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas [name="settings[label]"]'));
$page->findField('Title')->setValue('');
$this->clickElementWhenClickable($page->findButton('Add Block'));
$this->clickElementWhenClickable($page->findButton('Add block'));
$this->assertMessagesDisplayed();
$page->findField('Title')->setValue('New title');
$page->pressButton('Add Block');
$page->pressButton('Add block');
$block_css_locator = '#layout-builder .block-system-powered-by-block';
$this->assertNotEmpty($assert_session->waitForElementVisible('css', $block_css_locator));
$this->waitForNoElement('#drupal-off-canvas');
......
......@@ -99,19 +99,19 @@ public function testContextualLinks() {
* Adds block to the layout via Layout Builder's UI.
*
* @param string $block_name
* The block name as it appears in the Add Block form.
* The block name as it appears in the Add block form.
*/
protected function addBlock($block_name) {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
$assert_session->linkExists('Add Block');
$page->clickLink('Add Block');
$assert_session->linkExists('Add block');
$page->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
$this->assertNotEmpty($assert_session->waitForElementVisible('css', "#drupal-off-canvas a:contains('$block_name')"));
$page->clickLink($block_name);
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '[data-drupal-selector=\'edit-actions-submit\']'));
$page->pressButton('Add Block');
$page->pressButton('Add block');
$this->waitForNoElement('#drupal-off-canvas');
$assert_session->assertWaitOnAjaxRequest();
}
......
......@@ -192,7 +192,7 @@ protected function replaceFileInBlock(FileInterface $file) {
protected function addInlineFileBlockToLayout($title, File $file) {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
$page->clickLink('Add Block');
$page->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
$this->assertNotEmpty($assert_session->waitForLink('Create custom block'));
$this->clickLink('Create custom block');
......@@ -200,7 +200,7 @@ protected function addInlineFileBlockToLayout($title, File $file) {
$assert_session->fieldValueEquals('Title', '');
$page->findField('Title')->setValue($title);
$this->attachFileToBlockForm($file);
$page->pressButton('Add Block');
$page->pressButton('Add block');
$this->assertDialogClosedAndTextVisible($file->label(), static::INLINE_BLOCK_LOCATOR);
}
......
......@@ -465,7 +465,7 @@ public function testAddWorkFlow() {
$layout_default_path = 'admin/structure/types/manage/bundle_with_section_field/display/default/layout';
$this->drupalGet($layout_default_path);
// Add a basic block with the body field set.
$page->clickLink('Add Block');
$page->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
// Confirm that with no block content types the link does not appear.
$assert_session->linkNotExists('Create custom block');
......@@ -474,7 +474,7 @@ public function testAddWorkFlow() {
$this->drupalGet($layout_default_path);
// Add a basic block with the body field set.
$page->clickLink('Add Block');
$page->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
// Confirm with only 1 type the "Create custom block" link goes directly t
// block add form.
......@@ -487,7 +487,7 @@ public function testAddWorkFlow() {
$this->drupalGet($layout_default_path);
// Add a basic block with the body field set.
$page->clickLink('Add Block');
$page->clickLink('Add block');
// Confirm that, when more than 1 type exists, "Create custom block" shows a
// list of block types.
$assert_session->assertWaitOnAjaxRequest();
......@@ -519,7 +519,7 @@ public function testAddInlineBlocksPermission() {
$this->drupalLogin($this->drupalCreateUser($permissions));
$this->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
$page->clickLink('Add Block');
$page->clickLink('Add block');
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas .block-categories'));
if ($expected) {
$assert_session->linkExists('Create custom block');
......
......@@ -133,7 +133,7 @@ protected function removeInlineBlockFromLayout() {
protected function addInlineBlockToLayout($title, $body) {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
$page->clickLink('Add Block');
$page->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
$this->assertNotEmpty($assert_session->waitForLink('Create custom block'));
$this->clickLink('Create custom block');
......@@ -143,7 +143,7 @@ protected function addInlineBlockToLayout($title, $body) {
$assert_session->fieldValueEquals('Title', '');
$page->findField('Title')->setValue($title);
$textarea->setValue($body);
$page->pressButton('Add Block');
$page->pressButton('Add block');
$this->assertDialogClosedAndTextVisible($body, static::INLINE_BLOCK_LOCATOR);
}
......
......@@ -64,7 +64,7 @@ public function testAddAjaxBlock() {
$this->drupalGet('node/1/layout');
// Add a new block.
$this->clickLink('Add Block');
$this->clickLink('Add block');
$assert_session->assertWaitOnAjaxRequest();
// Validate that only field blocks for layouted bundle are present.
......
......@@ -142,8 +142,8 @@ protected function addBlock($block_link_text, $rendered_locator) {