Skip to content

Commit

Permalink
[8.x] [Synthetics] Clean up e2e test helpers !! (#203812) (#203999)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Synthetics] Clean up e2e test helpers !!
(#203812)](#203812)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2024-12-12T09:52:19Z","message":"[Synthetics]
Clean up e2e test helpers !! (#203812)\n\n## Summary\r\n\r\nClean up e2e
test
helpers","sha":"0203bba44f9dcac037f23a23e4945298ef6b5912","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services","Team:obs-ux-management"],"number":203812,"url":"https://github.com/elastic/kibana/pull/203812","mergeCommit":{"message":"[Synthetics]
Clean up e2e test helpers !! (#203812)\n\n## Summary\r\n\r\nClean up e2e
test
helpers","sha":"0203bba44f9dcac037f23a23e4945298ef6b5912"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203812","number":203812,"mergeCommit":{"message":"[Synthetics]
Clean up e2e test helpers !! (#203812)\n\n## Summary\r\n\r\nClean up e2e
test helpers","sha":"0203bba44f9dcac037f23a23e4945298ef6b5912"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
shahzad31 and kibanamachine authored Dec 12, 2024
1 parent a6f369b commit ac450e9
Show file tree
Hide file tree
Showing 64 changed files with 129 additions and 1,541 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,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.
*/

export { recordVideo } from './helpers/record_video';
export { SyntheticsRunner } from './helpers/synthetics_runner';
export { argv } from './helpers/parse_args_params';
export { readKibanaConfig } from './tasks/read_kibana_config';
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Path from 'path';
import { execSync } from 'child_process';
import { REPO_ROOT } from '@kbn/repo-info';

const ES_ARCHIVE_DIR = './fixtures/es_archiver';

Expand All @@ -16,22 +17,15 @@ const NODE_TLS_REJECT_UNAUTHORIZED = '1';
export const esArchiverLoad = (folder: string) => {
const path = Path.join(ES_ARCHIVE_DIR, folder);
execSync(
`node ../../../../scripts/es_archiver load "${path}" --config ../../../test/functional/config.base.js`,
`node ${REPO_ROOT}/scripts/es_archiver load "${path}" --config ${REPO_ROOT}/test/functional/config.base.js`,
{ env: { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED }, stdio: 'inherit' }
);
};

export const esArchiverUnload = (folder: string) => {
const path = Path.join(ES_ARCHIVE_DIR, folder);
execSync(
`node ../../../../scripts/es_archiver unload "${path}" --config ../../../test/functional/config.base.js`,
{ env: { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED }, stdio: 'inherit' }
);
};

export const esArchiverResetKibana = () => {
execSync(
`node ../../../../scripts/es_archiver empty-kibana-index --config ../../../test/functional/config.base.js`,
`node ${REPO_ROOT}/scripts/es_archiver unload "${path}" --config ${REPO_ROOT}/test/functional/config.base.js`,
{ env: { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED }, stdio: 'inherit' }
);
};
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 '../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 '../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,10 +6,10 @@
*/

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

journey('Step Duration series', async ({ page, params }) => {
recordVideo(page);
Expand Down Expand Up @@ -56,7 +56,8 @@ journey('Step Duration series', async ({ page, params }) => {
await page.click('[aria-label="Remove report metric"]');
await page.click('button:has-text("Select report metric")');
await page.click('button:has-text("Step duration")');
await page.click(byTestId('seriesBreakdown'));
await page.waitForSelector('[data-test-subj=seriesBreakdown]');
await page.getByTestId('seriesBreakdown').click();
await page.click('button[role="option"]:has-text("Step name")');
await page.click('.euiComboBox__inputWrap');
await page.click('[role="combobox"][placeholder="Search Monitor name"]');
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
import { FtrConfigProviderContext } from '@kbn/test';
import path from 'path';
import { SyntheticsRunner } from './synthetics_runner';
import { argv } from './parse_args_params';
import { REPO_ROOT } from '@kbn/repo-info';
import { SyntheticsRunner, argv } from '@kbn/observability-synthetics-test-data';

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

Expand All @@ -24,13 +24,12 @@ async function runE2ETests({ readConfigFile }: FtrConfigProviderContext) {
});

await syntheticsRunner.setup();

await syntheticsRunner.loadTestData(path.join(__dirname, '../../ux/e2e/fixtures/'), [
'rum_8.0.0',
'rum_test_data',
]);
await syntheticsRunner.loadTestData(
path.join(__dirname, '../../synthetics/e2e/fixtures/es_archiver/'),
`${REPO_ROOT}/x-pack/plugins/observability_solution/ux/e2e/fixtures/`,
['rum_8.0.0', 'rum_test_data']
);
await syntheticsRunner.loadTestData(
`${REPO_ROOT}/x-pack/plugins/observability_solution/synthetics/e2e/fixtures/es_archiver/`,
['full_heartbeat', 'browser']
);
await syntheticsRunner.loadTestFiles(async () => {
Expand Down
Loading

0 comments on commit ac450e9

Please sign in to comment.