Skip to content

[2.11]Fix gantt chart UI test failing on empty index-pattern fields - #2091

Merged
SuZhou-Joe merged 1 commit into
opensearch-project:2.11from
Qxisylolo:osd211_gantt_fix
Jul 17, 2026
Merged

[2.11]Fix gantt chart UI test failing on empty index-pattern fields#2091
SuZhou-Joe merged 1 commit into
opensearch-project:2.11from
Qxisylolo:osd211_gantt_fix

Conversation

@Qxisylolo

@Qxisylolo Qxisylolo commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the gantt-chart-dashboards/gantt_ui.spec.js test.

Root cause

  1. Empty index-pattern fields attribute. The test created the jaeger
    index pattern with only a title, leaving its fields attribute empty.
    The visualization editor reads the stored fields list to populate its
    field dropdowns — so every dropdown in the Gantt editor (Event, Start time,
    Duration) showed no options, and the chart could not be configured. The
    test then hung on cy.contains('spanID') until it timed out.

opensearch-project/OpenSearch-Dashboards#11653 introduces the error: An index-pattern created with only a title → fields stays empty → editor dropdowns are empty → the gantt chart can't be configured

test result

yarn cypress:run-without-security --browser electron \
  --spec cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js

yarn run v1.22.19
$ env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=false --browser electron --spec cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        9.5.4                                                                          │
  │ Browser:        Electron 94 (headless)                                                         │
  │ Node Version:   v22.23.0 (/Users/qianxisy/.local/share/mise/installs/node/22.23.0/bin/node)    │
  │ Specs:          1 found (plugins/gantt-chart-dashboards/gantt_ui.spec.js)                      │
  │ Searched:       cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  plugins/gantt-chart-dashboards/gantt_ui.spec.js                                 (1 of 1)
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating


  Dump test data
    ✓ Indexes test data for gantt chart

  Save a gantt chart
    ✓ Creates and saves a gantt chart (17703ms)

  Render and configure a gantt chart
    ✓ Renders no data message
    ✓ Renders the chart (5779ms)

  Configure panel settings
    ✓ Changes y-axis label
    ✓ Changes x-axis label
    ✓ Changes time formats (10285ms)
    ✓ Hides legends

  Add gantt chart to dashboard
    ✓ Adds gantt chart to dashboard


  9 passing (58s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        9                                                                                │
  │ Passing:      9                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     57 seconds                                                                       │
  │ Spec Ran:     plugins/gantt-chart-dashboards/gantt_ui.spec.js                                  │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Video)

  -  Started processing:  Compressing to 32 CRF                                                     
  -  Finished processing: /Users/qianxisy/co404/testss/Opensearch-dashboards-function    (3 seconds)
                          al-test/cypress/videos/plugins/gantt-chart-dashboards/gantt               
                          _ui.spec.js.mp4                                                           


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  plugins/gantt-chart-dashboards/gant      00:57        9        9        -        -        - │
  │    t_ui.spec.js                                                                                │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:57        9        9        -        -        -  

✨  Done in 75.90s.

Issues Resolved

[List any issues this PR will resolve]

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Qxisylolo <qianxisy@amazon.com>
@Qxisylolo Qxisylolo changed the title fix 2.11 gantt [2.11]Fix gantt chart UI test failing on empty index-pattern fields Jul 17, 2026
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Guard against missing fields response

Guard against a missing or non-array resp.body.fields before stringifying it,
otherwise the index pattern may be created with fields: undefined (as a JSON string)
and reintroduce the original empty-fields failure. Fallback to an empty array to
make the test robust.

cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js [46-59]

 }).then((resp) => {
+  const fields = Array.isArray(resp.body && resp.body.fields) ? resp.body.fields : [];
   cy.request({
     method: 'POST',
     failOnStatusCode: false,
     url: `api/saved_objects/index-pattern/${INDEX}`,
     headers: { 'content-type': 'application/json', 'osd-xsrf': true },
     body: JSON.stringify({
       attributes: {
         title: INDEX,
-        fields: JSON.stringify(resp.body.fields),
+        fields: JSON.stringify(fields),
       },
     }),
   });
 });
Suggestion importance[1-10]: 4

__

Why: The suggestion adds a defensive fallback for resp.body.fields to prevent the index pattern from being created with an undefined fields attribute. It's a minor robustness improvement for a test setup, but the API call is expected to return fields for the indexed data.

Low

@wanglam wanglam left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The fix correctly addresses the root cause — index-pattern created without fields attribute caused empty dropdowns in the gantt chart editor. The approach (refresh=wait_for + _fields_for_wildcard + store fields) mirrors how OSD itself creates index patterns. Clean and self-maintaining.

@SuZhou-Joe
SuZhou-Joe merged commit f452b40 into opensearch-project:2.11 Jul 17, 2026
19 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants