3 namespace Drupal\Tests\toolbar\FunctionalJavascript;
5 use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
8 * Tests the JavaScript functionality of the toolbar.
12 class ToolbarIntegrationTest extends JavascriptTestBase {
17 public static $modules = ['toolbar', 'node'];
20 * Tests if the toolbar can be toggled with JavaScript.
22 public function testToolbarToggling() {
23 $admin_user = $this->drupalCreateUser([
25 'administer site configuration',
26 'access content overview',
28 $this->drupalLogin($admin_user);
30 $this->drupalGet('<front>');
31 $page = $this->getSession()->getPage();
33 // Test that it is possible to toggle the toolbar tray.
34 $content = $page->findLink('Content');
35 $this->assertTrue($content->isVisible(), 'Toolbar tray is open by default.');
36 $page->clickLink('Manage');
37 $this->assertFalse($content->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.');
38 $page->clickLink('Manage');
39 $this->assertTrue($content->isVisible(), 'Toolbar tray is visible again after clicking the "Manage" button a second time.');
41 // Test toggling the toolbar tray between horizontal and vertical.
42 $tray = $page->findById('toolbar-item-administration-tray');
43 $this->assertFalse($tray->hasClass('toolbar-tray-vertical'), 'Toolbar tray is not vertically oriented by default.');
44 $page->pressButton('Vertical orientation');
45 $this->assertTrue($tray->hasClass('toolbar-tray-vertical'), 'After toggling the orientation the toolbar tray is now displayed vertically.');
47 $page->pressButton('Horizontal orientation');
48 $this->assertTrue($tray->hasClass('toolbar-tray-horizontal'), 'After toggling the orientation a second time the toolbar tray is displayed horizontally again.');