webform_deprecated-6.3.x-dev/modules/webform_shortcuts/tests/src/Functional/WebformShortcutsFunctionalTest.php
modules/webform_shortcuts/tests/src/Functional/WebformShortcutsFunctionalTest.php
<?php
namespace Drupal\Tests\webform_shortcuts\Functional;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
/**
* Webform shortcuts test.
*
* @group webform_shortcuts
*/
class WebformShortcutsFunctionalTest extends WebformBrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'webform',
'webform_ui',
'webform_shortcuts',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->placeBlocks();
}
/**
* Test shortcuts.
*/
public function testShortcuts() {
$assert_session = $this->assertSession();
$this->drupalLogin($this->rootUser);
// Check default shortcuts.
$this->drupalGet('/admin/structure/webform/manage/contact');
$assert_session->responseContains('<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="Keyboard shortcuts" data-webform-help="<div class="webform-element-help--title">Keyboard shortcuts</div><div class="webform-element-help--content"><hr />CTRL+E = Add element<br />CTRL+P = Add page<br />CTRL+L = Add layout<br /><hr />CTRL+S = Save element or elements<br />CTRL+R = Reset elements<br /><hr />CTRL+W = Show/hide row weights<br /><hr /></div>"><span aria-hidden="true">?</span></span>');
// Customize the shortcuts.
$this->drupalGet('/admin/structure/webform/config/advanced');
$edit = [
'webform_shortcuts[add_element]' => 'crtl+z',
'webform_shortcuts[toggle_weights]' => '',
];
$this->submitForm($edit, 'Save configuration');
// Check customized shortcuts.
$this->drupalGet('/admin/structure/webform/manage/contact');
$assert_session->responseContains('<span class="webform-element-help js-webform-element-help" role="tooltip" tabindex="0" aria-label="Keyboard shortcuts" data-webform-help="<div class="webform-element-help--title">Keyboard shortcuts</div><div class="webform-element-help--content"><hr />CRTL+Z = Add element<br />CTRL+P = Add page<br />CTRL+L = Add layout<br /><hr />CTRL+S = Save element or elements<br />CTRL+R = Reset elements<br /><hr /></div>"><span aria-hidden="true">?</span></span>');
}
}
