class OliveroAvoidStorageUsingTest
Same name in this branch
- main core/tests/Drupal/FunctionalJavascriptTests/Theme/OliveroAvoidStorageUsingTest.php \Drupal\FunctionalJavascriptTests\Theme\OliveroAvoidStorageUsingTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalJavascriptTests/Theme/OliveroAvoidStorageUsingTest.php \Drupal\FunctionalJavascriptTests\Theme\OliveroAvoidStorageUsingTest
- 11.x core/themes/olivero/tests/src/FunctionalJavascript/OliveroAvoidStorageUsingTest.php \Drupal\Tests\olivero\FunctionalJavascript\OliveroAvoidStorageUsingTest
Tests usage of localStorage.
Attributes
#[Group('olivero')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\ExtensionListTestTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\olivero\FunctionalJavascript\OliveroAvoidStorageUsingTest extends \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\ExtensionListTestTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of OliveroAvoidStorageUsingTest
File
-
core/
themes/ olivero/ tests/ src/ FunctionalJavascript/ OliveroAvoidStorageUsingTest.php, line 14
Namespace
Drupal\Tests\olivero\FunctionalJavascriptView source
final class OliveroAvoidStorageUsingTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'node',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'olivero';
/**
* Tests use of localStorage.
*/
public function testStorageUsing() : void {
$this->drupalGet('<front>');
// Check if initial no storage item is written.
$this->assertJsCondition("localStorage.getItem('Drupal.olivero.stickyHeaderState') === null", 10000, 'Written not strictly necessary Drupal.olivero.stickyHeaderState to localStorage without consent.');
// Resize and scroll to show stickyHeaderToggleButton.
$session = $this->getSession();
$session->resizeWindow(1280, 1024);
$session->executeScript('window.scrollTo(0, 500);');
// Click stickyHeaderToggleButton.
$this->getSession()
->getPage()
->find('css', '.sticky-header-toggle')
->click();
// Test if localStorage is set now.
$this->assertJsCondition("localStorage.getItem('Drupal.olivero.stickyHeaderState') !== null");
// Click stickyHeaderToggleButton again.
$this->getSession()
->getPage()
->find('css', '.sticky-header-toggle')
->click();
// Storage item should be removed now.
$this->assertJsCondition("localStorage.getItem('Drupal.olivero.stickyHeaderState') === null", 10000, 'Storage item Drupal.olivero.stickyHeaderState should be removed.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.