Format plural for number of Results

Created on 13 December 2024, 3 months ago

Problem/Motivation

When there is only 1 Result of search result, it still says "1 Results" but proper grammar is "1 Result" in case only 1 result is found

Steps to reproduce

We can use the Drupal.formatPlural JS method to format this better.

Proposed resolution

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India shalini_jha

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

Merge Requests

Comments & Activities

  • Issue created by @shalini_jha
  • Pipeline finished with Failed
    3 months ago
    Total: 612s
    #367578
  • Pipeline finished with Success
    3 months ago
    Total: 367s
    #367596
  • Pipeline finished with Success
    3 months ago
    Total: 460s
    #367632
  • 🇮🇳India shalini_jha

    I have addressed the issue with the search result count by correcting the grammar for displaying "1 Result" when there is only one result. Additionally, I have added a test to verify this change. I am moving this to "Needs Review." Please review the changes and let me know if they are appropriate or if any further modifications are needed.

    Currently, when no results are found, it displays "0 Results." Do we still need this text, given that "No modules found" is already displayed?

  • 🇺🇸United States chrisfromredfin Portland, Maine

    Good work so far, but we need to make this its own test. I think you could start with the test you injected this into and copy/paste as a starting point, but then you need to do a search that gets only one result.

    Here's some completely untested code to get you started:

    /**
       * Tests formatting plural for results.
       */
      public function testSearchForSpecialChar(): void {
    
      // Load browser.
        $this->drupalGet('admin/modules/browse');
    // Check for plural.
        $this->svelteInitHelper('text', '10 Results');
    
        // Tests for the presence of search bar placeholder text.
        $search_field = $this->getSession()->getPage()->find('css', '#pb-text');
    
        // Fill in the search field.
        $this->inputSearchField('', TRUE);
        $this->inputSearchField('Vitamin', TRUE);
        $this->assertSession()->waitForElementVisible('css', ".search__search-submit")->click();
    
        // Test for result count text (singular).
        $this->assertEquals('1 Result', $this->getElementText('.pb-search-results'));
    }
    
  • 🇮🇳India shalini_jha

    Looking into separate test coverage

  • Pipeline finished with Failed
    2 months ago
    Total: 451s
    #389366
  • Pipeline finished with Failed
    2 months ago
    Total: 424s
    #389688
  • 🇮🇳India shalini_jha

    Thank you for the review. I have added separate test coverage for this functionality and verified that it is working as expected. Moving this for review . Please review

  • 🇮🇳India shalini_jha

    shalini_jha changed the visibility of the branch 3492153-project-usage-icon to hidden.

  • First commit to issue fork.
  • Pipeline finished with Canceled
    2 months ago
    Total: 109s
    #389921
  • 🇺🇸United States phenaproxima Massachusetts

    Fixed merge conflicts and a couple minor things with the tests. This looks okay to me, so let's run with it.

  • Pipeline finished with Success
    2 months ago
    Total: 356s
    #389923
  • Pipeline finished with Success
    2 months ago
    Total: 470s
    #389934
  • Pipeline finished with Skipped
    2 months ago
    #389954
  • 🇺🇸United States chrisfromredfin Portland, Maine

    Excellent!

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 1165s
    #421466
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1241s
    #421467
  • Pipeline finished with Failed
    about 1 month ago
    Total: 519s
    #421486
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1311s
    #421494
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1198s
    #421528
  • Pipeline finished with Failed
    30 days ago
    Total: 1369s
    #422314
  • Pipeline finished with Success
    29 days ago
    Total: 1258s
    #423239
  • Pipeline finished with Failed
    29 days ago
    Total: 323s
    #423294
  • Pipeline finished with Failed
    29 days ago
    Total: 261s
    #423306
  • Pipeline finished with Canceled
    29 days ago
    Total: 111s
    #423310
  • Pipeline finished with Failed
    29 days ago
    Total: 1278s
    #423313
  • Pipeline finished with Failed
    29 days ago
    Total: 1299s
    #423340
  • Pipeline finished with Failed
    29 days ago
    Total: 1183s
    #423411
  • Pipeline finished with Failed
    29 days ago
    Total: 283s
    #423622
  • Pipeline finished with Failed
    29 days ago
    Total: 1223s
    #423623
  • Pipeline finished with Failed
    28 days ago
    Total: 1084s
    #424144
  • Pipeline finished with Failed
    28 days ago
    Total: 1063s
    #424156
  • Pipeline finished with Success
    28 days ago
    Total: 6200s
    #424172
  • Pipeline finished with Success
    24 days ago
    Total: 1324s
    #427135
  • Pipeline finished with Canceled
    23 days ago
    Total: 124s
    #428386
  • Pipeline finished with Failed
    23 days ago
    Total: 979s
    #428389
  • Pipeline finished with Failed
    23 days ago
    Total: 1478s
    #428396
Production build 0.71.5 2024