You are here

public function ModerationContext::assertInPlaceStateTransition in Lightning Workflow 8.2

Asserts that the moderation sidebar works.

@Then I should be able to transition to the :state_label state without leaving the page

Parameters

string $state_label: The label of the state to which to transition the node.

File

tests/contexts/ModerationContext.behat.inc, line 125

Class

ModerationContext
Contains miscellaneous step definitions for testing moderation UIs.

Namespace

Acquia\LightningExtension\Context

Code

public function assertInPlaceStateTransition($state_label) {
  Assert::notEmpty($this->node);
  $transition = $this
    ->getWorkflow()
    ->getTransitionFromStateToState($this->node->moderation_state->value, $this
    ->getStateId($state_label));
  $assert = $this
    ->assertSession();
  $toolbar = $assert
    ->elementExists('css', '#toolbar-bar');
  $toolbar
    ->clickLink('Tasks');
  $sidebar = $this
    ->awaitElement('.moderation-sidebar-container');

  // Assert that the review transition has the correct label.
  // @see \Drupal\lightning_workflow\Update\Update230
  // @see lightning_workflow_install()
  $assert
    ->elementExists('named', [
    'button',
    'Send to review',
  ], $sidebar);
  $sidebar
    ->pressButton($transition
    ->label());
  $assert
    ->pageTextContains('The moderation state has been updated.');
  $current_state = $assert
    ->elementExists('named', [
    'link',
    'Tasks',
  ], $toolbar)
    ->getAttribute('data-label');
  Assert::same($current_state, $transition
    ->to()
    ->label());
}