You are here

function TMGMTUiJavascriptTest::testItemRevision in Translation Management Tool 8

Test the Revisions of a job item.

@todo Will be extended with the diff support. @todo There will be another test that checks for changes and merges with diffs.

File

tests/src/FunctionalJavascript/TMGMTUiJavascriptTest.php, line 460

Class

TMGMTUiJavascriptTest
Verifies the UI of the review form.

Namespace

Drupal\Tests\tmgmt\FunctionalJavascript

Code

function testItemRevision() {
  $this
    ->loginAsAdmin();

  // Create a translator.
  $translator = $this
    ->createTranslator();

  // Create a job and attach to the translator.
  $job = $this
    ->createJob();
  $job->translator = $translator;
  $job->settings = array();
  $job
    ->save();
  $job
    ->setState(Job::STATE_ACTIVE);

  // Add item to the job.
  $item = $job
    ->addItem('test_source', 'test', 1);
  $this
    ->drupalGet('admin/tmgmt/jobs/');
  $this
    ->clickLink(t('Manage'));
  $this
    ->clickLink(t('View'));
  $edit = [
    'dummy|deep_nesting[translation]' => 'any_value',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->clickLink(t('Review'));
  $edit = [
    'dummy|deep_nesting[translation]' => 'any_different_value',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->clickLink(t('Review'));
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->pressButton('revert-dummy|deep_nesting');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->pageTextContains('Translation for dummy reverted to the latest version.');
  $this
    ->assertFieldByName('dummy|deep_nesting[translation]', 'any_value');
}