You are here

function ContentTmgmtEntitySourceUiTest::testNodeTranslateTabMultipleCheckoutUnsupported in Translation Management Tool 8

Test job submission of multiple jobs with an unsupported language

File

sources/content/tests/src/Functional/ContentTmgmtEntitySourceUiTest.php, line 378

Class

ContentTmgmtEntitySourceUiTest
Content entity source UI tests.

Namespace

Drupal\Tests\tmgmt_content\Functional

Code

function testNodeTranslateTabMultipleCheckoutUnsupported() {

  // Allow auto-accept.
  $default_translator = Translator::load('test_translator');
  $default_translator
    ->setAutoAccept(TRUE)
    ->save();
  $this
    ->loginAsTranslator([
    'translate any entity',
    'create content translations',
  ]);

  // Create an english source node.
  $node = $this
    ->createTranslatableNode('page', 'en');

  // Go to the translate tab.
  $this
    ->drupalGet('node/' . $node
    ->id());
  $this
    ->clickLink('Translate');

  // Assert some basic strings on that page.
  $this
    ->assertText(t('Translations of @title', [
    '@title' => $node
      ->getTitle(),
  ]));
  $this
    ->assertText(t('Pending Translations'));

  // Request a translation for german, spanish and french.
  $edit = [
    'languages[de]' => TRUE,
    'languages[es]' => TRUE,
    'languages[el]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Request translation'));

  // Verify that we are on the translate tab.
  $this
    ->assertText(t('3 jobs need to be checked out.'));

  // Assert progress bar.
  $this
    ->assertText('3 jobs pending');
  $this
    ->assertText($node
    ->label() . ', English to German');
  $this
    ->assertText($node
    ->label() . ', English to Spanish');
  $this
    ->assertText($node
    ->label() . ', English to Greek');
  $this
    ->assertRaw('progress__track');
  $this
    ->assertRaw('<div class="progress__bar" style="width: 3%"></div>');

  // Submit all jobs.
  $edit = [
    'submit_all' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Submit to provider and continue'));

  // Assert messages.
  $this
    ->assertText('Test translation created.');
  $this
    ->assertText('The translation job has been finished.');
  $this
    ->assertText('The translation for ' . $node
    ->label() . ' has been accepted as de(de-ch): ' . $node
    ->label() . '.');
  $this
    ->assertText('The translation for ' . $node
    ->label() . ' has been accepted as es: ' . $node
    ->label() . '.');
  $this
    ->assertText('Job ' . $node
    ->label() . ' is not translatable with the chosen settings: Test provider can not translate from English to Greek.');

  // Assert progress bar.
  $this
    ->assertText('1 job pending');
  $this
    ->assertNoText($node
    ->label() . ', English to German');
  $this
    ->assertNoText($node
    ->label() . ', English to Spanish');
  $this
    ->assertText($node
    ->label() . ', English to Greek');
  $this
    ->assertRaw('progress__track');
  $this
    ->assertRaw('<div class="progress__bar" style="width: 67%"></div>');
}