You are here

public function GoogleAnalyticsEventTrackingJsTest::testClickTrackerConfig in Google Analytics Event Tracking 8

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/GoogleAnalyticsEventTrackingJsTest.php \Drupal\Tests\google_analytics_et\FunctionalJavascript\GoogleAnalyticsEventTrackingJsTest::testClickTrackerConfig()

Ensure a tracker config adds a click event to an element.

File

tests/src/FunctionalJavascript/GoogleAnalyticsEventTrackingJsTest.php, line 52

Class

GoogleAnalyticsEventTrackingJsTest
Google Analytics Event Tracking JavaScript tests.

Namespace

Drupal\Tests\google_analytics_et\FunctionalJavascript

Code

public function testClickTrackerConfig() {
  $web_assert = $this
    ->assertSession();
  $this
    ->drupalGet('<front>');
  $drupal_settings = $this
    ->getDrupalSettings();
  $this
    ->assertArrayNotHasKey('googleAnalyticsEt', $drupal_settings, 'No google analytics event trackers configured for front page.');
  $web_assert
    ->elementNotExists('xpath', "//[@data-google-analytics-et-processed = 'true']");
  $this
    ->drupalGet('/google_analytics_et_test/test');
  $drupal_settings = $this
    ->getDrupalSettings();
  $this
    ->assertArrayHasKey('googleAnalyticsEt', $drupal_settings, 'Google analytics event trackers configured for test page.');
  $web_assert
    ->elementExists('xpath', "//[@data-google-analytics-et-processed = 'true']");
}