public function DataCollectorTableTest::testDataCollectorTable in Charts 5.0.x
Same name and namespace in other branches
- 8.4 tests/src/FunctionalJavascript/DataCollectorTableTest.php \Drupal\Tests\charts\FunctionalJavascript\DataCollectorTableTest::testDataCollectorTable()
Tests the data collector table.
File
- tests/
src/ FunctionalJavascript/ DataCollectorTableTest.php, line 42
Class
- DataCollectorTableTest
- Tests the data collector table element.
Namespace
Drupal\Tests\charts\FunctionalJavascriptCode
public function testDataCollectorTable() {
$this
->drupalGet('/charts_test/data_collector_table_test_form');
$table_id_selector = static::TABLE_SELECTOR;
// Count generated rows.
$rows = $this
->cssSelect(static::TABLE_ROW_SELECTOR);
$this
->assertTrue(count($rows) === DataCollectorTableTestForm::INITIAL_ROWS, 'Expected rows were found.');
// Count generated columns.
// Only using the first row to count columns.
$columns = $this
->cssSelect(static::TABLE_COLUMN_SELECTOR);
$this
->assertTrue(count($columns) === DataCollectorTableTestForm::INITIAL_COLUMNS, 'Expected columns were found.');
// Fill the table.
$cell_input_selector = $table_id_selector . ' tr.data-collector-table--row td > .data-collector-table--row--cell .form-text';
$cell_inputs = $this
->cssSelect($cell_input_selector);
$this
->assertNotEmpty($cell_inputs, t('@count inputs were found', [
'@count' => count($cell_inputs),
]));
$this
->fillInputs($cell_inputs);
// Test adding a row.
$this
->doTableOperation('add', 'row');
// New row should not have any data.
$this
->assertNewCellIsEmpty('row');
// Test adding a column.
$this
->doTableOperation('add', 'column');
// New column should not have any data.
$this
->assertNewCellIsEmpty('column');
// Delete second and third row.
$this
->doTableOperation('delete', 'row', [
2,
3,
]);
// Remove middle column.
$this
->doTableOperation('delete', 'column', [
2,
]);
// Import csv from resources - not passing complaining file not found.
// $file_input_selector = 'files[series]';
// $file_input = $this->getSession()
// ->getPage()
// ->find('css', '[name="' . $file_input_selector . '"]');
// $file_input->setValue($this->getResourcesUrl() .
// '/csv/first_column.csv');
// $this->prepareRequest();
// code/web/modules/custom/charts/tests/resources/csv/first_row.csv.
// $button_selector = 'details[data-drupal-selector="edit-import"].
// Input[value="Upload CSV"]';
// $page = $this->getSession()->getPage();
// $path = $this->getResourcesUrl() . '/csv/first_column.csv';
// $page->attachFileToField($file_input_selector, $path);
// $this->pressAjaxButton($button_selector);
// $web_assert = $this->assertSession();
// $web_assert->assertWaitOnAjaxRequest(20000);
// $page = $this->getSession()->getPage();
// Count rows
// $targets = $page->findAll('css', static::TABLE_ROW_SELECTOR);
// $this->assertTrue(count($targets) === 7);
// Count columns
// $targets = $page->findAll('css', static::TABLE_COLUMN_SELECTOR);
// $this->assertTrue(count($targets) === 3);
// Delete all the rows and columns - skip for now.
// Confirm that only one row and column left - skip.
// Submit the form and verify the submitted data. - skip.
}