You are here

public function PageManagerIntegrationTest::testUserEditSession in Panels 8.4

Tests that the IPE editing session is specific to a user.

File

panels_ipe/tests/src/FunctionalJavascript/PageManagerIntegrationTest.php, line 64

Class

PageManagerIntegrationTest
Tests the JavaScript functionality of Panels IPE with PageManager.

Namespace

Drupal\Tests\panels_ipe\FunctionalJavascript

Code

public function testUserEditSession() {
  $this
    ->visitIPERoute();
  $this
    ->assertSession()
    ->elementExists('css', '.layout--onecol');

  // Change the layout to lock the IPE.
  $this
    ->changeLayout('Columns: 2', 'layout_twocol');
  $this
    ->assertSession()
    ->elementExists('css', '.layout--twocol');
  $this
    ->assertSession()
    ->elementNotExists('css', '.layout--onecol');
  $this
    ->assertSession()
    ->elementExists('css', '[data-tab-id="save"]');

  // Ensure the second user does not see the session of the other user.
  $this
    ->drupalLogin($this->user2);
  $this
    ->visitIPERoute();
  $this
    ->assertSession()
    ->elementExists('css', '.layout--onecol');
  $this
    ->assertSession()
    ->elementNotExists('css', '.layout--twocol');

  // Ensure the IPE is locked.
  $this
    ->assertSession()
    ->elementNotExists('css', '[data-tab-id="edit"]');
  $this
    ->assertSession()
    ->elementExists('css', '[data-tab-id="locked"]');

  // Click the break lock button.
  $this
    ->breakLock();
  $this
    ->assertSession()
    ->waitForElementVisible('css', '[data-tab-id="edit"]');

  // Log back in as the first user to find the edits gone.
  $this
    ->drupalLogin($this->user1);
  $this
    ->visitIPERoute();
  $this
    ->assertSession()
    ->elementExists('css', '[data-tab-id="edit"]');
  $this
    ->assertSession()
    ->elementNotExists('css', '[data-tab-id="save"]');
  $this
    ->assertSession()
    ->elementExists('css', '.layout--onecol');
}