You are here

public function UiTest::testUi in Lightning Scheduler 8

File

tests/src/FunctionalJavascript/UiTest.php, line 44

Class

UiTest
@group lightning_scheduler

Namespace

Drupal\Tests\lightning_scheduler\FunctionalJavascript

Code

public function testUi() {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->createContentType([
    'type' => 'page',
  ]);
  $workflow = $this
    ->createEditorialWorkflow();
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'page');
  $workflow
    ->save();
  $account = $this
    ->createUser([
    'create page content',
    'view own unpublished content',
    'edit own page content',
    'use editorial transition create_new_draft',
    'schedule editorial transition publish',
    'schedule editorial transition archive',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('/node/add/page');
  $page
    ->fillField('Title', $this
    ->randomString());
  $this
    ->createTransition('Published', mktime(18, 0, 0, 5, 4, 2038));
  $this
    ->createTransition('Archived', mktime(8, 57, 0, 9, 19, 2038));
  $page
    ->pressButton('Save');
  $this
    ->clickEditLink();
  $assert_session
    ->pageTextContains("Change to Published on May 4, 2038 at 6:00 PM");
  $assert_session
    ->pageTextContains("Change to Archived on September 19, 2038 at 8:57 AM");
  $page
    ->clickLink('Remove transition to Archived on September 19, 2038 at 8:57 AM');
  $assert_session
    ->pageTextContains("Change to Published on May 4, 2038 at 6:00 PM");
  $assert_session
    ->pageTextNotContains("Change to Archived on September 19, 2038 at 8:57 AM");
  $assert_session
    ->linkExists('add another');
  $page
    ->pressButton('Save');
  $this
    ->clickEditLink();
  $assert_session
    ->pageTextContains("Change to Published on May 4, 2038 at 6:00 PM");
  $assert_session
    ->pageTextNotContains("Change to Archived on September 19, 2038 at 8:57 AM");
  $this
    ->createTransition('Archived', mktime(8, 57, 0, 9, 19, 2038), FALSE);
  $assert_session
    ->linkExists('Cancel transition');
  $assert_session
    ->pageTextContains("Change to Published on May 4, 2038 at 6:00 PM");
  $assert_session
    ->pageTextNotContains("Change to Archived on September 19, 2038 at 8:57 AM");
  $page
    ->pressButton('Save');
  $this
    ->clickEditLink();
  $assert_session
    ->pageTextContains("Change to Published on May 4, 2038 at 6:00 PM");
  $assert_session
    ->pageTextNotContains("Change to Archived on September 19, 2038 at 8:57 AM");
  $page
    ->clickLink('Remove transition to Published on May 4, 2038 at 6:00 PM');
  $assert_session
    ->pageTextNotContains("Change to Published on May 4, 2038 at 6:00 PM");
  $assert_session
    ->linkExists('Schedule a status change');
}