function OffCanvasTest::assertOffCanvasDialog

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php \Drupal\Tests\system\FunctionalJavascript\OffCanvasTest::assertOffCanvasDialog()
  2. 10 core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php \Drupal\Tests\system\FunctionalJavascript\OffCanvasTest::assertOffCanvasDialog()
  3. 11.x core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php \Drupal\Tests\system\FunctionalJavascript\OffCanvasTest::assertOffCanvasDialog()

@internal

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 156

Class

OffCanvasTest
Tests the off-canvas dialog functionality.

Namespace

Drupal\Tests\system\FunctionalJavascript

Code

protected function assertOffCanvasDialog(int $link_index, string $position) : void {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.