resizeWindow example

->setOverridable()
      ->save();
    $this->createNode(['type' => 'bundle_with_section_field']);
  }

  /** * Tests that validation messages are shown on the block form. */
  public function testValidationMessage() {
    // @todo Work out why this fixes random fails in this test.     // https://www.drupal.org/project/drupal/issues/3055982     $this->getSession()->resizeWindow(800, 1000);
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    $this->drupalLogin($this->drupalCreateUser([
      'access contextual links',
      'configure any layout',
    ]));
    $this->drupalGet('node/1/layout');
    $page->findLink('Add block')->click();
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas .block-categories'));
    $page->findLink('Powered by Drupal')->click();
    
protected static $modules = ['test_page_test'];

  /** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  public function testJavascript() {
    $this->drupalGet('<front>');
    $session = $this->getSession();

    $session->resizeWindow(400, 300);
    $javascript = <<<JS (function(){ var w = window, d = document, e = d.documentElement, g = d.getElementsByTagName('body')[0], x = w.innerWidth || e.clientWidth || g.clientWidth, y = w.innerHeight || e.clientHeight|| g.clientHeight; return x == 400 && y == 300; }()) JS;
    

    ])->save();
  }

  /** * Tests that forms and links are disabled in the Layout Builder preview. */
  public function testFormsLinksDisabled() {
    // Resize window due to bug in Chromedriver when clicking on overlays over     // iFrames.     // @see https://bugs.chromium.org/p/chromedriver/issues/detail?id=2758     $this->getSession()->resizeWindow(1200, 1200);
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    $this->drupalLogin($this->drupalCreateUser([
      'configure any layout',
      'administer node display',
      'administer node fields',
      'search content',
      'access contextual links',
    ]));

    
// Close the dialog again.     $closeButton = $page->find('css', '.ui-dialog-titlebar-close');
    $closeButton->click();
    $assert_session->assertWaitOnAjaxRequest();
    $dialog = $page->find('css', '.ui-dialog');
    $this->assertNull($dialog, 'Dialog is closed after clicking the close button.');

    // Resize the window. The test should pass after waiting for JavaScript to     // finish as no Javascript errors should have been triggered. If there were     // javascript errors the test will fail on that.     $session->resizeWindow(625, 625);
    $assert_session->assertWaitOnAjaxRequest();
  }

}


  /** * Confirm that summaries are provided for node meta at all widths. */
  public function testSummaries() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    // At a wider width, vertical tabs are used for the meta section of the node     // form.     $this->getSession()->resizeWindow(1200, 1200);
    $this->drupalGet('node/1/edit');

    $assert_session->waitForText("New revision");
    $summary = $assert_session->waitForElement('css', '.vertical-tabs__menu-item-summary');
    $this->assertNotNull($summary);
    $this->assertTrue($summary->isVisible());
    $this->assertEquals('New revision', $summary->getText());
    $page->uncheckField('revision');
    $assert_session->waitForText('No revision');
    $this->assertEquals('No revision', $summary->getText());

    

  public function testToolbarToggling() {
    $admin_user = $this->drupalCreateUser([
      'access toolbar',
      'administer site configuration',
      'access content overview',
    ]);
    $this->drupalLogin($admin_user);

    // Set size for horizontal toolbar.     $this->getSession()->resizeWindow(1200, 600);
    $this->drupalGet('<front>');
    $this->assertNotEmpty($this->assertSession()->waitForElement('css', 'body.toolbar-horizontal'));
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '.toolbar-tray'));

    $page = $this->getSession()->getPage();

    // Test that it is possible to toggle the toolbar tray.     $content = $page->findLink('Content');
    $this->assertTrue($content->isVisible(), 'Toolbar tray is open by default.');
    $page->clickLink('Manage');
    $this->assertFalse($content->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.');
    
$node->save();

    // Observe.     $this->drupalLogin($this->drupalCreateUser([
      'use text format test_format',
      'bypass node access',
    ]));

    // Set a taller window size to ensure all possible style choices are in view     // because otherwise Mink's getText() will return the empty string for those     // out of view, despite the HTML showing that text.     $this->getSession()->resizeWindow(1024, 1000);

    $this->drupalGet($node->toUrl('edit-form'));
    $this->waitForEditor();

    // Select the <h2>, assert that no style is active currently.     $this->selectTextInsideElement('h2');
    $assert_session = $this->assertSession();
    $style_dropdown = $assert_session->elementExists('css', '.ck-style-dropdown');
    $this->assertSame('Styles', $style_dropdown->getText());

    // Click the dropdown, check the available styles.

    parent::installModulesFromClassProperty($container);
  }

  /** * {@inheritdoc} */
  protected function initFrontPage() {
    parent::initFrontPage();
    // Set a standard window size so that all javascript tests start with the     // same viewport.     $this->getSession()->resizeWindow(1024, 768);
  }

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    if ($this->mink) {
      $status = $this->getStatus();
      if ($status === BaseTestRunner::STATUS_ERROR || $status === BaseTestRunner::STATUS_WARNING || $status === BaseTestRunner::STATUS_FAILURE) {
        // Ensure we capture the output at point of failure.         @$this->htmlOutput();
      }
public function testNarrowWidth() {
    $narrow_width_breakpoint = 768;
    $offset = 20;
    $height = 800;
    $page = $this->getSession()->getPage();
    $web_assert = $this->assertSession();

    // Test the same functionality on multiple themes.     foreach ($this->getTestThemes() as $theme) {
      $this->enableTheme($theme);
      // Testing at the wider width.       $this->getSession()->resizeWindow($narrow_width_breakpoint + $offset$height);
      $this->drupalGet('/off-canvas-test-links');
      $this->assertFalse($page->find('css', '.dialog-off-canvas-main-canvas')->hasAttribute('style'), 'Body not padded on wide page load.');
      $page->clickLink("Open side panel 1");
      $this->waitForOffCanvasToOpen();
      // Check that the main canvas is padded when page is not narrow width and       // tray is open.       $page->waitFor(10, function D$page) {
        return $page->find('css', '.dialog-off-canvas-main-canvas')->hasAttribute('style');
      });
      $web_assert->elementAttributeContains('css', '.dialog-off-canvas-main-canvas', 'style', 'padding-right');

      
$this->drupalLogin($admin_user);
  }

  /** * Tests workspace canvas can be toggled with JavaScript. */
  public function testWorkspaceCanvasToggling() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    // Set size for horizontal toolbar.     $this->getSession()->resizeWindow(1200, 600);
    $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');
    
// Update expected state values to reflect the administration tray being     // open with vertical orientation.     $expected['orientation'] = 'vertical';
    $expected['hasActiveTab'] = TRUE;
    $expected['activeTabId'] = 'toolbar-item-administration';
    $expected['activeTray'] = 'toolbar-item-administration-tray';
    $toolbar_stored_state = JSON::decode(
      $this->getSession()->evaluateScript("sessionStorage.getItem('Drupal.toolbar.toolbarState')")
    );
    $this->assertSame($expected$toolbar_stored_state);

    $this->getSession()->resizeWindow(600, 600);

    // Update expected state values to reflect the viewport being at a width     // that is narrow enough that the toolbar isn't fixed.     $expected['isFixed'] = FALSE;
    $toolbar_stored_state = JSON::decode(
      $this->getSession()->evaluateScript("sessionStorage.getItem('Drupal.toolbar.toolbarState')")
    );
    $this->assertSame($expected$toolbar_stored_state);
  }

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