WorkspaceToolbarIntegrationTest.php in Drupal 10
File
core/modules/workspaces/tests/src/FunctionalJavascript/WorkspaceToolbarIntegrationTest.php
View source
<?php
namespace Drupal\Tests\workspaces\FunctionalJavascript;
use Drupal\Tests\system\FunctionalJavascript\OffCanvasTestBase;
class WorkspaceToolbarIntegrationTest extends OffCanvasTestBase {
protected static $modules = [
'toolbar',
'workspaces',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'administer workspaces',
'access toolbar',
'access administration pages',
]);
$this
->drupalLogin($admin_user);
}
public function testWorkspaceCanvasToggling() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->getSession()
->resizeWindow(1200, 600);
$this
->drupalGet('<front>');
$this
->assertNotEmpty($assert_session
->waitForElement('css', 'body.toolbar-horizontal'));
$page
->clickLink('Switch workspace');
$this
->waitForOffCanvasToOpen('top');
$assert_session
->elementExists('css', '.workspaces-dialog');
$page
->pressButton('Close');
$this
->waitForOffCanvasToClose();
$assert_session
->assertNoElementAfterWait('css', '.workspaces-dialog');
}
public function testWorkspaceSwitch() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->getSession()
->resizeWindow(1200, 600);
$this
->drupalGet('admin');
$this
->assertNotEmpty($assert_session
->waitForElement('css', 'body.toolbar-horizontal'));
$page
->clickLink('Switch workspace');
$this
->waitForOffCanvasToOpen('top');
$page
->clickLink('Stage');
$this
->assertElementVisibleAfterWait('css', '.workspace-activate-form.workspace-confirm-form');
$page
->find('css', '.ui-dialog-buttonset .button--primary')
->click();
$assert_session
->statusMessageContainsAfterWait('Stage is now the active workspace.', 'status');
$assert_session
->addressEquals('admin');
}
}