function TableTest::testTableCaptionUi

Same name and namespace in other branches
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\TableTest::testTableCaptionUi()
  2. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\TableTest::testTableCaptionUi()

Tests creating a table with caption in the UI.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php, line 156

Class

TableTest
For testing the table plugin.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testTableCaptionUi() : void {
    $assert_session = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $this->drupalGet($this->host
        ->toUrl('edit-form'));
    $this->waitForEditor();
    // Add a table via the editor buttons.
    $table_button = $page->find('css', '.ck-dropdown button');
    $table_button->click();
    // Add a single table cell.
    $grid_button = $assert_session->waitForElementVisible('css', '.ck-insert-table-dropdown-grid-box[data-row="1"][data-column="1"]');
    $grid_button->click();
    // Confirm the table has been added and no caption is present.
    $this->assertNotNull($table_figure = $assert_session->waitForElementVisible('css', 'figure.table'));
    $assert_session->elementNotExists('css', 'figure.table > figcaption');
    // Enable captions and update caption content.
    $caption_button = $this->getBalloonButton('Toggle caption on');
    $caption_button->click();
    $caption = $assert_session->waitForElementVisible('css', 'figure.table > figcaption');
    $this->assertEmpty($caption->getText());
    $caption->setValue($this->captionText);
    $this->assertEquals($this->captionText, $caption->getText());
    // Update table cell content.
    $table_cell = $assert_session->waitForElement('css', '.ck-editor__nested-editable .ck-table-bogus-paragraph');
    $this->assertNotEmpty($table_cell);
    $table_cell->click();
    $table_cell->setValue($this->tableCellText);
    $table_cell = $page->find('css', 'figure.table > table > tbody > tr > td');
    $this->assertEquals($this->tableCellText, $table_cell->getText());
    $this->assertTableStructureInEditorData();
    // Disable caption, confirm the caption is no longer present.
    $table_figure->click();
    $caption_off_button = $this->getBalloonButton('Toggle caption off');
    $caption_off_button->click();
    $assert_session->assertNoElementAfterWait('css', 'figure.table > figcaption');
    // Re-enable caption and confirm the value was retained.
    $table_figure->click();
    $caption_on_button = $this->getBalloonButton('Toggle caption on');
    $caption_on_button->click();
    $caption = $assert_session->waitForElementVisible('css', 'figure.table > figcaption');
    $this->assertEquals($this->captionText, $caption->getText());
    $this->assertTableStructureInRenderedPage();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.