Skip to content

extract tenant-dialog helper & improve forecaster list test robustness - #1823

Merged
yubonluo merged 3 commits into
opensearch-project:mainfrom
kaituo:forecasterList
Aug 8, 2025
Merged

extract tenant-dialog helper & improve forecaster list test robustness#1823
yubonluo merged 3 commits into
opensearch-project:mainfrom
kaituo:forecasterList

Conversation

@kaituo

@kaituo kaituo commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

Description

This PR:

  • Create cy.handleTenantDialog custom command to handle the optional "Select your tenant" pop-up.
  • Refactor forecaster_list_spec.js and createForecaster helper to leverage the new command, reducing duplicate code.
  • Introduce explicit waits (cy.contains('Loading OpenSearch Dashboards').should('not.exist'), cy.wait(500)) and additional cy.log statements to handle cases where the home page loads slowly, improving stability and aiding debugging.
  • Replace thrown error during action-menu retries with a cy.log to enable fallback logic in future enhancements.
  • Implement fallback logic to use "Stop forecasting" when the "Cancel forecast" modal
    does not appear, covering both Initializing and Running forecast states.

Issues Resolved

opensearch-project/anomaly-detection-dashboards-plugin#1072

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.

@kaituo kaituo changed the title test extract tenant-dialog helper & improve forecaster list test robustness Aug 7, 2025
This PR:

* Create `cy.handleTenantDialog` custom command to handle the optional  **"Select your tenant"** pop-up.
* Refactor `forecaster_list_spec.js` and `createForecaster` helper to leverage the new command, reducing duplicate code.
* Introduce explicit waits (`cy.contains('Loading OpenSearch Dashboards').should('not.exist')`, `cy.wait(500)`) and additional `cy.log` statements to handle cases where the home page loads slowly, improving stability and aiding debugging.
* Replace thrown error during action-menu retries with a `cy.log` to enable fallback logic in future enhancements.
* Implement fallback logic to use **"Stop forecasting"** when the **"Cancel forecast"** modal
  does not appear, covering both *Initializing* and *Running* forecast states.

Signed-off-by: Kaituo Li <kaituo@amazon.com>
}
});
// tenant dialog can appear at any time, so we need to handle it between each clicks
cy.handleTenantDialog();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can't wait for it to show up and then confirm and it shouldn't show up again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can do it. Since I cannot reproduce the issue locally, should I commit the change you suggested, wait for another test run in jenkis, and check if things get fixed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am good with either, just seems like it can be more deterministic, locally if it passes with my suggestions thats also a good sign

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussed with Amit offline, he is ok keep things as it is.

@kaituo
kaituo force-pushed the forecasterList branch 2 times, most recently from 4917e9f to cd673b0 Compare August 7, 2025 22:56
Signed-off-by: Kaituo Li <kaituo@amazon.com>
@yubonluo
yubonluo merged commit 5397438 into opensearch-project:main Aug 8, 2025
49 checks passed
opensearch-trigger-bot Bot pushed a commit that referenced this pull request Aug 8, 2025
#1823)

* extract tenant-dialog helper & improve forecaster list test robustness

This PR:

* Create `cy.handleTenantDialog` custom command to handle the optional  **"Select your tenant"** pop-up.
* Refactor `forecaster_list_spec.js` and `createForecaster` helper to leverage the new command, reducing duplicate code.
* Introduce explicit waits (`cy.contains('Loading OpenSearch Dashboards').should('not.exist')`, `cy.wait(500)`) and additional `cy.log` statements to handle cases where the home page loads slowly, improving stability and aiding debugging.
* Replace thrown error during action-menu retries with a `cy.log` to enable fallback logic in future enhancements.
* Implement fallback logic to use **"Stop forecasting"** when the **"Cancel forecast"** modal
  does not appear, covering both *Initializing* and *Running* forecast states.

Signed-off-by: Kaituo Li <kaituo@amazon.com>

* check if deleted detector matches of of known existing one

Signed-off-by: Kaituo Li <kaituo@amazon.com>

---------

Signed-off-by: Kaituo Li <kaituo@amazon.com>
Co-authored-by: yuboluo <yubonluo@amazon.com>
(cherry picked from commit 5397438)
opensearch-trigger-bot Bot pushed a commit that referenced this pull request Aug 8, 2025
#1823)

* extract tenant-dialog helper & improve forecaster list test robustness

This PR:

* Create `cy.handleTenantDialog` custom command to handle the optional  **"Select your tenant"** pop-up.
* Refactor `forecaster_list_spec.js` and `createForecaster` helper to leverage the new command, reducing duplicate code.
* Introduce explicit waits (`cy.contains('Loading OpenSearch Dashboards').should('not.exist')`, `cy.wait(500)`) and additional `cy.log` statements to handle cases where the home page loads slowly, improving stability and aiding debugging.
* Replace thrown error during action-menu retries with a `cy.log` to enable fallback logic in future enhancements.
* Implement fallback logic to use **"Stop forecasting"** when the **"Cancel forecast"** modal
  does not appear, covering both *Initializing* and *Running* forecast states.

Signed-off-by: Kaituo Li <kaituo@amazon.com>

* check if deleted detector matches of of known existing one

Signed-off-by: Kaituo Li <kaituo@amazon.com>

---------

Signed-off-by: Kaituo Li <kaituo@amazon.com>
Co-authored-by: yuboluo <yubonluo@amazon.com>
(cherry picked from commit 5397438)
yubonluo added a commit that referenced this pull request Aug 8, 2025
#1823) (#1832)

* extract tenant-dialog helper & improve forecaster list test robustness

This PR:

* Create `cy.handleTenantDialog` custom command to handle the optional  **"Select your tenant"** pop-up.
* Refactor `forecaster_list_spec.js` and `createForecaster` helper to leverage the new command, reducing duplicate code.
* Introduce explicit waits (`cy.contains('Loading OpenSearch Dashboards').should('not.exist')`, `cy.wait(500)`) and additional `cy.log` statements to handle cases where the home page loads slowly, improving stability and aiding debugging.
* Replace thrown error during action-menu retries with a `cy.log` to enable fallback logic in future enhancements.
* Implement fallback logic to use **"Stop forecasting"** when the **"Cancel forecast"** modal
  does not appear, covering both *Initializing* and *Running* forecast states.



* check if deleted detector matches of of known existing one



---------



(cherry picked from commit 5397438)

Signed-off-by: Kaituo Li <kaituo@amazon.com>
Co-authored-by: Kaituo Li <kaituo@amazon.com>
Co-authored-by: yuboluo <yubonluo@amazon.com>
kaituo added a commit to kaituo/opensearch-dashboards-functional-test that referenced this pull request Aug 10, 2025
opensearch-project#1823)

* extract tenant-dialog helper & improve forecaster list test robustness

This PR:

* Create `cy.handleTenantDialog` custom command to handle the optional  **"Select your tenant"** pop-up.
* Refactor `forecaster_list_spec.js` and `createForecaster` helper to leverage the new command, reducing duplicate code.
* Introduce explicit waits (`cy.contains('Loading OpenSearch Dashboards').should('not.exist')`, `cy.wait(500)`) and additional `cy.log` statements to handle cases where the home page loads slowly, improving stability and aiding debugging.
* Replace thrown error during action-menu retries with a `cy.log` to enable fallback logic in future enhancements.
* Implement fallback logic to use **"Stop forecasting"** when the **"Cancel forecast"** modal
  does not appear, covering both *Initializing* and *Running* forecast states.

Signed-off-by: Kaituo Li <kaituo@amazon.com>

* check if deleted detector matches of of known existing one

Signed-off-by: Kaituo Li <kaituo@amazon.com>

---------

Signed-off-by: Kaituo Li <kaituo@amazon.com>
Co-authored-by: yuboluo <yubonluo@amazon.com>
yubonluo added a commit that referenced this pull request Aug 10, 2025
* extract tenant-dialog helper & improve forecaster list test robustness (#1823)

* extract tenant-dialog helper & improve forecaster list test robustness

This PR:

* Create `cy.handleTenantDialog` custom command to handle the optional  **"Select your tenant"** pop-up.
* Refactor `forecaster_list_spec.js` and `createForecaster` helper to leverage the new command, reducing duplicate code.
* Introduce explicit waits (`cy.contains('Loading OpenSearch Dashboards').should('not.exist')`, `cy.wait(500)`) and additional `cy.log` statements to handle cases where the home page loads slowly, improving stability and aiding debugging.
* Replace thrown error during action-menu retries with a `cy.log` to enable fallback logic in future enhancements.
* Implement fallback logic to use **"Stop forecasting"** when the **"Cancel forecast"** modal
  does not appear, covering both *Initializing* and *Running* forecast states.

Signed-off-by: Kaituo Li <kaituo@amazon.com>

* check if deleted detector matches of of known existing one

Signed-off-by: Kaituo Li <kaituo@amazon.com>

---------

Signed-off-by: Kaituo Li <kaituo@amazon.com>
Co-authored-by: yuboluo <yubonluo@amazon.com>

* test: improve resilience in forecast tests

- In `daily_forecaster_spec.js`, after clicking the “Start test” button, wait for the “Initializing test” message before verifying “Test complete” to ensure previous messages have cleared and avoid race conditions.

- In `forecaster_list_spec.js`:
  • Preemptively set the tenant to “global” via localStorage within `onBeforeLoad` when visiting `/`—this avoids the non-deterministic “Select your tenant” popup.
  • Removed multiple scattered calls to `cy.handleTenantDialog()`, relying on tenant pre-setting instead.
  • Increased UI rendering wait from 500 ms to 2000 ms for menu visibility.

- In `forecaster_list_spec_mock.js`:
  • Applied the same “global” tenant override on page load to avoid the popup.

- In `commands.js`:
  • Added `typeInEuiCombo(testSubj, value)` Cypress command to reliably enter text into EUI combo boxes by clicking the wrapper, typing into the actual input, and asserting the resulting pill—this reduces flakiness compared to typing directly in the wrapper.
  • Updated `createForecaster()` to use `typeInEuiCombo` for both `indicesFilter` and `timestampFilter`.

Signed-off-by: Kaituo Li <kaituo@amazon.com>

---------

Signed-off-by: Kaituo Li <kaituo@amazon.com>
Co-authored-by: yuboluo <yubonluo@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants