You are here

public function PanelizerTest::testResave in Lightning Layout 8

File

tests/src/FunctionalJavascript/PanelizerTest.php, line 82

Class

PanelizerTest
@group lightning_layout

Namespace

Drupal\Tests\lightning_layout\FunctionalJavascript

Code

public function testResave() {
  $account = $this
    ->drupalCreateUser([
    'create landing_page content',
    'edit own landing_page content',
    'access panels in-place editing',
    'administer panelizer node landing_page content',
    // This permission is needed to access the whos_online view.
    'access user profiles',
  ]);
  $this
    ->drupalLogin($account);
  $block_selector = '[data-block-plugin-id="views_block:who_s_online-who_s_online_block"]';
  $node = $this
    ->drupalCreateNode([
    'type' => 'landing_page',
    'uid' => $account
      ->id(),
  ]);
  $this
    ->drupalGet($node
    ->toUrl());

  // Panels IPE is enabled...
  $this
    ->assertSession()
    ->elementExists('css', '#panels-ipe-content');

  // ...and standard fields are not present on the default layout.
  $this
    ->assertSession()
    ->elementNotExists('css', '.field--name-uid');
  $this
    ->assertSession()
    ->elementNotExists('css', '.field--name-created');

  // Place the "Who's online" block into the layout and save it as a custom
  // override.
  $this
    ->getBlockForm('views_block:who_s_online-who_s_online_block', 'Lists (Views)')
    ->pressButton('Add');
  $this
    ->assertNotEmpty($this
    ->assertSession()
    ->waitForElement('css', $block_selector));
  $this
    ->getTray()
    ->clickLink('Save');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();

  // Edit the node, verify that the layout is a custom override, and re-save.
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->assertTrue($this
    ->assertSession()
    ->selectExists('Full content')
    ->hasAttribute('disabled'));
  $this
    ->assertSession()
    ->buttonExists('Save')
    ->press();

  // The "Who's online" block should still be there.
  $this
    ->assertSession()
    ->elementExists('css', $block_selector);
}