You are here

public function MessageSubscribeEmailTest::testUi in Message Subscribe 8

Tests the flag/unflag UI.

File

message_subscribe_email/tests/src/FunctionalJavascript/MessageSubscribeEmailTest.php, line 77

Class

MessageSubscribeEmailTest
Javascript tests for message subscribe email.

Namespace

Drupal\Tests\message_subscribe_email\FunctionalJavascript

Code

public function testUi() {
  $flag = $this->flagService
    ->getFlagById('subscribe_node');
  $this
    ->drupalLogin($this->users[2]);
  $this
    ->drupalGet($this->nodes[2]
    ->toUrl());

  // Subscribe to the node.
  $this
    ->clickLink(t('Subscribe'));
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertTrue($this->flagService
    ->getFlagging($flag, $this->nodes[2], $this->users[2]));

  // Unsubscribe from the node.
  $this
    ->clickLink(t('Unsubscribe'));
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertFalse($this->flagService
    ->getFlagging($flag, $this->nodes[2], $this->users[2]));

  // Subscribe again!
  $this
    ->clickLink(t('Subscribe'));
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertTrue($this->flagService
    ->getFlagging($flag, $this->nodes[2], $this->users[2]));
}