annotate core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Tests\toolbar\FunctionalJavascript;
Chris@0 4
Chris@17 5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
Chris@0 6
Chris@0 7 /**
Chris@0 8 * Tests the JavaScript functionality of the toolbar.
Chris@0 9 *
Chris@0 10 * @group toolbar
Chris@0 11 */
Chris@17 12 class ToolbarIntegrationTest extends WebDriverTestBase {
Chris@0 13
Chris@0 14 /**
Chris@0 15 * {@inheritdoc}
Chris@0 16 */
Chris@0 17 public static $modules = ['toolbar', 'node'];
Chris@0 18
Chris@0 19 /**
Chris@0 20 * Tests if the toolbar can be toggled with JavaScript.
Chris@0 21 */
Chris@0 22 public function testToolbarToggling() {
Chris@0 23 $admin_user = $this->drupalCreateUser([
Chris@0 24 'access toolbar',
Chris@0 25 'administer site configuration',
Chris@0 26 'access content overview',
Chris@0 27 ]);
Chris@0 28 $this->drupalLogin($admin_user);
Chris@0 29
Chris@17 30 // Set size for horizontal toolbar.
Chris@17 31 $this->getSession()->resizeWindow(1200, 600);
Chris@0 32 $this->drupalGet('<front>');
Chris@17 33 $this->assertNotEmpty($this->assertSession()->waitForElement('css', 'body.toolbar-horizontal'));
Chris@17 34 $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '.toolbar-tray'));
Chris@17 35
Chris@0 36 $page = $this->getSession()->getPage();
Chris@0 37
Chris@0 38 // Test that it is possible to toggle the toolbar tray.
Chris@0 39 $content = $page->findLink('Content');
Chris@0 40 $this->assertTrue($content->isVisible(), 'Toolbar tray is open by default.');
Chris@0 41 $page->clickLink('Manage');
Chris@0 42 $this->assertFalse($content->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.');
Chris@0 43 $page->clickLink('Manage');
Chris@0 44 $this->assertTrue($content->isVisible(), 'Toolbar tray is visible again after clicking the "Manage" button a second time.');
Chris@0 45
Chris@0 46 // Test toggling the toolbar tray between horizontal and vertical.
Chris@0 47 $tray = $page->findById('toolbar-item-administration-tray');
Chris@0 48 $this->assertFalse($tray->hasClass('toolbar-tray-vertical'), 'Toolbar tray is not vertically oriented by default.');
Chris@0 49 $page->pressButton('Vertical orientation');
Chris@0 50 $this->assertTrue($tray->hasClass('toolbar-tray-vertical'), 'After toggling the orientation the toolbar tray is now displayed vertically.');
Chris@0 51
Chris@0 52 $page->pressButton('Horizontal orientation');
Chris@0 53 $this->assertTrue($tray->hasClass('toolbar-tray-horizontal'), 'After toggling the orientation a second time the toolbar tray is displayed horizontally again.');
Chris@0 54 }
Chris@0 55
Chris@0 56 }