hasUncheckedField example


  public function testSettingsOnlyFireAjaxWithCkeditor5() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();
    $this->addNewTextFormat($page$assert_session);
    $this->addNewTextFormat($page$assert_session, 'unicorn');

    $this->drupalGet('admin/config/content/formats/manage/ckeditor5');

    // Enable media embed to trigger an AJAX rebuild.     $this->assertTrue($page->hasUncheckedField('filters[media_embed][status]'));
    $this->assertSame(0, $this->getAjaxResponseCount());
    $page->checkField('filters[media_embed][status]');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertSame(1, $this->getAjaxResponseCount());

    // Perform the same steps as above with CKEditor, and confirm AJAX callbacks     // are not triggered on settings changes.     $this->drupalGet('admin/config/content/formats/manage/unicorn');

    // Enable media embed to confirm a format not using CKEditor 5 will not     // trigger an AJAX rebuild.
$this->assertSame([
      'Paragraph',
      'Heading 2',
      'Heading 3',
      'Heading 4',
      'Heading 5',
      'Heading 6',
    ]$available_headings);

    $this->drupalGet('admin/config/content/formats/manage/ckeditor5');
    $this->assertTrue($page->hasUncheckedField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading1]'));
    $page->checkField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading1]');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertTrue($page->hasCheckedField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading1]'));
    $this->assertTrue($page->hasCheckedField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading2]'));
    $page->uncheckField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading2]');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertTrue($page->hasUncheckedField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading2]'));
    $this->assertTrue($page->hasCheckedField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading4]'));
    $page->uncheckField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading4]');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertTrue($page->hasUncheckedField('editor[settings][plugins][ckeditor5_heading][enabled_headings][heading4]'));
    
$this->sortableAfter($links_block$body_block$region_content);
    $assert_session->assertWaitOnAjaxRequest();

    // Check that the drag-triggered rebuild did not trigger content preview.     $assert_session->pageTextNotContains($content_preview_body_text);

    // Check that drag successfully repositioned blocks.     $this->assertOrderInPage([$body_field_placeholder_label$links_field_placeholder_label]);

    // Check if block position maintained after enabling content preview.     $this->assertTrue($page->hasUncheckedField('layout-builder-content-preview'));
    $page->checkField('layout-builder-content-preview');
    $this->assertNotEmpty($assert_session->waitForText($content_preview_body_text));
    $assert_session->pageTextContains($content_preview_body_text);
    $this->assertNotEmpty($assert_session->waitForText('Placeholder for the "Links" field'));
    $this->assertOrderInPage([$content_preview_body_text, 'Placeholder for the "Links" field']);
  }

  /** * Checks if contextual links are working properly. * * @internal */
/** * Confirm that switching to CKEditor 5 from another editor updates tags. */
  public function testSwitchToVersion5() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->createNewTextFormat($page$assert_session, 'unicorn');
    $assert_session->assertWaitOnAjaxRequest();

    // Enable the HTML filter.     $this->assertTrue($page->hasUncheckedField('filters[filter_html][status]'));
    $page->checkField('filters[filter_html][status]');
    $assert_session->assertWaitOnAjaxRequest();

    // Confirm the allowed HTML tags are the defaults initially.     $this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $this->defaultElementsWhenUpdatingNotCkeditor5);

    $this->saveNewTextFormat($page$assert_session);
    $assert_session->pageTextContains('Added text format unicorn');

    // Return to the config form to confirm that switching text editors on     // existing formats will properly switch allowed tags.

  public function createNewTextFormat($page$assert_session$name = 'ckeditor5') {
    $this->drupalGet('admin/config/content/formats/add');
    $page->fillField('name', $name);
    $assert_session->waitForText('Machine name');
    $this->assertNotEmpty($assert_session->waitForText($name));
    $page->checkField('roles[authenticated]');

    if ($name === 'ckeditor5') {
      // Enable the HTML filter, at least one HTML restricting filter is needed       // before CKEditor 5 can be enabled.       $this->assertTrue($page->hasUncheckedField('filters[filter_html][status]'));
      $page->checkField('filters[filter_html][status]');
      $assert_session->assertWaitOnAjaxRequest();

      // Add the tags that must be included in the html filter for CKEditor 5.       $allowed_html_field = $assert_session->fieldExists('filters[filter_html][settings][allowed_html]');
      $allowed_html_field->setValue('<p> <br>');
    }
    $page->selectFieldOption('editor[editor]', $name);
  }

  /** * Save the new text format. */
/** * Tests the presence of ajax functionality for all options. */
  public function testAjax() {
    // Test checkboxes (#multiple == TRUE).     $this->drupalGet('form_test/tableselect/multiple-true');
    $session = $this->getSession();
    $page = $session->getPage();
    for ($i = 1; $i <= 3; $i++) {
      $row = 'row' . $i;
      $page->hasUncheckedField($row);
      $page->checkField($row);
      $this->assertSession()->assertWaitOnAjaxRequest();
      // Check current row and previous rows are checked.       for ($j = 1; $j <= $i$j++) {
        $other_row = 'row' . $j;
        $page->hasCheckedField($other_row);
      }
    }

    // Test radios (#multiple == FALSE).     $this->drupalGet('form_test/tableselect/multiple-false');
    
Home | Imprint | This part of the site doesn't use cookies.