Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e-tests/cypress/e2e/Tenancy.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Dashboard } from '../support/page-objects/Dashboard';
import { TENANCY_QUERY_STRING_KEY } from '../support/types';
import { Spaces } from '../support/page-objects/Spaces';
import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient';
import { IndexManagement } from '../support/page-objects/IndexManagement';

describe('Tenancy', () => {
describe('should run tests', () => {
Expand Down Expand Up @@ -160,6 +161,7 @@ function runTests({
spacePrefix: ''
});

IndexManagement.waitingForSectionLoadingFinish();
callbackAfterLogin?.();

Spaces.createNewSpace(newSpace);
Expand Down
7 changes: 5 additions & 2 deletions e2e-tests/cypress/support/page-objects/IndexManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ export class IndexManagement {

static openDataStreams() {
cy.log('Open Data Streams');

cy.get('[data-test-subj="data_streamsTab"]').click();
}

static verifyDataStreamsEmptyPage() {
cy.log('Verify data streams empty page');

cy.contains('[data-test-subj="title"]', "You don't have any data streams yet");
}

static waitingForSectionLoadingFinish() {
cy.log('Waiting for section loading');
cy.get('[data-test-subj="sectionLoading"]', { timeout: 30000 }).should('not.exist');
}
Comment on lines +108 to +111
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In Cypress 14.x, can cy.get('selector').should('not.exist') pass immediately if the element is initially absent, and therefore miss an element that appears shortly after?

💡 Result:

Yes, cy.get('selector').should('not.exist') can pass immediately if the element is absent at the moment Cypress checks for it, which may lead to false positives if the element is intended to appear shortly after [1]. Cypress's retry-ability mechanism is designed to wait for an element to appear when using positive assertions (like should('exist') or should('be.visible')) [2][3]. However, when using the negative assertion should('not.exist'), Cypress checks the DOM and, if the element is not found, the assertion passes immediately [1]. It does not inherently wait to see if the element might appear later [1]. If you need to ensure an element does not appear after an asynchronous action (such as a network request or a UI update), you must explicitly control the timing of the assertion [4]. Common strategies include: 1. Waiting for the specific action to complete: Use cy.wait() with a network alias or wait for a specific state change before asserting that the element does not exist [4]. 2. Chaining assertions: If you expect an element to exist first and then disappear, assert its existence before asserting its non-existence [5]. 3. Adjusting timeouts: While increasing the timeout can sometimes help, it is generally better to use explicit synchronization (like waiting for a network request) to ensure the test is deterministic [4]. If you require an immediate check without any waiting (e.g., verifying an element is absent after a server-side render), you can explicitly set the timeout to 0 to disable retrying [2][3]: cy.get('selector', { timeout: 0 }).should('not.exist') [2][3]

Citations:


waitingForSectionLoadingFinish() has a race condition: loader may appear after assertion passes.

On line 110, cy.get('[data-test-subj="sectionLoading"]', { timeout: 30000 }).should('not.exist') passes immediately if the loader is not present at that instant. It does not wait to detect if the loader appears later. If the loader starts loading slightly after this check, the flake remains unresolved. Add an explicit page-ready assertion first to ensure the page has stabilized, then verify the loader is absent.

Suggested fix
  static waitingForSectionLoadingFinish() {
    cy.log('Waiting for section loading');
+    if (semver.gte(getKibanaVersion(), '8.0.0')) {
+      cy.get('[data-test-subj="indicesSearch"]', { timeout: 30000 }).should('be.visible');
+    } else {
+      cy.get(
+        'input[aria-label="This is a search bar. As you type, the results lower in the page will automatically filter."]',
+        { timeout: 30000 }
+      ).should('be.visible');
+    }
     cy.get('[data-test-subj="sectionLoading"]', { timeout: 30000 }).should('not.exist');
  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/cypress/support/page-objects/IndexManagement.ts` around lines 108 -
111, waitingForSectionLoadingFinish has a race where the loader check can pass
before the loader ever appears; fix by first asserting the page is stable (e.g.,
wait for a page-ready or section-content element to exist/be visible with a
reasonable timeout) and only then assert the loader is not present — update
waitingForSectionLoadingFinish to first cy.get(...) for a stable selector like a
page-ready or section-content data-test-subj and .should('be.visible' or
'exist') and after that run the existing
cy.get('[data-test-subj="sectionLoading"]', { timeout: 30000
}).should('not.exist').

}
Loading