Drupal\system\Tests\Theme\FastTest does not test anything

Created on 20 August 2016, almost 9 years ago
Updated 27 January 2023, over 2 years ago
/**
 * Tests access to user autocompletion and verify the correct results.
 */
function testUserAutocomplete() {
  $this->drupalLogin($this->account);
  $this->drupalGet('user/autocomplete', array('query' => array('q' => $this->account->getUsername())));
  $this->assertRaw($this->account->getUsername());
  $this->assertNoText('registry initialized', 'The registry was not initialized');
}

The path user/autocomplete does not exist in Drupal 8 for a long time. The test still passes because user/autocomplete is found in drupalSettings.path.currentQuery.

🐛 Bug report
Status

Needs work

Version

10.1

Component
System 

Last updated about 9 hours ago

No maintainer
Created by

🇷🇺Russia Chi

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    Needs a reroll but appears to be dead code maybe?

  • 🇮🇳India _utsavsharma

    Rerolled for 10.1.x.

  • Status changed to RTBC over 2 years ago
  • 🇺🇸United States smustgrave

    Pretty convinced this is deadcode but will see what the committers say.

  • Status changed to Needs work over 2 years ago
  • 🇳🇿New Zealand quietone

    The route 'user.autocomplete' was removed in Drupal 8.0.x #2434697: Remove UserAutocompleteController .

    There is another instance of the string 'user/autocomplete'. That should be investigated here as well.

    $ git grep 'user.autocomplete' | grep -v drupal[6-7].php
    core/modules/node/tests/src/Functional/NodeCreationTest.php:    $this->assertSession()->elementNotExists('xpath', '//input[@id="edit-uid-0-value" and contains(@data-autocomplete-path, "user/autocomplete")]');
    core/modules/system/tests/src/Functional/Theme/FastTest.php:    $this->drupalGet('user/autocomplete', ['query' => ['q' => $this->account->getAccountName()]]);
    
  • First commit to issue fork.
  • Merge request !12245Remove FastTest → (Open) created by mstrelan
  • Pipeline finished with Success
    3 days ago
    Total: 362s
    #507117
  • 🇦🇺Australia mstrelan

    #22 - The other reference to user/autocomplete was removed in 🐛 NodeCreationtest::testAuthorAutocomplete has incorrect selector for falsey check Active

    I've created an MR to remove the test. But kind of agree with #17:

    What was this originally testing? Should we still test that?

    Good question. The test was meant to ensure that the theme registry was not initialized when making a request to the autocomplete route. The theme_test module has an event subscriber that throws a "registry initialized" exception if the theme registry is initialized. This currently only applies to the 'system.entity_autocomplete' route but previously applied to 'user.autocomplete' and 'user.autocomplete_anonymous', before #2434697: Remove UserAutocompleteController . I'm not sure if there is any test that's checking for that exception, so perhaps that should be removed too? Or we refactor FastTest to use the 'system.entity_autocomplete' route instead.

  • 🇦🇺Australia mstrelan

    I did some more digging. We can use 'system.entity_autocomplete' in the test like so:

    $this->drupalLogin($this->account);
    $selection_settings_key = Crypt::hmacBase64(serialize([]) . 'userdefault', Settings::getHashSalt());;
    \Drupal::keyValue('entity_autocomplete')->set($selection_settings_key, []);
    $this->drupalGet('/entity_reference_autocomplete/user/default/' . $selection_settings_key, [
      'query' => [
        'q' => $this->account->getAccountName(),
      ],
    ]);

    However we never enter ThemeTestSubscriber::onView so the exception is never thrown anyway.

    I think we can just remove the test.

  • 🇺🇸United States smustgrave

    Thanks @mstrelan for digging into that! Agree with your findings.

Production build 0.71.5 2024