mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[SecuritySolution] Fix inspect_button cypress (#158543)
## Summary
https://github.com/elastic/kibana/issues/153765
Inspect button cypress was found flaky sometimes. I was able to
reproduce the scenario when the tests failed by setting network
throttling to slow 3G with Chrome.
Here's what I add to reduce the flakyness:
1. Taking `welcome icon` page into consideration when loading the page.
Check the welcome icon has shown and disappeared before checking the
loading indicator in the header. This should buy us more time to avoid
timeout in comparison to checking the loading indicator straight away.
<img width="2556" alt="Screenshot 2023-05-26 at 10 51 08"
src="19f4b94f
-e8e9-40ca-bb85-cc496a396bde">
2. ~Replace creating data view via api with loading esArchiver auditbeat
data. I assume preload the data could reduce the uncertainty of fetching
api under slow internet speed, and therefore reduce the possible failure
during setting up the tests.~
3. Update postDataView task:
https://github.com/elastic/kibana/pull/158543#issuecomment-1590912859
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
cdd8bc43ef
commit
11cdbc999b
5 changed files with 40 additions and 13 deletions
|
@ -17,8 +17,11 @@ import {
|
|||
openTableInspectModal,
|
||||
} from '../../tasks/inspect';
|
||||
import { login, visit } from '../../tasks/login';
|
||||
import { HOSTS_URL } from '../../urls/navigation';
|
||||
import { postDataView, waitForPageToBeLoaded } from '../../tasks/common';
|
||||
import {
|
||||
postDataView,
|
||||
waitForPageToBeLoaded,
|
||||
waitForWelcomePanelToBeLoaded,
|
||||
} from '../../tasks/common';
|
||||
import { esArchiverLoad, esArchiverUnload } from '../../tasks/es_archiver';
|
||||
import { selectDataView } from '../../tasks/sourcerer';
|
||||
|
||||
|
@ -28,12 +31,10 @@ describe('Inspect Explore pages', () => {
|
|||
before(() => {
|
||||
esArchiverLoad('risk_users');
|
||||
esArchiverLoad('risk_hosts');
|
||||
login();
|
||||
|
||||
login();
|
||||
// Create and select data view
|
||||
postDataView(DATA_VIEW);
|
||||
visit(HOSTS_URL);
|
||||
selectDataView(DATA_VIEW);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
|
@ -47,8 +48,14 @@ describe('Inspect Explore pages', () => {
|
|||
*/
|
||||
it(`inspect ${pageName} page`, () => {
|
||||
login();
|
||||
visit(url);
|
||||
waitForPageToBeLoaded();
|
||||
|
||||
visit(url, {
|
||||
onLoad: () => {
|
||||
waitForWelcomePanelToBeLoaded();
|
||||
waitForPageToBeLoaded();
|
||||
selectDataView(DATA_VIEW);
|
||||
},
|
||||
});
|
||||
|
||||
lensVisualizations.forEach((lens) => {
|
||||
cy.log(`inspects the ${lens.title} visualization`);
|
||||
|
|
|
@ -69,6 +69,8 @@ export const REFRESH_BUTTON = '[data-test-subj="querySubmitButton"]';
|
|||
export const LOADING_INDICATOR = '[data-test-subj="globalLoadingIndicator"]';
|
||||
export const LOADING_INDICATOR_HIDDEN = '[data-test-subj="globalLoadingIndicator-hidden"]';
|
||||
|
||||
export const KIBANA_LOADING_ICON = '[data-test-subj="kbnLoadingMessage"]';
|
||||
|
||||
// opens the navigation panel for a given nested link
|
||||
export const openNavigationPanelFor = (page: string) => {
|
||||
let panel;
|
||||
|
|
|
@ -5,7 +5,13 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { LOADING_INDICATOR, LOADING_INDICATOR_HIDDEN } from '../screens/security_header';
|
||||
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
||||
import { DATA_VIEW_PATH, INITIAL_REST_VERSION } from '@kbn/data-views-plugin/server/constants';
|
||||
import {
|
||||
LOADING_INDICATOR,
|
||||
LOADING_INDICATOR_HIDDEN,
|
||||
KIBANA_LOADING_ICON,
|
||||
} from '../screens/security_header';
|
||||
|
||||
const primaryButton = 0;
|
||||
|
||||
|
@ -215,17 +221,20 @@ export const deleteConnectors = () => {
|
|||
export const postDataView = (dataSource: string) => {
|
||||
rootRequest({
|
||||
method: 'POST',
|
||||
url: `/api/index_patterns/index_pattern`,
|
||||
url: DATA_VIEW_PATH,
|
||||
body: {
|
||||
index_pattern: {
|
||||
data_view: {
|
||||
id: dataSource,
|
||||
name: dataSource,
|
||||
fieldAttrs: '{}',
|
||||
title: dataSource,
|
||||
timeFieldName: '@timestamp',
|
||||
fields: '{}',
|
||||
},
|
||||
},
|
||||
headers: { 'kbn-xsrf': 'cypress-creds-via-config' },
|
||||
headers: {
|
||||
'kbn-xsrf': 'cypress-creds-via-config',
|
||||
[ELASTIC_HTTP_VERSION_HEADER]: [INITIAL_REST_VERSION],
|
||||
},
|
||||
failOnStatusCode: false,
|
||||
});
|
||||
};
|
||||
|
@ -245,3 +254,8 @@ export const waitForPageToBeLoaded = () => {
|
|||
cy.get(LOADING_INDICATOR_HIDDEN).should('exist');
|
||||
cy.get(LOADING_INDICATOR).should('not.exist');
|
||||
};
|
||||
|
||||
export const waitForWelcomePanelToBeLoaded = () => {
|
||||
cy.get(KIBANA_LOADING_ICON).should('exist');
|
||||
cy.get(KIBANA_LOADING_ICON).should('not.exist');
|
||||
};
|
||||
|
|
|
@ -352,6 +352,9 @@ export const visit = (url: string, options: Partial<Cypress.VisitOptions> = {},
|
|||
|
||||
disableNewFeaturesTours(win);
|
||||
},
|
||||
onLoad: (win) => {
|
||||
options.onLoad?.(win);
|
||||
},
|
||||
});
|
||||
waitForPageToBeLoaded();
|
||||
};
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"@kbn/securitysolution-data-table",
|
||||
"@kbn/cases-plugin",
|
||||
"@kbn/data-plugin",
|
||||
"@kbn/core-http-common"
|
||||
"@kbn/core-http-common",
|
||||
"@kbn/data-views-plugin"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue