function AggregationAjaxTest::setFieldAggregationFunction

Same name and namespace in other branches
  1. 11.x core/modules/views_ui/tests/src/FunctionalJavascript/AggregationAjaxTest.php \Drupal\Tests\views_ui\FunctionalJavascript\AggregationAjaxTest::setFieldAggregationFunction()

Opens the aggregation settings dialog and applies an aggregation function to the 'changed' field.

Parameters

string $group_type: The aggregation function to select, e.g. 'count' or 'count_distinct'.

File

core/modules/views_ui/tests/src/FunctionalJavascript/AggregationAjaxTest.php, line 133

Class

AggregationAjaxTest
Tests editing a field's aggregation function via AJAX.

Namespace

Drupal\Tests\views_ui\FunctionalJavascript

Code

protected function setFieldAggregationFunction(string $group_type) : void {
  $page = $this->getSession()
    ->getPage();
  $assert_session = $this->assertSession();
  // Opens Aggregation settings dialog.
  $page->clickLink('Aggregation settings');
  $this->assertNotEmpty($assert_session->waitForElementVisible('css', '.views-ui-dialog'), sprintf('The aggregation settings dialog did not open while setting "%s".', $group_type));
  $assert_session->fieldExists('options[group_type]');
  $page->selectFieldOption('options[group_type]', $group_type);
  $this->pressDialogButton('Apply');
  // Check if the settings dialog closes.
  $this->assertNotEmpty($assert_session->waitForElementRemoved('css', '.views-ui-dialog'), sprintf('The aggregation settings dialog is still open after setting "%s".', $group_type));
  // Check for the AJAX error message.
  $assert_session->pageTextNotContains(static::AJAX_ERROR_MESSAGE);
}

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