function TourLegacyTest::assertToolTipMarkup

Asserts the markup structure of a tip.

@internal

Parameters

int $index: The position of the tip within the tour.

string $nub_position: The expected position of the nub arrow.

string $joyride_content_container_name: For identifying classnames specific to a tip type.

1 call to TourLegacyTest::assertToolTipMarkup()
TourLegacyTest::testTourTipMarkup in core/modules/tour/tests/src/FunctionalJavascript/TourLegacyTest.php
Confirms backwards compatible markup.

File

core/modules/tour/tests/src/FunctionalJavascript/TourLegacyTest.php, line 98

Class

TourLegacyTest
Tests Tour's backwards compatible markup and legacy config.

Namespace

Drupal\Tests\tour\FunctionalJavascript

Code

private function assertToolTipMarkup(int $index, string $nub_position, string $joyride_content_container_name = 'body') : void {
    $assert_session = $this->assertSession();
    $tip = $assert_session->waitForElementVisible('css', ".joyride-tip-guide[data-index=\"{$index}\"]");
    $this->assertNotNull($tip, 'The tour tip element is present.');
    $nub = $tip->find('css', ".joyride-tip-guide[data-index=\"{$index}\"] > .joyride-nub");
    $this->assertNotNull($nub, 'The nub element is present.');
    if (!empty($nub_position)) {
        $this->assertTrue($nub->hasClass($nub_position), 'The nub has a class that indicates its configured position.');
    }
    $content_wrapper = $tip->find('css', '.joyride-nub + .joyride-content-wrapper');
    $this->assertNotNull($content_wrapper, 'The joyride content wrapper exists, and is the next sibling of the nub.');
    $label = $tip->find('css', '.joyride-content-wrapper > h2.tour-tip-label:first-child');
    $this->assertNotNull($label, 'The tour tip label is an h2, and is the first child of the content wrapper.');
    $tip_content = $content_wrapper->find('css', "h2.tour-tip-label + p.tour-tip-{$joyride_content_container_name}");
    $this->assertNotNull($tip_content, 'The tip\'s main paragraph is the next sibling of the label, and has the expected wrapper class.');
    $tour_progress = $content_wrapper->find('css', "h2.tour-tip-label + p.tour-tip-{$joyride_content_container_name} ~ div.tour-progress");
    $this->assertNotNull($tour_progress, 'The div containing tour progress info is present, and is the next sibling of the main paragraph.');
    $next_item = $content_wrapper->find('css', ".tour-progress + a.joyride-next-tip.button.button--primary");
    $this->assertNotNull($next_item, 'The "Next" link is present, and the next sibling of the div containing progress info.');
    $close_tour = $content_wrapper->find('css', ".joyride-content-wrapper > a.joyride-close-tip:last-child");
    $this->assertNotNull($close_tour, 'The "Close" link is present, is an immediate child of the content wrapper, and is the last child.');
}

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