public function ScheduledTransitionModalFormJavascriptTest::testRevisionLogOverride in Scheduled Transitions 2.x
Tests revision logs.
File
- tests/
src/ FunctionalJavascript/ ScheduledTransitionModalFormJavascriptTest.php, line 48
Class
- ScheduledTransitionModalFormJavascriptTest
- Tests the route to add a new transition to an entity (modal form).
Namespace
Drupal\Tests\scheduled_transitions\FunctionalJavascriptCode
public function testRevisionLogOverride() {
// Enable users to override messages.
\Drupal::configFactory()
->getEditable('scheduled_transitions.settings')
->set('message_override', TRUE)
->save(TRUE);
$this
->enabledBundles([
[
'st_entity_test',
'st_entity_test',
],
]);
$workflow = $this
->createEditorialWorkflow();
$workflow
->getTypePlugin()
->addEntityTypeAndBundle('st_entity_test', 'st_entity_test');
$workflow
->save();
$currentUser = $this
->drupalCreateUser([
'administer st_entity_test entities',
'use editorial transition create_new_draft',
'use editorial transition publish',
'use editorial transition archive',
Permissions::addScheduledTransitionsPermission('st_entity_test', 'st_entity_test'),
]);
$this
->drupalLogin($currentUser);
$entity = ScheduledTransitionsTestEntity::create([
'type' => 'st_entity_test',
]);
$entity->name = 'revision 1';
$entity
->save();
$entity->name = 'revision 2';
$entity
->setNewRevision(TRUE);
$entity
->save();
$entity->name = 'revision 3';
$entity
->setNewRevision(TRUE);
$entity
->save();
$this
->drupalGet($entity
->toUrl());
// Access the modal directly.
$this
->drupalGet($entity
->toUrl(ScheduledTransitionsRouteProvider::LINK_TEMPLATE_ADD));
// Open the details element.
$this
->getSession()
->getPage()
->find('css', '#edit-revision-metadata-revision-log > summary')
->click();
// The default revision log is shown.
$this
->assertSession()
->pageTextContains('Scheduled transition: transitioning latest revision from Draft to - Unknown state -');
$this
->getSession()
->getPage()
->fillField('transition', 'archive');
$this
->getSession()
->getPage()
->pressButton('Reload preview');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->pageTextContains('Scheduled transition: transitioning latest revision from Draft to Archived');
$this
->getSession()
->getPage()
->fillField('revision', 2);
$this
->getSession()
->getPage()
->checkField('revision_metadata[revision_log][override]');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->getSession()
->getPage()
->fillField('revision_metadata[revision_log][custom][message]', 'Test message. Transitioning from revision #[scheduled-transitions:from-revision-id].');
$this
->getSession()
->getPage()
->pressButton('Reload preview');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->pageTextContains('Test message. Transitioning from revision #2');
}