1<?php 2 3namespace Drupal\Tests\workspaces\FunctionalJavascript; 4 5use Drupal\Tests\system\FunctionalJavascript\OffCanvasTestBase; 6 7/** 8 * Tests workspace settings stray integration. 9 * 10 * @group workspaces 11 */ 12class WorkspaceToolbarIntegrationTest extends OffCanvasTestBase { 13 14 /** 15 * {@inheritdoc} 16 */ 17 public static $modules = ['toolbar', 'workspaces']; 18 19 /** 20 * {@inheritdoc} 21 */ 22 protected $defaultTheme = 'stark'; 23 24 /** 25 * {@inheritdoc} 26 */ 27 protected function setUp() { 28 parent::setUp(); 29 $admin_user = $this->drupalCreateUser([ 30 'administer workspaces', 31 'access toolbar', 32 'access administration pages', 33 ]); 34 $this->drupalLogin($admin_user); 35 } 36 37 /** 38 * Test workspace canvas can be toggled with JavaScript. 39 */ 40 public function testWorkspaceCanvasToggling() { 41 $page = $this->getSession()->getPage(); 42 $assert_session = $this->assertSession(); 43 44 // Set size for horizontal toolbar. 45 $this->getSession()->resizeWindow(1200, 600); 46 $this->drupalGet('<front>'); 47 // Wait for toolbar to appear. 48 $this->assertNotEmpty($assert_session->waitForElement('css', 'body.toolbar-horizontal')); 49 50 // Open workspace canvas. 51 $page->clickLink('Switch workspace'); 52 $this->waitForOffCanvasToOpen('top'); 53 $assert_session->elementExists('css', '.workspaces-dialog'); 54 55 // Close Canvas. 56 $page->pressButton('Close'); 57 $this->waitForOffCanvasToClose(); 58 $assert_session->assertNoElementAfterWait('css', '.workspaces-dialog'); 59 } 60 61 /** 62 * Test workspace switch and landing page behavior. 63 */ 64 public function testWorkspaceSwitch() { 65 $page = $this->getSession()->getPage(); 66 $assert_session = $this->assertSession(); 67 68 // Wait for toolbar to appear. 69 $this->getSession()->resizeWindow(1200, 600); 70 $this->drupalGet('admin'); 71 72 // Wait for toolbar to appear. 73 $this->assertNotEmpty($assert_session->waitForElement('css', 'body.toolbar-horizontal')); 74 75 // Open workspace canvas. 76 $page->clickLink('Switch workspace'); 77 $this->waitForOffCanvasToOpen('top'); 78 79 // Click 'stage' workspace and confirm switch. 80 $page->clickLink('Stage'); 81 $this->assertElementVisibleAfterWait('css', '.workspace-activate-form.workspace-confirm-form'); 82 $page->find('css', '.ui-dialog-buttonset .button--primary')->click(); 83 $assert_session->waitForElementVisible('css', '.messages--status'); 84 85 // Make sure we stay on same page after switch. 86 $assert_session->responseContains('<em class="placeholder">Stage</em> is now the active workspace.'); 87 $assert_session->addressEquals('admin'); 88 } 89 90} 91