public function CollapseActionTest::testCollapsibleDefaultExpanded in Collapsiblock 4.x
Same name and namespace in other branches
- 3.x tests/src/FunctionalJavascript/CollapseActionTest.php \Drupal\Tests\collapsiblock\FunctionalJavascript\CollapseActionTest::testCollapsibleDefaultExpanded()
Test the "Collapsible, expanded by default" Block Collapse Behavior.
File
- tests/
src/ FunctionalJavascript/ CollapseActionTest.php, line 157
Class
- CollapseActionTest
- Test that collapse actions work as-intended.
Namespace
Drupal\Tests\collapsiblock\FunctionalJavascriptCode
public function testCollapsibleDefaultExpanded() {
// Set the collapse action.
$this
->setCollapsiblockBlockInstanceSetting($this->collapsiblockTestBlock, 2, 'collapse_action');
// Load a page that the block will be displayed on.
$this
->drupalLogin($this
->getCollapsiblockUnprivilegedUser());
$this
->drupalGet('<front>');
// Check that the block title and contents are initially visible.
$beforeTitle = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockTitleXpath);
$this
->assertNotNull($beforeTitle);
$this
->assertTrue($beforeTitle
->isVisible());
$beforeContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($beforeContent);
$this
->assertTrue($beforeContent
->isVisible());
// Click on the block title.
$this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockTitleXpath)
->click();
// Check that the block title is visible but the contents are not visible
// after the click.
$afterTitle = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockTitleXpath);
$this
->assertNotNull($afterTitle);
$this
->assertTrue($afterTitle
->isVisible());
$afterContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($afterContent);
$this
->assertFalse($afterContent
->isVisible());
}