Skip to content

Commit

Permalink
update code paths
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Dec 11, 2024
1 parent 901ca2c commit 75c043a
Show file tree
Hide file tree
Showing 46 changed files with 106 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*/

export { makeUpSummary, makeDownSummary } from './src/make_summaries';
export * from './src/e2e';
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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.
*/

import { expect, Page } from '@elastic/synthetics';

export async function waitForLoadingToFinish({ page }: { page: Page }) {
while (true) {
if (!(await page.isVisible(byTestId('kbnLoadingMessage'), { timeout: 5000 }))) break;
await page.waitForTimeout(1000);
}
}

export async function loginToKibana({
page,
user,
}: {
page: Page;
user?: { username: string; password: string };
}) {
await page.fill('[data-test-subj=loginUsername]', user?.username ?? 'elastic', {
timeout: 60 * 1000,
});

await page.fill('[data-test-subj=loginPassword]', user?.password ?? 'changeme');

await page.click('[data-test-subj=loginSubmit]');

await waitForLoadingToFinish({ page });
}

export const byTestId = (testId: string) => {
return `[data-test-subj=${testId}]`;
};

export const assertText = async ({ page, text }: { page: Page; text: string }) => {
const element = await page.waitForSelector(`text=${text}`);
expect(await element.isVisible()).toBeTruthy();
};

export const assertNotText = async ({ page, text }: { page: Page; text: string }) => {
expect(await page.$(`text=${text}`)).toBeFalsy();
};

export const getQuerystring = (params: object) => {
return Object.entries(params)
.map(([key, value]) => encodeURIComponent(key) + '=' + encodeURIComponent(value))
.join('&');
};

export const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

export const TIMEOUT_60_SEC = {
timeout: 60 * 1000,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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.
*/

export { recordVideo } from './helpers/record_video';
export { SyntheticsRunner } from './helpers/synthetics_runner';
export { argv } from './helpers/parse_args_params';
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"target/**/*"
],
"kbn_references": [
"@kbn/apm-plugin",
"@kbn/es-archiver",
"@kbn/repo-info",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { createExploratoryViewUrl } from '../../public/components/shared/exploratory_view/configurations/exploratory_view_url';
import { loginToKibana, TIMEOUT_60_SEC, waitForLoadingToFinish } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { createExploratoryViewUrl } from '../../public/components/shared/exploratory_view/configurations/exploratory_view_url';
import { loginToKibana, TIMEOUT_60_SEC, waitForLoadingToFinish } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import moment from 'moment';
import { createExploratoryViewUrl } from '../../public/components/shared/exploratory_view/configurations/exploratory_view_url';
import { loginToKibana, TIMEOUT_60_SEC, waitForLoadingToFinish } from '../utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { FtrConfigProviderContext } from '@kbn/test';
import path from 'path';
import { REPO_ROOT } from '@kbn/repo-info';
import { SyntheticsRunner, argv } from '@kbn/synthetics-e2e';
import { SyntheticsRunner, argv } from '@kbn/observability-synthetics-test-data';

const { headless, grep, bail: pauseOnError } = argv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"kbn_references": [
"@kbn/test",
"@kbn/synthetics-e2e",
"@kbn/repo-info",
"@kbn/observability-synthetics-test-data",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { Page } from '@elastic/synthetics';
import { loginPageProvider } from '@kbn/synthetics-e2e/page_objects/login';
import { utilsPageProvider } from '@kbn/synthetics-e2e/page_objects/utils';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';

export function sloAppPageProvider({ page, kibanaUrl }: { page: Page; kibanaUrl: string }) {
page.setDefaultTimeout(60 * 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import { FtrConfigProviderContext } from '@kbn/test';
import { SyntheticsRunner, argv } from '@kbn/synthetics-e2e';
import { SyntheticsRunner, argv } from '@kbn/observability-synthetics-test-data';

const { headless, grep, bail: pauseOnError } = argv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"@kbn/ftr-common-functional-services",
"@kbn/data-forge",
"@kbn/synthetics-e2e",
"@kbn/observability-synthetics-test-data",
]
}
2 changes: 0 additions & 2 deletions x-pack/plugins/observability_solution/synthetics/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
* 2.0.
*/

export { SyntheticsRunner } from './helpers/synthetics_runner';
export { argv } from './helpers/parse_args_params';
export { loginPageProvider } from './page_objects/login';
export { utilsPageProvider } from './page_objects/utils';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { journey, step, expect, Page } from '@elastic/synthetics';
import { RetryService } from '@kbn/ftr-common-functional-services';
import { recordVideo } from '../../helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { syntheticsAppPageProvider } from '../page_objects/synthetics_app';
import { byTestId, assertText } from '../../helpers/utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { journey, step, expect, before } from '@elastic/synthetics';
import { SYNTHETICS_API_URLS } from '@kbn/synthetics-plugin/common/constants';
import { recordVideo } from '../../helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';

journey('ProjectAPIKeys', async ({ page }) => {
recordVideo(page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { expect, Page } from '@elastic/synthetics';
import { RetryService } from '@kbn/ftr-common-functional-services';
import { FormMonitorType } from '@kbn/synthetics-plugin/common/runtime_types/monitor_management';
import { recordVideo } from '../../helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { loginPageProvider } from '../../page_objects/login';
import { utilsPageProvider } from '../../page_objects/utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { SyntheticsRunner, argv } from '@kbn/observability-synthetics-test-data';
import { FtrConfigProviderContext } from '@kbn/test';
import path from 'path';
import { argv } from '../helpers/parse_args_params';
import { SyntheticsRunner } from '../helpers/synthetics_runner';

const { headless, grep, bail: pauseOnError } = argv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
"@kbn/dev-utils",
"@kbn/ux-plugin/e2e",
"@kbn/ftr-common-functional-services",
"@kbn/apm-plugin",
"@kbn/es-archiver",
"@kbn/synthetics-plugin",
"@kbn/repo-info",
"@kbn/observability-synthetics-test-data",
"@kbn/ftr-common-functional-ui-services"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"@kbn/ftr-common-functional-services",
"@kbn/apm-plugin",
"@kbn/ftr-common-functional-ui-services",
"@kbn/synthetics-e2e"
"@kbn/observability-synthetics-test-data"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import {
assertNotText,
assertText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { journey, step, expect, before } from '@elastic/synthetics';
import { RetryService } from '@kbn/ftr-common-functional-services';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { byTestId, assertText, waitForLoadingToFinish } from '../../../helpers/utils';
import { loginPageProvider } from '../../../page_objects/login';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before, expect } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { byTestId, assertText, waitForLoadingToFinish } from '../../../helpers/utils';
import { loginPageProvider } from '../../../page_objects/login';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { journey, step, expect, before } from '@elastic/synthetics';
import { callKibana } from '@kbn/apm-plugin/server/test_helpers/create_apm_users/helpers/call_kibana';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { byTestId, TIMEOUT_60_SEC, waitForLoadingToFinish } from '../../helpers/utils';
import { loginPageProvider } from '../../page_objects/login';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before, Page } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { makeChecksWithStatus } from '../../../helpers/make_checks';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { journey, step, expect, before, Page } from '@elastic/synthetics';
import { noop } from 'lodash';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { byTestId, delay } from '../../../helpers/utils';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before, Page } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { byTestId } from '../../../helpers/utils';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, expect, before, Page } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { byTestId, delay } from '../../../helpers/utils';
import { makeChecksWithStatus } from '../../../helpers/make_checks';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { journey, step, expect } from '@elastic/synthetics';
import { RetryService } from '@kbn/ftr-common-functional-services';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { loginPageProvider } from '../../page_objects/login';

journey('StepsDuration', async ({ page, params }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { byTestId, waitForLoadingToFinish } from '../../helpers/utils';

journey('UptimeOverview', ({ page, params }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/
import { FtrConfigProviderContext } from '@kbn/test';
import path from 'path';
import { argv } from '../helpers/parse_args_params';
import { SyntheticsRunner } from '../helpers/synthetics_runner';
import { SyntheticsRunner, argv } from '@kbn/observability-synthetics-test-data';

const { headless, grep, bail: pauseOnError } = argv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, expect, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { UXDashboardDatePicker } from '../page_objects/date_picker';
import { loginToKibana, waitForLoadingToFinish } from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { journey, step, expect, before } from '@elastic/synthetics';
import { Client } from '@elastic/elasticsearch';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { loginToKibana, waitForLoadingToFinish } from './utils';

const addTestTransaction = async (params: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, expect, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { UXDashboardDatePicker } from '../page_objects/date_picker';
import { byTestId, loginToKibana, waitForLoadingToFinish } from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, expect, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { UXDashboardDatePicker } from '../page_objects/date_picker';
import { byTestId, loginToKibana, waitForLoadingToFinish } from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, expect, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { UXDashboardDatePicker } from '../page_objects/date_picker';
import { byTestId, loginToKibana, waitForLoadingToFinish } from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, expect, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { UXDashboardDatePicker } from '../page_objects/date_picker';
import { byTestId, loginToKibana, waitForLoadingToFinish } from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before, expect } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { UXDashboardDatePicker } from '../page_objects/date_picker';
import { byTestId, loginToKibana, waitForLoadingToFinish } from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { journey, step, before } from '@elastic/synthetics';
import { recordVideo } from '@kbn/synthetics-e2e/helpers/record_video';
import { recordVideo } from '@kbn/observability-synthetics-test-data';
import { UXDashboardDatePicker } from '../page_objects/date_picker';
import { byLensTestId, loginToKibana, waitForLoadingToFinish } from './utils';

Expand Down
Loading

0 comments on commit 75c043a

Please sign in to comment.