Skip to content

[2.13]Fix gantt chart UI test failing on empty index-pattern fields - #2094

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

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

Conversation

@Qxisylolo

Copy link
Copy Markdown
Contributor

test result

➜  Opensearch-dashboards-functional-test git:(osd213_gantt_fix) ✗ 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 (17572ms)

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

  Configure panel settings
    ✓ Changes y-axis label (11149ms)
    ✓ Changes x-axis label (11911ms)
    ✓ Changes time formats (12429ms)
    ✓ Hides legends (11529ms)

  Add gantt chart to dashboard
    ✓ Adds gantt chart to dashboard


  9 passing (2m)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        9                                                                                │
  │ Passing:      9                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     1 minute, 35 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    (5 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      01:35        9        9        -        -        - │
  │    t_ui.spec.js                                                                                │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        01:35        9        9        -        -        -  

✨  Done in 115.15s.

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>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 No relevant 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 in response

Guard against a missing or empty fields array in the _fields_for_wildcard response
to avoid JSON.stringify(undefined) producing an invalid fields attribute, which
would recreate the bug this PR is trying to fix. Fallback to an empty array (or fail
early) when the fields list is not present.

cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js [55-68]

 }).then((resp) => {
+  const fields = (resp.body && 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]: 5

__

Why: Adding a fallback for missing fields in the response is a reasonable defensive measure in a test that specifically aims to fix an index-pattern fields issue, though in practice the endpoint should always return fields.

Low
General
Prefer retry-ability over fixed waits

Add a blank line between the delay constant declaration and the describe block for
readability, and consider using Cypress's built-in retry-ability (e.g., .should())
instead of arbitrary cy.wait(delay) calls, which are flaky.

cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js [21-23]

 const INDEX = 'jaeger';
 const delay = 100;
+
 describe('Dump test data', () => {
Suggestion importance[1-10]: 4

__

Why: The suggestion combines a minor formatting nit with a valid general recommendation to avoid fixed cy.wait() calls for flakiness, but it's not actionable as a concrete code change and only marginally improves the PR.

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. Same correct fix as the other branch backports — dynamically discovers fields from indexed data rather than hardcoding. Solid approach.

@SuZhou-Joe
SuZhou-Joe merged commit c27af6c into opensearch-project:2.13 Jul 17, 2026
21 of 37 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