Ensure ConfigPageTest actually verifies require_on_publish setting

Created on 30 July 2025, 12 days ago

Problem/Motivation

The test ConfigPageTest::testRequireOnPublishEnable() fails to verify that the require_on_publish setting is saved correctly, due to two related issues:

  1. The field_tags field is created without specifying a required Vocabulary bundle. This causes a form validation error ("Vocabulary field is required.") that prevents the form from being submitted.
  2. Despite the failed submission, the test attempts to verify the setting using:
       $required = $this->getSession()->getPage()->findField('require_on_publish')->getValue();
       $this->assertEquals(1, $required);
    

In Drupal 10, this check still passed—likely because the field value persisted in the form even after the validation error. However, in Drupal 11, this assertion fails. The test environment no longer retains the field value after validation fails, resulting in a null or incorrect value, and causing the assertion to break.

Steps to reproduce

  1. Run `ConfigPageTest::testRequireOnPublishEnable()` in a Drupal 11 environment.
  2. Observe test failure with:
        WebDriver\Exception\StaleElementReference: stale element reference: element is not attached to the page document
        
  3. Investigate the form and discover the unconfigured required Vocabulary caused the form to never successfully submit.
  4. Note that in Drupal 10, the form value was still accessible despite the failed submission; this behavior no longer holds in Drupal 11.

Proposed resolution

  • Fix the test setup by creating a Vocabulary and assigning it when adding the field_tags field to the article content type. This allows the form to submit successfully.
  • Fix the verification step by reloading the FieldConfig entity after form submission and asserting the setting directly:
  $field_config = FieldConfig::load('node.article.field_tags');
  $this->assertTrue($field_config->getThirdPartySetting('require_on_publish', 'require_on_publish'));

This ensures the test reliably verifies persisted configuration rather than transient UI state.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States jcandan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024