function ContentTmgmtEntitySourceUiTest::testNodeTranslateTabMultipleCheckoutUnsupported

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
    ->assertSession()
    ->pageTextContains(t('Translations of @title', [
    '@title' => $node
      ->getTitle(),
  ]));
  $this
    ->assertSession()
    ->pageTextContains('Pending Translations');

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

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

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

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

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

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