ClaroViewsUiTest.php in Drupal 10
File
core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsUiTest.php
View source
<?php
namespace Drupal\FunctionalJavascriptTests\Theme;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class ClaroViewsUiTest extends WebDriverTestBase {
protected static $modules = [
'views_ui',
];
protected $defaultTheme = 'claro';
protected function setUp() : void {
parent::setUp();
$this
->config('views.settings')
->set('ui.always_live_preview', FALSE)
->save();
$admin_user = $this
->drupalCreateUser([
'administer views',
'access administration pages',
'view the administration theme',
]);
$this
->drupalLogin($admin_user);
}
public function testViewsUiTabsCssClasses() {
$this
->drupalGet('admin/structure/views/view/who_s_online');
$assert_session = $this
->assertSession();
$assert_session
->elementExists('css', '#views-display-menu-tabs.views-tabs.views-tabs--secondary');
$assert_session
->elementExists('css', '#edit-display-settings-top .views-display-setting a')
->click();
$this
->assertNotNull($this
->assertSession()
->waitForElement('css', '.js-views-ui-dialog'));
$assert_session
->elementExists('css', '.js-views-ui-dialog .ui-dialog-buttonpane')
->findButton('Apply')
->press();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementExists('css', '#views-display-menu-tabs.views-tabs.views-tabs--secondary');
}
public function testViewsUiDropButtonCssClasses() {
$this
->drupalGet('admin/structure/views/view/who_s_online');
$assert_session = $this
->assertSession();
$extra_actions_dropbutton_list = $assert_session
->elementExists('css', '#views-display-extra-actions.dropbutton--small');
$list_item_selectors = [
'li:first-child',
'li:last-child',
];
foreach ($list_item_selectors as $list_item_selector) {
$this
->assertNotNull($extra_actions_dropbutton_list
->find('css', "{$list_item_selector}.dropbutton__item"));
}
$assert_session
->elementExists('css', '#edit-display-settings-top .views-display-setting a')
->click();
$this
->assertNotNull($this
->assertSession()
->waitForElement('css', '.js-views-ui-dialog'));
$assert_session
->elementExists('css', '.js-views-ui-dialog .ui-dialog-buttonpane')
->findButton('Apply')
->press();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertTrue($extra_actions_dropbutton_list
->hasClass('dropbutton--small'));
foreach ($list_item_selectors as $list_item_selector) {
$this
->assertNotNull($extra_actions_dropbutton_list
->find('css', "{$list_item_selector}.dropbutton__item"));
}
}
}