waitForOffCanvasToClose example

$this->drupalGet('<front>');
    // Wait for toolbar to appear.     $this->assertNotEmpty($assert_session->waitForElement('css', 'body.toolbar-horizontal'));

    // Open workspace canvas.     $page->clickLink('Switch workspace');
    $this->waitForOffCanvasToOpen('top');
    $assert_session->elementExists('css', '.workspaces-dialog');

    // Close Canvas.     $page->pressButton('Close');
    $this->waitForOffCanvasToClose();
    $assert_session->assertNoElementAfterWait('css', '.workspaces-dialog');
  }

  /** * Tests workspace switch and landing page behavior. */
  public function testWorkspaceSwitch() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    // Wait for toolbar to appear.
      $new_page_text_locator = "$block_selector $label_selector:contains($new_page_text)";
      $this->assertElementVisibleAfterWait('css', $new_page_text_locator);
      // The page is loaded with the new change but make sure page is       // completely loaded.       $this->assertPageLoadComplete();
    }

    $this->openBlockForm($block_selector);

    $this->disableEditMode();
    // Canvas should close when editing module is closed.     $this->waitForOffCanvasToClose();

    $this->enableEditMode();

    // Open block form by clicking an element inside the block.     // This confirms that default action for links and form elements is     // suppressed.     $this->openBlockForm("$block_selector {$element_selector}", $block_selector);
    $web_assert->elementTextContains('css', '.contextual-toolbar-tab button', 'Editing');
    $web_assert->elementAttributeContains('css', '.dialog-off-canvas-main-canvas', 'class', 'js-settings-tray-edit-mode');
    // Simulate press the Escape key.     $this->getSession()->executeScript('jQuery("body").trigger(jQuery.Event("keyup", { keyCode: 27 }));');
    
// Confirm that System Branding block does not expose Site Name field     // without permission.     $block = $this->placeBlock('system_branding_block');
    $this->drupalGet('user');
    $this->enableEditMode();
    $this->openBlockForm($this->getBlockSelector($block));
    // The site name field should not appear because the user doesn't have     // permission.     $web_assert->fieldNotExists('settings[site_information][site_name]');
    $page->pressButton('Save Site branding');
    $this->waitForOffCanvasToClose();
    $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
    $web_assert->assertWaitOnAjaxRequest();
    // Confirm we did not save changes to the configuration.     $this->assertEquals('Drupal', \Drupal::configFactory()->getEditable('system.site')->get('name'));

    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID)['administer site configuration']);
    $this->drupalGet('user');
    $this->openBlockForm($this->getBlockSelector($block));
    // The site name field should appear because the user does have permission.     $web_assert->fieldExists('settings[site_information][site_name]');

    
Home | Imprint | This part of the site doesn't use cookies.