Index content after its creation on behat steps does not work

Created on 11 February 2022, almost 3 years ago
Updated 12 May 2023, over 1 year ago

Problem/Motivation

The issue https://www.drupal.org/project/search_api/issues/3115214 β†’ defined a method to index items on behat using the tag @search_api.

The reason for using the tag is because search_api enqueue the content that needs indexation with the service search_api.post_request_indexing and until the PHP process is not finished, it does not index the content because this service does it on its destruct method, so using the tag @search_api we call to the destruct method.

See the code in https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/search_api....

   * @AfterStep
   */
  public function indexEntities(AfterStepScope $event) {
    $tags = $event->getFeature()->getTags();
    if (!in_array('search_api', $tags)) {
      return;
    }

    \Drupal::getContainer()->get('search_api.post_request_indexing')
      ->destruct();
  }

We added the tag '@search_api' to index the content created in the scenario, but debugging, the method ```$event->getFeature()->getTags();``` returns empty tags, so the destruct is never called, so the items are not indexed during the scenario execution.

Steps to reproduce

Add a feature with a step to create content, the option index immediately on the configuration of search_api should be checked. and add the tag @search_api to execute the search_api behat step.

The tag will be ignored, and the content should not be indexed.

Proposed resolution

Refactor the code to use the tag @search_api.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

General code

Created by

πŸ‡ͺπŸ‡ΈSpain eduardo morales alberti Spain, πŸ‡ͺπŸ‡Ί

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

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024