From 7cd831bcfe63e8006e067230bbaf1d4e2e7c0704 Mon Sep 17 00:00:00 2001 From: Ricky Ang Date: Wed, 28 Jun 2023 09:41:26 -0700 Subject: [PATCH] added another delay to handle a different failure + clean up --- .../test/cloud_security_posture_functional/helper.ts | 11 +++++++++++ .../page_objects/csp_dashboard_page.ts | 2 ++ .../pages/findings.ts | 6 +----- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 x-pack/test/cloud_security_posture_functional/helper.ts diff --git a/x-pack/test/cloud_security_posture_functional/helper.ts b/x-pack/test/cloud_security_posture_functional/helper.ts new file mode 100644 index 0000000000000..f426a64db4c90 --- /dev/null +++ b/x-pack/test/cloud_security_posture_functional/helper.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +/* This sleep or delay is added to allow some time for the column to settle down before we get the value and to prevent the test from getting the wrong value*/ +export const sleep = (num: number) => { + return new Promise((res) => setTimeout(res, num)); +}; diff --git a/x-pack/test/cloud_security_posture_functional/page_objects/csp_dashboard_page.ts b/x-pack/test/cloud_security_posture_functional/page_objects/csp_dashboard_page.ts index 635cf88965e5f..507512293db7f 100644 --- a/x-pack/test/cloud_security_posture_functional/page_objects/csp_dashboard_page.ts +++ b/x-pack/test/cloud_security_posture_functional/page_objects/csp_dashboard_page.ts @@ -7,6 +7,7 @@ import expect from '@kbn/expect'; import type { FtrProviderContext } from '../ftr_provider_context'; +import { sleep } from '../helper'; // Defined in CSP plugin const LATEST_FINDINGS_INDEX = 'logs-cloud_security_posture.findings_latest-default'; @@ -61,6 +62,7 @@ export function CspDashboardPageProvider({ getService, getPageObjects }: FtrProv getKubernetesTab: async () => { const tabs = await dashboard.getDashboardTabs(); + sleep(1000); return await tabs.findByXpath(`//span[text()="Kubernetes"]`); }, diff --git a/x-pack/test/cloud_security_posture_functional/pages/findings.ts b/x-pack/test/cloud_security_posture_functional/pages/findings.ts index 7000b606f9b5e..9353f579e6a62 100644 --- a/x-pack/test/cloud_security_posture_functional/pages/findings.ts +++ b/x-pack/test/cloud_security_posture_functional/pages/findings.ts @@ -8,11 +8,7 @@ import expect from '@kbn/expect'; import Chance from 'chance'; import type { FtrProviderContext } from '../ftr_provider_context'; - -/* This sleep or delay is added to allow some time for the column to settle down before we get the value and to prevent the test from getting the wrong value*/ -const sleep = (num: number) => { - return new Promise((res) => setTimeout(res, num)); -}; +import { sleep } from '../helper'; // eslint-disable-next-line import/no-default-export export default function ({ getPageObjects, getService }: FtrProviderContext) {