You are here

public function ResponsivePreviewTest::testContentEdit in Responsive Theme Preview 8

Tests that preview works on node edit.

File

tests/src/FunctionalJavascript/ResponsivePreviewTest.php, line 78

Class

ResponsivePreviewTest
Tests the toolbar integration.

Namespace

Drupal\Tests\responsive_preview\FunctionalJavascript

Code

public function testContentEdit() {
  $this
    ->drupalLogin($this->previewUser);
  $node = Node::create([
    'type' => 'article',
    'uid' => $this->previewUser
      ->id(),
    'title' => $this
      ->randomString(),
  ]);
  $node
    ->save();
  $this
    ->drupalGet('node/' . $node
    ->id() . '/edit');
  $this
    ->selectDevice('(//*[@id="responsive-preview-toolbar-tab"]//button[@data-responsive-preview-name])[1]');
  $this
    ->assertSession()
    ->elementNotExists('xpath', '//*[@id="responsive-preview-orientation" and contains(@class, "rotated")]');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertTrue($this
    ->getSession()
    ->evaluateScript("jQuery('#responsive-preview-frame')[0].contentWindow.location.href.endsWith('/node/preview/" . $node
    ->uuid() . "/full')"));
}