Uploaded image for project: 'Red Hat Developer Hub Bugs'
  1. Red Hat Developer Hub Bugs
  2. RHDHBUGS-2161

[e2e] extension.spec.ts Fix "Verify support type filters in extensions" test assertion strategy

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Undefined Undefined
    • None
    • 1.8.0
    • Test framework
    • RHDH Plugins 3282, RHDH Plugins 3283
    • Low

      Issue:
      The test "Verify support type filters in extensions" in extensions.spec.ts is failing because it uses toContainText() on the entire listbox element, which contains concatenated text from all options including descriptions and counts. This approach is unreliable and causes false negatives.

      Root Cause:
      The listbox element contains the full rendered content as a single concatenated string:

      "Generally available (GA) Production-ready and supported 27 Certified Stable and secured by Red Hat 2 Tech preview (TP) Plugin still in development 48 Dev preview (DP) An early-stage, experimental plugin 3 Community plugin Open-source plugins, no official support 4"
      

      Using toContainText() on this concatenated string doesn't guarantee that individual options are present as separate elements.

      Solution:
      Changed the assertion strategy to use getByRole("option").filter({ hasText }) which:

      • Locates individual option elements by their ARIA role
      • Uses partial text matching via filter() to identify each option
      • Provides more robust and accurate verification
      • Follows Playwright best practices for role-based selectors

      Changes Made:

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml// Before (unreliable)
      for (const option of supportTypeOptions) {
        await expect(page.getByRole("listbox")).toContainText(option);
      }
      
      // After (robust)
      for (const option of supportTypeOptions) {
        const optionLocator = page
          .getByRole("option")
          .filter({ hasText: option });
        await expect(optionLocator).toBeVisible();
      }
      

      Test Coverage:
      Verified that all support type options are correctly displayed:

      • Generally available (GA)
      • Certified
      • Tech preview (TP)
      • Dev preview (DP)
      • Community plugin

              gustavolira Gustavo Lira Silva
              gustavolira Gustavo Lira Silva
              RHIDP - Plugins
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: