You are here

protected function OffCanvasTest::assertOffCanvasDialog in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php \Drupal\Tests\system\FunctionalJavascript\OffCanvasTest::assertOffCanvasDialog()

Parameters

int $link_index: The index of the link to test.

string $position: The position of the dialog to test.

1 call to OffCanvasTest::assertOffCanvasDialog()
OffCanvasTest::testOffCanvasLinks in core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php
Tests that non-contextual links will work with the off-canvas dialog.

File

core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php, line 154

Class

OffCanvasTest
Tests the off-canvas dialog functionality.

Namespace

Drupal\Tests\system\FunctionalJavascript

Code

protected function assertOffCanvasDialog($link_index, $position) {
  $page = $this
    ->getSession()
    ->getPage();
  $web_assert = $this
    ->assertSession();
  $link_text = "Open {$position} panel {$link_index}";

  // Click the first test like that should open the page.
  $page
    ->clickLink($link_text);
  if ($this->lastDialogClass) {
    $web_assert
      ->assertNoElementAfterWait('css', '.' . $this->lastDialogClass);
  }
  $this
    ->waitForOffCanvasToOpen($position);
  $this->lastDialogClass = "{$position}-{$link_index}";

  // Check that response text is on page.
  $web_assert
    ->pageTextContains("Thing {$link_index} says hello");
  $off_canvas_tray = $this
    ->getOffCanvasDialog();

  // Check that tray is visible.
  $this
    ->assertEquals(TRUE, $off_canvas_tray
    ->isVisible());
  $tray_text = $off_canvas_tray
    ->findById('drupal-off-canvas')
    ->getText();
  $this
    ->assertEquals("Thing {$link_index} says hello", $tray_text);
}