Issue #3469573 by catch, pooja_sharma: Speed up ElementTest

merge-requests/4676/merge
nod_ 2024-08-22 10:15:16 +02:00
parent de6e4c69e5
commit 6aae927629
No known key found for this signature in database
GPG Key ID: 76624892606FA197
1 changed files with 26 additions and 11 deletions

View File

@ -10,7 +10,6 @@ use Drupal\Tests\BrowserTestBase;
* Tests building and processing of core form elements.
*
* @group Form
* @group #slow
*/
class ElementTest extends BrowserTestBase {
@ -26,10 +25,26 @@ class ElementTest extends BrowserTestBase {
*/
protected $defaultTheme = 'starterkit_theme';
/**
* Test form elements.
*/
public function testFormElements(): void {
$this->testPlaceHolderText();
$this->testOptions();
$this->testRadiosChecked();
$this->testWrapperIds();
$this->testButtonClasses();
$this->testGroupElements();
$this->testRequiredFieldsetsAndDetails();
$this->testFormAutocomplete();
$this->testFormElementErrors();
$this->testDetailsSummaryAttributes();
}
/**
* Tests placeholder text for elements that support placeholders.
*/
public function testPlaceHolderText(): void {
protected function testPlaceHolderText(): void {
$this->drupalGet('form-test/placeholder-text');
foreach (['textfield', 'tel', 'url', 'password', 'email', 'number', 'textarea'] as $type) {
$field = $this->assertSession()->fieldExists("edit-$type");
@ -40,7 +55,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests expansion of #options for #type checkboxes and radios.
*/
public function testOptions(): void {
protected function testOptions(): void {
$this->drupalGet('form-test/checkboxes-radios');
// Verify that all options appear in their defined order.
@ -81,7 +96,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests correct checked attribute for radios element.
*/
public function testRadiosChecked(): void {
protected function testRadiosChecked(): void {
// Verify that there is only one radio option checked.
$this->drupalGet('form-test/radios-checked');
$this->assertSession()->elementsCount('xpath', '//input[@name="radios" and @checked]', 1);
@ -110,7 +125,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests wrapper ids for checkboxes and radios.
*/
public function testWrapperIds(): void {
protected function testWrapperIds(): void {
$this->drupalGet('form-test/checkboxes-radios');
// Verify that wrapper id is different from element id.
@ -124,7 +139,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests button classes.
*/
public function testButtonClasses(): void {
protected function testButtonClasses(): void {
$this->drupalGet('form-test/button-class');
// Just contains(@class, "button") won't do because then
// "button--foo" would contain "button". Instead, check
@ -138,7 +153,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests the #group property.
*/
public function testGroupElements(): void {
protected function testGroupElements(): void {
$this->drupalGet('form-test/group-details');
$this->assertSession()->elementsCount('xpath', '//div[@class="details-wrapper"]//div[@class="details-wrapper"]//label', 1);
$this->drupalGet('form-test/group-container');
@ -154,7 +169,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests the #required property on details and fieldset elements.
*/
public function testRequiredFieldsetsAndDetails(): void {
protected function testRequiredFieldsetsAndDetails(): void {
$this->drupalGet('form-test/group-details');
$this->assertEmpty($this->cssSelect('summary.form-required'));
$this->drupalGet('form-test/group-details/1');
@ -168,7 +183,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests a form with an autocomplete setting..
*/
public function testFormAutocomplete(): void {
protected function testFormAutocomplete(): void {
$this->drupalGet('form-test/autocomplete');
// Ensure that the user does not have access to the autocompletion.
@ -190,7 +205,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests form element error messages.
*/
public function testFormElementErrors(): void {
protected function testFormElementErrors(): void {
$this->drupalGet('form_test/details-form');
$this->submitForm([], 'Submit');
$this->assertSession()->pageTextContains('I am an error on the details element.');
@ -199,7 +214,7 @@ class ElementTest extends BrowserTestBase {
/**
* Tests summary attributes of details.
*/
public function testDetailsSummaryAttributes(): void {
protected function testDetailsSummaryAttributes(): void {
$this->drupalGet('form-test/group-details');
$this->assertSession()->elementExists('css', 'summary[data-summary-attribute="test"]');
}