Test continuous job form improvements.
public function testContinuousJobForm() {
// Create two new node types one not enabled for translation.
$this
->createNodeType('page1', 'Enabled page', TRUE);
$this
->createNodeType('article1', 'Not enabled article', FALSE);
// Create a page, request a translation for de and es to initiate a
// checkout queue.
$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');
// Create continuous job through the form.
$this
->drupalGet('admin/tmgmt/continuous_jobs/continuous_add');
// Test we don't have selected source language in target language dropdown.
$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());
// Make sure that no checkout queue UI elements are shown.
$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');
// Check we don't see not enabled article in content type list.
$this
->clickLink('Manage');
$assert_session
->pageTextContains('Enabled page');
$assert_session
->pageTextNotContains('Not enabled article');
}