Skip to content

Commit 4da590c

Browse files
fix: flaky tests in discover.spec.js (#1033) (#1056)
* fix: manually set global as default tenant Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * fix: add delay to ensure the input is right Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add some comment Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com> (cherry picked from commit 94a5d3c) Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
1 parent d9d4060 commit 4da590c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ const indexSet = [
2626

2727
describe('discover app', { scrollBehavior: false }, () => {
2828
before(() => {
29+
if (Cypress.env('SECURITY_ENABLED')) {
30+
/**
31+
* Security plugin is using private tenant as default.
32+
* So here we'd need to set global tenant as default manually.
33+
*/
34+
cy.changeDefaultTenant({
35+
multitenancy_enabled: true,
36+
private_tenant_enabled: true,
37+
default_tenant: 'global',
38+
});
39+
}
2940
CURRENT_TENANT.newTenant = 'global';
3041
// import logstash functional
3142
testFixtureHandler.importJSONDocIfNeeded(

cypress/utils/dashboards/commands.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ Cypress.Commands.add('setTopNavDate', (start, end, submit = true) => {
7979
cy.getElementByTestId('superDatePickerAbsoluteDateInput', opts)
8080
.click(opts)
8181
.clear(opts)
82-
.type(start, opts);
82+
.type(start, {
83+
...opts,
84+
delay: 0, // add a delay here, cypress sometimes fails to type all the content into the input.
85+
});
8386

8487
// Click end date
8588
cy.getElementByTestId('superDatePickerendDatePopoverButton', opts)
@@ -96,7 +99,10 @@ Cypress.Commands.add('setTopNavDate', (start, end, submit = true) => {
9699
.last(opts)
97100
.click(opts)
98101
.clear(opts)
99-
.type(end, opts);
102+
.type(end, {
103+
...opts,
104+
delay: 0, // add a delay here, cypress sometimes fails to type all the content into the input.
105+
});
100106

101107
// Close popup
102108
cy.getElementByTestId('superDatePickerendDatePopoverButton', opts).click(

0 commit comments

Comments
 (0)