[Exploratory view] Add e2e tests (#135148)

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Shahzad 2022-06-28 13:31:12 +02:00 committed by GitHub
parent a0f69e0e43
commit d6f2dc1042
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 267 additions and 23 deletions

View file

@ -41,6 +41,7 @@ disabled:
- x-pack/plugins/synthetics/e2e/config.ts
- x-pack/plugins/synthetics/e2e/synthetics_run.ts
- x-pack/plugins/ux/e2e/synthetics_run.ts
- x-pack/plugins/observability/e2e/synthetics_run.ts
# Configs that exist but weren't running in CI when this file was introduced
- test/visual_regression/config.ts

View file

@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/functional/observability_plugin.sh
label: 'Observability @elastic/synthetics Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1

View file

@ -104,6 +104,10 @@ const uploadPipeline = (pipelineContent) => {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/osquery_cypress.yml'));
}
if (await doAnyChangesMatch([/^x-pack\/plugins\/observability/])) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/observability_plugin.yml'));
}
if (await doAnyChangesMatch([/^x-pack\/plugins\/synthetics/])) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/synthetics_plugin.yml'));
}

View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common/util.sh
.buildkite/scripts/bootstrap.sh
.buildkite/scripts/download_build_artifacts.sh
export JOB=kibana-observability-plugin
echo "--- Observability plugin @elastic/synthetics Tests"
cd "$XPACK_DIR"
checks-reporter-with-killswitch "Observability plugin @elastic/synthetics Tests" \
node plugins/observability/scripts/e2e.js --kibana-install-dir "$KIBANA_BUILD_LOCATION" ${GREP:+--grep \"${GREP}\"}

View file

@ -78,6 +78,7 @@ it('produces the right watch and ignore list', () => {
<absolute path>/x-pack/plugins/security_solution/server/lib/detection_engine/scripts,
<absolute path>/x-pack/plugins/synthetics/e2e,
<absolute path>/x-pack/plugins/ux/e2e,
<absolute path>/x-pack/plugins/observability/e2e,
]
`);
});

View file

@ -68,6 +68,7 @@ export function getServerWatchPaths({ pluginPaths, pluginScanDirs }: Options) {
fromRoot('x-pack/plugins/security_solution/server/lib/detection_engine/scripts'),
fromRoot('x-pack/plugins/synthetics/e2e'),
fromRoot('x-pack/plugins/ux/e2e'),
fromRoot('x-pack/plugins/observability/e2e'),
];
return {

View file

@ -75,6 +75,11 @@ export const PROJECTS = [
disableTypeCheck: true,
}),
createProject('x-pack/plugins/observability/e2e/tsconfig.json', {
name: 'observability/synthetics-e2e-tests',
disableTypeCheck: true,
}),
// Glob patterns to be all search at once
...findProjects([
'src/plugins/*/tsconfig.json',

View file

@ -172,7 +172,6 @@ def functionalXpack(Map params = [:]) {
}
}
whenChanged([
'x-pack/plugins/fleet/',
]) {

View file

@ -0,0 +1,106 @@
/*
* 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 { journey, step, before } from '@elastic/synthetics';
import { createExploratoryViewUrl } from '../../public/components/shared/exploratory_view/configurations/exploratory_view_url';
import { loginToKibana, TIMEOUT_60_SEC, waitForLoadingToFinish } from '../utils';
journey('Exploratory view', async ({ page, params }) => {
before(async () => {
await waitForLoadingToFinish({ page });
});
const expUrl = createExploratoryViewUrl({
reportType: 'kpi-over-time',
allSeries: [
{
name: 'Elastic page views',
time: {
from: '2021-01-18T12:20:01.682Z',
to: '2021-01-18T12:25:27.484Z',
},
selectedMetricField: '___records___',
reportDefinitions: { 'service.name': [] },
dataType: 'ux',
},
],
});
const baseUrl = `${params.kibanaUrl}${expUrl}`;
step('Go to Exploratory view', async () => {
await page.goto(baseUrl, {
waitUntil: 'networkidle',
});
await loginToKibana({
page,
user: { username: 'elastic', password: 'changeme' },
dismissTour: false,
});
});
step('renders as expected', async () => {
await page.waitForTimeout(60 * 1000);
await page.click('text=User experience (RUM)');
await page.click('[aria-label="Toggle series information"] >> text=Page views', TIMEOUT_60_SEC);
await page.click('[aria-label="Edit series"]', TIMEOUT_60_SEC);
await page.click('button:has-text("No breakdown")');
await page.click('button[role="option"]:has-text("Operating system")');
await page.click('button:has-text("Apply changes")');
await page.click('text=Chrome OS');
await page.click('text=iOS');
await page.click('text=iOS');
await page.click('text=Chrome OS');
await page.click('text=Ubuntu');
await page.click('text=Android');
await page.click('text=Linux');
await page.click('text=Mac OS X');
await page.click('text=Windows');
await page.click('h1:has-text("Explore data")');
});
step('Edit and change the series to distribution', async () => {
await page.click('[aria-label="View series actions"]');
await page.click('[aria-label="Remove series"]');
await page.click('button:has-text("KPI over time")');
await page.click('button[role="option"]:has-text("Performance distribution")');
await page.click('button:has-text("Add series")');
await page.click('button:has-text("Select data type")');
await page.click('button:has-text("User experience (RUM)")');
await page.click('button:has-text("Select report metric")');
await page.click('button:has-text("Page load time")');
await page.click('.euiComboBox__inputWrap');
await page.click('[aria-label="Date quick select"]');
await page.click('text=Last 1 year');
await page.click('[aria-label="Date quick select"]');
await page.click('[aria-label="Time value"]');
await page.fill('[aria-label="Time value"]', '010');
await page.selectOption('[aria-label="Time unit"]', 'y');
await page.click('div[role="dialog"] button:has-text("Apply")');
await page.click('.euiComboBox__inputWrap');
await page.click('button[role="option"]:has-text("elastic-co-frontend")');
await page.click('button:has-text("Apply changes")');
await page.click('text=ux-series-1');
await page.click('text=User experience (RUM)');
await page.click('text=Page load time');
await page.click('text=Pages loaded');
await page.click('button:has-text("95th")');
await page.click('button:has-text("90th")');
await page.click('button:has-text("99th")');
await page.click('[aria-label="Edit series"]');
await page.click('button:has-text("No breakdown")');
await page.click('button[role="option"]:has-text("Browser family")');
await page.click('button:has-text("Apply changes")');
await page.click('text=Edge');
await page.click('text=Opera');
await page.click('text=Safari');
await page.click('text=HeadlessChrome');
await page.click('[aria-label="Firefox; Activate to hide series in graph"]');
});
});

View file

@ -0,0 +1,8 @@
/*
* 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 * from './exploratory_view';

View file

@ -0,0 +1,40 @@
/*
* 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 { FtrConfigProviderContext } from '@kbn/test';
import path from 'path';
import { SyntheticsRunner } from './synthetics_runner';
import { argv } from './parse_args_params';
const { headless, grep, bail: pauseOnError } = argv;
async function runE2ETests({ readConfigFile }: FtrConfigProviderContext) {
const kibanaConfig = await readConfigFile(require.resolve('@kbn/synthetics-plugin/e2e/config'));
return {
...kibanaConfig.getAll(),
testRunner: async ({ getService }: any) => {
const syntheticsRunner = new SyntheticsRunner(getService, {
headless,
match: grep,
pauseOnError,
});
await syntheticsRunner.setup();
const fixturesDir = path.join(__dirname, '../../ux/e2e/fixtures/');
await syntheticsRunner.loadTestData(fixturesDir, ['rum_8.0.0', 'rum_test_data']);
await syntheticsRunner.loadTestFiles(async () => {
require('./journeys');
});
await syntheticsRunner.run();
},
};
}
// eslint-disable-next-line import/no-default-export
export default runE2ETests;

View file

@ -0,0 +1,17 @@
{
"extends": "../../../../tsconfig.base.json",
"exclude": ["tmp", "target/**/*"],
"include": ["./**/*"],
"compilerOptions": {
"outDir": "target/types",
"types": [ "node"],
},
"references": [
{
"path": "../../apm/tsconfig.json",
},
{
"path": "../tsconfig.json",
}
]
}

View file

@ -17,9 +17,11 @@ export async function waitForLoadingToFinish({ page }: { page: Page }) {
export async function loginToKibana({
page,
user,
dismissTour = true,
}: {
page: Page;
user?: { username: string; password: string };
dismissTour?: boolean;
}) {
await page.fill('[data-test-subj=loginUsername]', user?.username ?? 'elastic', {
timeout: 60 * 1000,
@ -30,8 +32,10 @@ export async function loginToKibana({
await page.click('[data-test-subj=loginSubmit]');
await waitForLoadingToFinish({ page });
// Close Monitor Management tour added in 8.2.0
await page.click('[data-test-subj=syntheticsManagementTourDismiss]');
if (dismissTour) {
// Close Monitor Management tour added in 8.2.0
await page.click('[data-test-subj=syntheticsManagementTourDismiss]');
}
}
export const byTestId = (testId: string) => {
@ -54,3 +58,7 @@ export const getQuerystring = (params: object) => {
};
export const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
export const TIMEOUT_60_SEC = {
timeout: 60 * 1000,
};

View file

@ -0,0 +1,16 @@
/*
* 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.
*/
/* eslint-disable no-console */
/* eslint-disable @kbn/imports/uniform_imports */
const { executeSyntheticsRunner } = require('../../synthetics/scripts/base_e2e');
const path = require('path');
const e2eDir = path.join(__dirname, '../e2e');
executeSyntheticsRunner(e2eDir);

View file

@ -13,7 +13,12 @@
*/
import { journey, step, before } from '@elastic/synthetics';
import { assertNotText, assertText, byTestId, waitForLoadingToFinish } from '../utils';
import {
assertNotText,
assertText,
byTestId,
waitForLoadingToFinish,
} from '@kbn/observability-plugin/e2e/utils';
import { settingsPageProvider } from '../../page_objects/settings';
journey('DefaultEmailSettings', async ({ page, params }) => {

View file

@ -6,7 +6,7 @@
*/
import { journey, step, expect, before } from '@elastic/synthetics';
import { assertText, byTestId, waitForLoadingToFinish } from '../utils';
import { assertText, byTestId, waitForLoadingToFinish } from '@kbn/observability-plugin/e2e/utils';
import { loginPageProvider } from '../../page_objects/login';
journey('StatusFlyoutInAlertingApp', async ({ page, params }) => {

View file

@ -6,7 +6,7 @@
*/
import { journey, step, before } from '@elastic/synthetics';
import { assertText, byTestId, waitForLoadingToFinish } from '../utils';
import { assertText, byTestId, waitForLoadingToFinish } from '@kbn/observability-plugin/e2e/utils';
import { loginPageProvider } from '../../page_objects/login';
journey('TlsFlyoutInAlertingApp', async ({ page, params }) => {

View file

@ -7,7 +7,7 @@
import { journey, step, expect, before } from '@elastic/synthetics';
import { callKibana } from '@kbn/apm-plugin/scripts/create_apm_users/helpers/call_kibana';
import { byTestId, waitForLoadingToFinish } from './utils';
import { byTestId, waitForLoadingToFinish } from '@kbn/observability-plugin/e2e/utils';
import { loginPageProvider } from '../page_objects/login';
journey('DataViewPermissions', async ({ page, params }) => {

View file

@ -7,8 +7,8 @@
import { journey, step, expect, before, Page } from '@elastic/synthetics';
import { noop } from 'lodash';
import { byTestId, delay } from '@kbn/observability-plugin/e2e/utils';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';
import { byTestId, delay } from '../utils';
const dateRangeStart = '2019-09-10T12:40:08.078Z';
const dateRangeEnd = '2019-09-11T19:40:08.078Z';

View file

@ -6,8 +6,8 @@
*/
import { journey, step, before, Page } from '@elastic/synthetics';
import { byTestId } from '@kbn/observability-plugin/e2e/utils';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';
import { byTestId } from '../utils';
const dateRangeStart = '2019-09-10T12:40:08.078Z';
const dateRangeEnd = '2019-09-11T19:40:08.078Z';

View file

@ -6,9 +6,9 @@
*/
import { journey, step, expect, before, Page } from '@elastic/synthetics';
import { byTestId, delay } from '@kbn/observability-plugin/e2e/utils';
import { makeChecksWithStatus } from '../../helpers/make_checks';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';
import { byTestId, delay } from '../utils';
journey('MonitorPingRedirects', async ({ page, params }: { page: Page; params: any }) => {
const monitorDetails = monitorDetailsPageProvider({ page, kibanaUrl: params.kibanaUrl });

View file

@ -7,9 +7,9 @@
import uuid from 'uuid';
import { journey, step, expect, before, after, Page } from '@elastic/synthetics';
import { byTestId } from '@kbn/observability-plugin/e2e/utils';
import { monitorManagementPageProvider } from '../page_objects/monitor_management';
import { DataStream } from '../../common/runtime_types/monitor_management';
import { byTestId } from './utils';
const customLocation = process.env.SYNTHETICS_TEST_LOCATION;

View file

@ -6,8 +6,8 @@
*/
import uuid from 'uuid';
import { journey, step, expect, before, Page } from '@elastic/synthetics';
import { byTestId } from '@kbn/observability-plugin/e2e/utils';
import { monitorManagementPageProvider } from '../page_objects/monitor_management';
import { byTestId } from './utils';
journey(`MonitorName`, async ({ page, params }: { page: Page; params: any }) => {
const name = `Test monitor ${uuid.v4()}`;

View file

@ -6,8 +6,8 @@
*/
import { before, expect, journey, Page, step } from '@elastic/synthetics';
import { byTestId } from '@kbn/observability-plugin/e2e/utils';
import { monitorManagementPageProvider } from '../../page_objects/monitor_management';
import { byTestId } from '../utils';
journey(
'Monitor Management read only user',

View file

@ -6,7 +6,7 @@
*/
import { journey, step, expect, before } from '@elastic/synthetics';
import { waitForLoadingToFinish } from './utils';
import { waitForLoadingToFinish } from '@kbn/observability-plugin/e2e/utils';
import { loginPageProvider } from '../page_objects/login';
journey('StepsDuration', async ({ page, params }) => {

View file

@ -6,7 +6,7 @@
*/
import { journey, step, before } from '@elastic/synthetics';
import { byTestId, waitForLoadingToFinish } from './utils';
import { byTestId, waitForLoadingToFinish } from '@kbn/observability-plugin/e2e/utils';
journey('uptime', ({ page, params }) => {
before(async () => {

View file

@ -6,7 +6,7 @@
*/
import { Page } from '@elastic/synthetics';
import { byTestId, delay } from '../journeys/utils';
import { byTestId, delay } from '@kbn/observability-plugin/e2e/utils';
import { monitorManagementPageProvider } from './monitor_management';
interface AlertType {

View file

@ -5,8 +5,8 @@
* 2.0.
*/
import { Page } from '@elastic/synthetics';
import { getQuerystring } from '@kbn/observability-plugin/e2e/utils';
import { DataStream } from '../../common/runtime_types/monitor_management';
import { getQuerystring } from '../journeys/utils';
import { loginPageProvider } from './login';
import { utilsPageProvider } from './utils';

View file

@ -6,9 +6,9 @@
*/
import { expect, Page } from '@elastic/synthetics';
import { byTestId } from '@kbn/observability-plugin/e2e/utils';
import { loginPageProvider } from './login';
import { utilsPageProvider } from './utils';
import { byTestId } from '../journeys/utils';
export function settingsPageProvider({ page }: { page: Page; kibanaUrl: string }) {
return {

View file

@ -6,9 +6,8 @@
*/
import { FtrConfigProviderContext } from '@kbn/test';
import path from 'path';
import { SyntheticsRunner } from './synthetics_start';
import { argv } from './parse_args_params';
import { argv } from '@kbn/observability-plugin/e2e/parse_args_params';
import { SyntheticsRunner } from '@kbn/observability-plugin/e2e/synthetics_runner';
const { headless, grep, bail: pauseOnError } = argv;

View file

@ -10,6 +10,9 @@
{
"path": "../../apm/tsconfig.json",
},
{
"path": "../../observability/e2e/tsconfig.json"
},
{
"path": "../tsconfig.json",
}

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { FtrConfigProviderContext } from '@kbn/test';
import { argv } from '@kbn/synthetics-plugin/e2e/parse_args_params';
import { SyntheticsRunner } from '@kbn/synthetics-plugin/e2e/synthetics_start';
import { argv } from '@kbn/observability-plugin/e2e/parse_args_params';
import path from 'path';
import { SyntheticsRunner } from '@kbn/observability-plugin/e2e/synthetics_runner';
const { headless, grep, bail: pauseOnError } = argv;

View file

@ -13,6 +13,9 @@
{
"path": "../../synthetics/e2e/tsconfig.json",
},
{
"path": "../../observability/e2e/tsconfig.json"
},
{
"path": "../tsconfig.json",
}