function TMGMTUiJavascriptTest::testItemRevision

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 463

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('Manage');
  $this
    ->clickLink('View');
  $edit = [
    'dummy|deep_nesting[translation]' => 'any_value',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->clickLink('Review');
  $edit = [
    'dummy|deep_nesting[translation]' => 'any_different_value',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->clickLink('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
    ->assertSession()
    ->fieldValueEquals('dummy|deep_nesting[translation]', 'any_value');
}