You are here

public function SlideTypeTest::testFadeAndSlideSlideType in Collapsiblock 3.x

Same name and namespace in other branches
  1. 4.x tests/src/FunctionalJavascript/SlideTypeTest.php \Drupal\Tests\collapsiblock\FunctionalJavascript\SlideTypeTest::testFadeAndSlideSlideType()

Test the "Fade and Slide" slide type does NOT set aria-hidden attributes.

File

tests/src/FunctionalJavascript/SlideTypeTest.php, line 60

Class

SlideTypeTest
Test the "Remember collapsed state on active pages" behavior.

Namespace

Drupal\Tests\collapsiblock\FunctionalJavascript

Code

public function testFadeAndSlideSlideType() {

  // Set the Default animation type to "Fade and slide"; then flush all caches
  // so the global configuration setting change will take effect.
  $this
    ->setCollapsiblockGlobalSetting(2, 'slide_type');
  drupal_flush_all_caches();

  // Load a page that the block will be displayed on.
  $this
    ->drupalLogin($this
    ->getCollapsiblockUnprivilegedUser());
  $this
    ->drupalGet('<front>');

  // Check that, initially, the aria-hidden attribute on the content wrapper
  // does not exist.
  $beforeContent = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockContentXpath);
  $this
    ->assertNotNull($beforeContent);
  $this
    ->assertFalse($beforeContent
    ->hasAttribute('aria-hidden'));

  // Click on the block title to collapse the block.
  $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockTitleXpath)
    ->click();

  // Check that, after hiding the block content, the aria-hidden attribute on
  // the content wrapper does not exist.
  $afterCollapseContent = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockContentXpath);
  $this
    ->assertNotNull($afterCollapseContent);
  $this
    ->assertFalse($afterCollapseContent
    ->hasAttribute('aria-hidden'));

  // Click on the block title to expand the block.
  $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockTitleXpath)
    ->click();

  // Check that, after showing the block content, the aria-hidden attribute on
  // the content wrapper does not exist.
  $afterReExpandContent = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockContentXpath);
  $this
    ->assertNotNull($afterReExpandContent);
  $this
    ->assertFalse($afterReExpandContent
    ->hasAttribute('aria-hidden'));
}