<?php
namespace Drupal\Tests\tmgmt\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\tmgmt\Functional\TmgmtEntityTestTrait;
use Drupal\Tests\tmgmt\Functional\TmgmtTestTrait;
class TmgmtContinuousJavascriptTest extends WebDriverTestBase {
use TmgmtTestTrait;
use TmgmtEntityTestTrait;
protected static $modules = array(
'tmgmt',
'tmgmt_test',
'tmgmt_content',
'node',
'block',
'locale',
);
protected $defaultTheme = 'stark';
function setUp() : void {
parent::setUp();
$this
->loginAsAdmin([
'translate any entity',
'create content translations',
]);
$this
->addLanguage('de');
$this
->addLanguage('es');
$this
->drupalPlaceBlock('system_breadcrumb_block');
$this
->createNodeType('page', 'Page', TRUE);
$this
->createNodeType('article', 'Article', TRUE);
}
public function testContinuousJobForm() {
$this
->createNodeType('page1', 'Enabled page', TRUE);
$this
->createNodeType('article1', 'Not enabled article', FALSE);
$node = $this
->createNode([
'type' => 'page',
]);
$edit = array(
'languages[de]' => TRUE,
'languages[es]' => TRUE,
);
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('node/' . $node
->id() . '/translations');
$this
->submitForm($edit, 'Request translation');
$assert_session
->pageTextContains('2 jobs need to be checked out.');
$assert_session
->pageTextContains('Submit all 2 translation jobs with the same settings');
$this
->drupalGet('admin/tmgmt/continuous_jobs/continuous_add');
$page
->selectFieldOption('Source language', 'de');
$assert_session
->assertWaitOnAjaxRequest();
$options = $this
->xpath('//*[@name="target_language"]/option');
$this
->assertCount(2, $options);
$this
->assertEquals('English', $options[0]
->getText());
$this
->assertEquals('Spanish', $options[1]
->getText());
$assert_session
->pageTextNotContains('jobs pending');
$assert_session
->pageTextNotContains('Submit all');
$assert_session
->responseNotContains('progress__track');
$continuous_job_label = strtolower($this
->randomMachineName());
$edit_job = [
'label[0][value]' => $continuous_job_label,
'target_language' => 'es',
'continuous_settings[content][node][enabled]' => TRUE,
];
$this
->submitForm($edit_job, 'Save job');
$this
->clickLink('Manage');
$assert_session
->pageTextContains('Enabled page');
$assert_session
->pageTextNotContains('Not enabled article');
}
}