public function DisplayTest::testRenameDisplayAdminName in Drupal 10
Tests setting the administrative title.
File
- core/
modules/ views_ui/ tests/ src/ FunctionalJavascript/ DisplayTest.php, line 87
Class
- DisplayTest
- Tests the display UI.
Namespace
Drupal\Tests\views_ui\FunctionalJavascriptCode
public function testRenameDisplayAdminName() {
$titles = [
'New admin title',
'</title><script>alert("alert!")</script>',
];
foreach ($titles as $new_title) {
$this
->drupalGet('admin/structure/views/view/test_content_ajax');
$page = $this
->getSession()
->getPage();
$page
->findLink('Edit view name/description')
->click();
$this
->getSession()
->executeScript("document.title = 'Initial title | " . \Drupal::config('system.site')
->get('name') . "'");
$admin_name_field = $this
->assertSession()
->waitForField('Administrative name');
$dialog_buttons = $page
->find('css', '.ui-dialog-buttonset');
$admin_name_field
->setValue($new_title);
$dialog_buttons
->pressButton('Apply');
$this
->assertJsCondition("document.title === '" . $new_title . " (Content) | " . \Drupal::config('system.site')
->get('name') . "'");
}
}