You are here

public function LingotekSourceActionsTest::testDropdownSourceStatus in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 4.0.x tests/src/FunctionalJavascript/LingotekSourceActionsTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekSourceActionsTest::testDropdownSourceStatus()

File

tests/src/FunctionalJavascript/LingotekSourceActionsTest.php, line 46

Class

LingotekSourceActionsTest
@group lingotek

Namespace

Drupal\Tests\lingotek\FunctionalJavascript

Code

public function testDropdownSourceStatus() {
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet('node/add/article');
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
  $translationService = \Drupal::service('lingotek.content_translation');
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $buttonLocator = 'button.lingotek-source-dropdown-toggle';
  $listLocator = 'ul.lingotek-source-actions';

  // There are two dropdowns.
  $assert_session
    ->elementsCount('css', $buttonLocator, 1);
  $assert_session
    ->elementsCount('css', $listLocator, 1);
  $lists = $page
    ->findAll('css', $listLocator);
  $visibleLists = $this
    ->filterVisibleElements($lists);
  $this
    ->assertCount(0, $visibleLists);
  $button_field = $assert_session
    ->elementExists('css', $buttonLocator);
  $button_field
    ->click();
  $listShown = $this
    ->waitForVisibleElementCount(1, $listLocator);
  $this
    ->assertTrue($listShown);
  $visibleLists = $this
    ->filterVisibleElements($lists);
  $this
    ->assertCount(1, $visibleLists);
}