Skip to content

[2.15]Fix gantt chart UI test failing on empty index-pattern fields - #2093

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

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

Conversation

@Qxisylolo

Copy link
Copy Markdown
Contributor

test result

➜  Opensearch-dashboards-functional-test git:(osd215_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 (16828ms)

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

  Configure panel settings
    ✓ Changes y-axis label (12029ms)
    ✓ Changes x-axis label (11524ms)
    ✓ Changes time formats (12445ms)
    ✓ Hides legends (11184ms)

  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, 34 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:34        9        9        -        -        - │
  │    t_ui.spec.js                                                                                │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        01:34        9        9        -        -        -  

✨  Done in 115.07s.

[Describe what this change achieves]

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
⚡ Recommended focus areas for review

Missing Request Body

The cy.fixture(...).then((ndjson) => cy.request({...})) block is followed by an empty cy.request({...}) call that appears to be intended for creating the index pattern, but the new implementation nests the saved-object creation inside the _fields_for_wildcard response handler. The outer cy.request({...}) on the second block has method/url/body defined inside the .then, so verify the control flow is correct and no stray empty request remains. Also confirm the fixture .then callback actually executes the bulk request (arrow function without braces returning cy.request is correct, but easy to break during future edits).

cy.fixture('plugins/gantt-chart-dashboards/jaeger-sample.txt').then(
  (ndjson) =>
    cy.request({
      method: 'POST',
      url: 'api/console/proxy',
      headers: {
        'content-type': 'application/json;charset=UTF-8',
        'osd-xsrf': true,
      },
      // refresh=wait_for makes the bulk-indexed docs immediately searchable
      qs: { path: `${INDEX}/_bulk?refresh=wait_for`, method: 'POST' },
      body: ndjson,
    })
);

// Create the index pattern with its field list for editor to read the stored `fields` attribute
cy.request({
  method: 'GET',
  url: 'api/index_patterns/_fields_for_wildcard',
  qs: { pattern: INDEX },
  headers: { 'osd-xsrf': true },
}).then((resp) => {
  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),
      },
    }),
  });
});

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Guard against missing fields in response

The response from _fields_for_wildcard may not always contain a fields array (e.g.,
on error or empty index). Guard against a missing resp.body.fields to avoid
stringifying undefined, which would store the literal string "undefined" as the
fields attribute and break the index pattern.

cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js [51-64]

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

__

Why: The suggestion adds a defensive check for resp.body.fields, which is a minor robustness improvement in a test setup context. Since this is test code with predictable data after a bulk index with refresh=wait_for, the impact is limited.

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. Root cause correctly identified and fixed. The _fields_for_wildcard approach ensures dropdowns are populated reliably.

@SuZhou-Joe
SuZhou-Joe merged commit 266410e into opensearch-project:2.15 Jul 17, 2026
22 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