public function LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved in Lingotek Translation 3.1.x
Same name in this branch
- 3.1.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.1.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
Same name and namespace in other branches
- 8.2 tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 4.0.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.0.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.2.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.3.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.4.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.5.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.6.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.7.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
- 3.8.x tests/src/FunctionalJavascript/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedFromTranslationIfSourceIsRemoved()
Paragraphs don't have a title, so we should disallow filtering by it.
File
- tests/
src/ FunctionalJavascript/ LingotekNodeParagraphsTranslationTest.php, line 176
Class
- LingotekNodeParagraphsTranslationTest
- @group lingotek @group legacy
Namespace
Drupal\Tests\lingotek\FunctionalJavascriptCode
public function testParagraphIsRemovedFromTranslationIfSourceIsRemoved() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$messages_locator = '.messages--status';
// This is a hack for avoiding writing different lingotek endpoint mocks.
\Drupal::state()
->set('lingotek.uploaded_content_type', 'node+paragraphs_multiple_before_removal');
// Add paragraphed content.
$this
->drupalGet('node/add/paragraphed_content_demo');
$page
->pressButton('field_paragraphs_demo_image_text_add_more');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->waitForElementVisible('css', '[name="field_paragraphs_demo[0][subform][field_text_demo][0][value]"]');
$page
->pressButton('field_paragraphs_demo_image_text_add_more');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->waitForElementVisible('css', '[name="field_paragraphs_demo[1][subform][field_text_demo][0][value]"]');
$page
->pressButton('field_paragraphs_demo_image_text_add_more');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->waitForElementVisible('css', '[name="field_paragraphs_demo[2][subform][field_text_demo][0][value]"]');
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool';
$edit['langcode[0][value]'] = 'en';
$edit['field_paragraphs_demo[0][subform][field_text_demo][0][value]'] = 'Llamas are very cool for the first time';
$edit['field_paragraphs_demo[1][subform][field_text_demo][0][value]'] = 'Llamas are very cool for the second time';
$edit['field_paragraphs_demo[2][subform][field_text_demo][0][value]'] = 'Llamas are very cool for the third time';
$edit['moderation_state[0][state]'] = 'published';
$this
->drupalPostForm(NULL, $edit, t('Save'));
// Check that only the configured fields have been uploaded, including metatags.
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->assertEqual($data['title'][0]['value'], 'Llamas are cool');
$this
->assertEqual($data['field_paragraphs_demo'][0]['field_text_demo'][0]['value'], 'Llamas are very cool for the first time');
$this
->assertEqual($data['field_paragraphs_demo'][1]['field_text_demo'][0]['value'], 'Llamas are very cool for the second time');
$this
->assertEqual($data['field_paragraphs_demo'][2]['field_text_demo'][0]['value'], 'Llamas are very cool for the third time');
// Check that the url used was the right one.
$uploaded_url = \Drupal::state()
->get('lingotek.uploaded_url');
$this
->assertIdentical(\Drupal::request()
->getUriForPath('/node/1'), $uploaded_url, 'The node url was used.');
// Check that the profile used was the right one.
$used_profile = \Drupal::state()
->get('lingotek.used_profile');
$this
->assertIdentical('automatic', $used_profile, 'The automatic profile was used.');
// Check that the translate tab is in the node.
$this
->drupalGet('node/1');
$this
->clickLink('Translate');
// The document should have been automatically uploaded, so let's check
// the upload status.
$toggle = $page
->find('css', 'li.dropbutton-toggle button');
$toggle
->click();
$dropButton = $page
->find('css', 'li.check-upload-status.dropbutton-action a');
$dropButton
->click();
// This is a batch process, wait to finish.
$assert_session
->waitForElementVisible('css', $messages_locator);
$assert_session
->elementTextContains('css', $messages_locator, 'The import for node Llamas are cool is complete.');
// Request translation.
$toggle = $page
->findAll('css', 'li.dropbutton-toggle button')[1];
$toggle
->click();
$dropButton = $page
->find('css', 'li.request-translation.dropbutton-action a');
$dropButton
->click();
// This is a batch process, wait to finish.
$assert_session
->waitForElementVisible('css', $messages_locator);
$assert_session
->elementTextContains('css', $messages_locator, "Locale 'es_AR' was added as a translation target for node Llamas are cool.");
// Check translation status.
$toggle = $page
->findAll('css', 'li.dropbutton-toggle button')[1];
$toggle
->click();
$dropButton = $page
->find('css', 'li.check-translation-status.dropbutton-action a');
$dropButton
->click();
// This is a batch process, wait to finish.
$assert_session
->waitForElementVisible('css', $messages_locator);
$assert_session
->elementTextContains('css', $messages_locator, 'The es_AR translation for node Llamas are cool is ready for download.');
// Download translation.
$toggle = $page
->findAll('css', 'li.dropbutton-toggle button')[1];
$toggle
->click();
$dropButton = $page
->find('css', 'li.download-completed-translation.dropbutton-action a');
$dropButton
->click();
// This is a batch process, wait to finish.
$assert_session
->waitForElementVisible('css', $messages_locator);
$assert_session
->elementTextContains('css', $messages_locator, 'The translation of node Llamas are cool into es_AR has been downloaded.');
// The content is translated and published.
$this
->clickLink('Las llamas son chulas');
$assert_session
->pageTextContains('Las llamas son chulas');
$assert_session
->pageTextContains('Las llamas son muy chulas por primera vez');
$assert_session
->pageTextContains('Las llamas son muy chulas por segunda vez');
$assert_session
->pageTextContains('Las llamas son muy chulas por tercera vez');
// This is a hack for avoiding writing different lingotek endpoint mocks.
\Drupal::state()
->set('lingotek.uploaded_content_type', 'node+paragraphs_multiple_after_removal');
$this
->drupalGet('node/1/edit');
$page
->pressButton('field_paragraphs_demo_1_remove');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->waitForElementVisible('named', [
'id_or_name',
'field_paragraphs_demo_1_confirm_remove',
]);
$page
->pressButton('field_paragraphs_demo_1_confirm_remove');
$assert_session
->assertWaitOnAjaxRequest();
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$edit['langcode[0][value]'] = 'en';
$edit['field_paragraphs_demo[0][subform][field_text_demo][0][value]'] = 'Llamas are very cool for the first time EDITED';
$edit['field_paragraphs_demo[2][subform][field_text_demo][0][value]'] = 'Llamas are very cool for the third time EDITED';
$this
->drupalPostForm(NULL, $edit, t('Save (this translation)'));
$assert_session
->pageTextContains('Llamas are cool EDITED');
$assert_session
->pageTextContains('Llamas are very cool for the first time EDITED');
$assert_session
->pageTextNotContains('Llamas are very cool for the second time EDITED');
$assert_session
->pageTextContains('Llamas are very cool for the third time EDITED');
// Check that the translate tab is in the node.
$this
->drupalGet('node/1');
$this
->clickLink('Translate');
// The document should have been automatically updated, so let's check
// the upload status.
$toggle = $page
->find('css', 'li.dropbutton-toggle button');
$toggle
->click();
$dropButton = $page
->find('css', 'li.check-upload-status.dropbutton-action a');
$dropButton
->click();
// This is a batch process, wait to finish.
$assert_session
->waitForElementVisible('css', $messages_locator);
$assert_session
->elementTextContains('css', $messages_locator, 'The import for node Llamas are cool EDITED is complete.');
// Check translation status.
$toggle = $page
->findAll('css', 'li.dropbutton-toggle button')[1];
$toggle
->click();
$dropButton = $page
->find('css', 'li.check-translation-status.dropbutton-action a');
$dropButton
->click();
// This is a batch process, wait to finish.
$assert_session
->waitForElementVisible('css', $messages_locator);
$assert_session
->elementTextContains('css', $messages_locator, 'The es_AR translation for node Llamas are cool EDITED is ready for download.');
// Download translation.
$toggle = $page
->findAll('css', 'li.dropbutton-toggle button')[1];
$toggle
->click();
$dropButton = $page
->find('css', 'li.download-completed-translation.dropbutton-action a');
$dropButton
->click();
// This is a batch process, wait to finish.
$assert_session
->waitForElementVisible('css', $messages_locator);
$assert_session
->elementTextContains('css', $messages_locator, 'The translation of node Llamas are cool EDITED into es_AR has been downloaded.');
// The content is translated and published.
$this
->clickLink('Las llamas son chulas EDITADO');
$assert_session
->pageTextContains('Las llamas son chulas EDITADO');
$assert_session
->pageTextContains('Las llamas son muy chulas por primera vez EDITADO.');
$assert_session
->pageTextNotContains('Las llamas son muy chulas por segunda vez EDITADO.');
$assert_session
->pageTextContains('Las llamas son muy chulas por tercera vez EDITADO.');
$assert_session
->pageTextNotContains('Las llamas son muy chulas por tercera vez.');
$paragraphs = $page
->findAll('css', '.paragraph');
$this
->assertCount(2, $paragraphs);
}