hasButton example

// Add a block that includes an entity contextual link.     $this->addBlock('Test Block View: Teaser block');

    // Add a block that includes a views contextual link.     $this->addBlock('Recent content');

    // Ensure the contextual links are correct before the layout is saved.     $this->assertCorrectContextualLinksInUi();

    // Ensure the contextual links are correct when the Layout Builder is loaded     // after being saved.     $page->hasButton('Save layout');
    $page->pressButton('Save layout');
    $this->drupalGet('node/1/layout');
    $this->assertCorrectContextualLinksInUi();

    $this->drupalGet('node/1');
    $this->assertCorrectContextualLinksInNode();
  }

  /** * Adds block to the layout via Layout Builder's UI. * * @param string $block_name * The block name as it appears in the Add block form. */
 'Apply to selected items');

    // Verify that the action was performed.     $this->assertSession()->pageTextContains('Make content sticky was applied to 1 item.');

    // Reset the form.     $this->submitForm([], 'Reset');
    $this->assertSession()->assertWaitOnAjaxRequest();

    $this->assertSession()->pageTextContains('Page One');
    $this->assertSession()->pageTextContains('Page Two');
    $this->assertFalse($session->getPage()->hasButton('Reset'));
  }

  /** * Tests if exposed filtering via AJAX works in a modal. */
  public function testExposedFiltersInModal() {
    $this->drupalGet('views-test-modal/modal');

    $assert = $this->assertSession();

    $assert->elementExists('named', ['link', 'Administer content'])->click();
    
$wrapper->pressButton('Add media');
    $this->assertNotNull($assert_session->waitForText('Add or select media'));
    $page->attachFileToField('Add file', $this->container->get('file_system')->realpath($jpg_image->uri));
    $this->assertNotNull($assert_session->waitForText('Alternative text'));
    $page->fillField('Alternative text', $this->randomString());
    $assert_session->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Save and insert');
    $first_item_locator = "(//div[@data-drupal-selector='edit-media-image-field-selection-0'])[1]";
    $this->assertNotNull($first_item = $assert_session->waitForElementVisible('xpath', $first_item_locator));
    $first_item->pressButton('Remove');
    $assert_session->waitForElementRemoved('xpath', $first_item_locator);
    $page->waitFor(10, function D) use ($wrapper) {
      return $wrapper->hasButton('Add media');
    });
    // Test reinserting the same selection.     $wrapper->pressButton('Add media');
    $this->assertNotNull($assert_session->waitForText('Add or select media'));
    $assert_session->elementExists('xpath', "(//div[contains(@class, 'media-library-item')])[1]")->click();
    $assert_session->checkboxChecked('media_library_select_form[0]');
    $assert_session->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Insert selected');
    $this->assertNotNull($assert_session->waitForElementVisible('xpath', $first_item_locator));
  }

  /** * Data provider for ::testInsertionAndReselection(). * * @return array * Test data. */
/** * Helper to test toggling the summary area. * * @internal */
  protected function assertSummaryToggle(): void {
    $this->drupalGet('node/add/page');
    $widget = $this->getSession()->getPage()->findById('edit-body-wrapper');
    $summary_field = $widget->findField('edit-body-0-summary');

    $this->assertEquals(FALSE, $summary_field->isVisible(), 'Summary field is hidden by default.');
    $this->assertEquals(FALSE, $widget->hasButton('Hide summary'), 'No Hide summary link by default.');

    $widget->pressButton('Edit summary');
    $this->assertEquals(FALSE, $widget->hasButton('Edit summary'), 'Edit summary link is removed after clicking.');
    $this->assertEquals(TRUE, $summary_field->isVisible(), 'Summary field is shown.');

    $widget->pressButton('Hide summary');
    $this->assertEquals(FALSE, $widget->hasButton('Hide summary'), 'Hide summary link is removed after clicking.');
    $this->assertEquals(FALSE, $summary_field->isVisible(), 'Summary field is hidden again.');
    $this->assertEquals(TRUE, $widget->hasButton('Edit summary'), 'Edit summary link is visible again.');
  }

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