Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ enabled:
- x-pack/platform/test/functional/apps/canvas/config.ts
- x-pack/platform/test/functional/apps/cross_cluster_replication/config.ts
- x-pack/platform/test/functional/apps/dashboard/group1/config.ts
- x-pack/platform/test/functional/apps/dashboard/group2/config.ts
- x-pack/platform/test/functional/apps/dashboard/group3/config.ts
- x-pack/platform/test/functional/apps/data_views/config.ts
- x-pack/platform/test/functional/apps/dev_tools/config.ts
Expand Down
1 change: 1 addition & 0 deletions .buildkite/scout_ci_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins:
- spaces
- streams_app
- transform
- dashboard
disabled:

packages:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,18 @@ export class EuiComboBoxWrapper {
}

// Select a single option in the comboBox
async selectSingleOption(value: string) {
async selectSingleOption(
value: string,
options: { optionTestSubj?: string; optionRoleName?: string } = {}
) {
await this.clear();
await this.comboBoxMainInput.click();
await this.typeValueInSearch(value);
await this.page.getByRole('option', { name: value }).click();
// Prefer a specific test subj when option text is ambiguous.
const optionLocator = options.optionTestSubj
? this.page.testSubj.locator(options.optionTestSubj)
: this.page.getByRole('option', { name: options.optionRoleName ?? value, exact: false });
await optionLocator.click();
expect(await this.getSelectedValue()).toBe(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,48 @@ export interface DataViewsApiService {
* Get all data views
* @returns Promise with array of data views and status
*/
getAll: () => Promise<DataViewApiResponse<DataView[]>>;
getAll: (spaceId?: string) => Promise<DataViewApiResponse<DataView[]>>;

/**
* Get a single data view by ID
* @param id - The data view ID
* @param spaceId - Optional space ID
* @returns Promise with the data view and status
*/
get: (id: string) => Promise<DataViewApiResponse<DataView>>;
get: (id: string, spaceId?: string) => Promise<DataViewApiResponse<DataView>>;

/**
* Delete a data view by ID
* @param id - The data view ID to delete
* @param spaceId - Optional space ID
* @returns Promise with status code
*/
delete: (id: string) => Promise<DataViewStatusResponse>;
delete: (id: string, spaceId?: string) => Promise<DataViewStatusResponse>;

/**
* Find data views that match a predicate function
* @param predicate - Function to filter data views
* @param spaceId - Optional space ID
* @returns Promise with filtered array of data views and status
*/
find: (predicate: (dataView: DataView) => boolean) => Promise<DataViewApiResponse<DataView[]>>;
find: (
predicate: (dataView: DataView) => boolean,
spaceId?: string
) => Promise<DataViewApiResponse<DataView[]>>;

/**
* Delete a data view by its title (convenience method)
* Finds the first data view matching the title and deletes it
* @param title - The data view title to search for
* @param spaceId - Optional space ID
* @returns Promise with status code
*/
deleteByTitle: (title: string) => Promise<DataViewStatusResponse>;
deleteByTitle: (title: string, spaceId?: string) => Promise<DataViewStatusResponse>;

/**
* Get data view ID by title (optionally within a space)
*/
getIdByTitle: (title: string, spaceId?: string) => Promise<string>;
}

/**
Expand All @@ -70,15 +82,17 @@ export const getDataViewsApiHelper = (
log: ScoutLogger,
kbnClient: KbnClient
): DataViewsApiService => {
const withSpace = (path: string, spaceId?: string) => (spaceId ? `/s/${spaceId}${path}` : path);

return {
getAll: async () => {
getAll: async (spaceId?: string) => {
return await measurePerformanceAsync(
log,
'dataViewsApi.getAll',
async (): Promise<DataViewApiResponse<DataView[]>> => {
const response = await kbnClient.request<GetDataViewsResponse>({
method: 'GET',
path: '/api/data_views',
path: withSpace('/api/data_views', spaceId),
retries: 3,
});

Expand All @@ -90,14 +104,14 @@ export const getDataViewsApiHelper = (
);
},

get: async (id: string) => {
get: async (id: string, spaceId?: string) => {
return await measurePerformanceAsync(
log,
'dataViewsApi.get',
async (): Promise<DataViewApiResponse<DataView>> => {
const response = await kbnClient.request<GetDataViewResponse>({
method: 'GET',
path: `/api/data_views/data_view/${id}`,
path: withSpace(`/api/data_views/data_view/${id}`, spaceId),
retries: 3,
ignoreErrors: [404],
});
Expand All @@ -110,14 +124,14 @@ export const getDataViewsApiHelper = (
);
},

delete: async (id: string) => {
delete: async (id: string, spaceId?: string) => {
return await measurePerformanceAsync(
log,
'dataViewsApi.delete',
async (): Promise<DataViewStatusResponse> => {
const response = await kbnClient.request({
method: 'DELETE',
path: `/api/data_views/data_view/${id}`,
path: withSpace(`/api/data_views/data_view/${id}`, spaceId),
retries: 3,
ignoreErrors: [404],
});
Expand All @@ -129,14 +143,14 @@ export const getDataViewsApiHelper = (
);
},

find: async (predicate: (dataView: DataView) => boolean) => {
find: async (predicate: (dataView: DataView) => boolean, spaceId?: string) => {
return await measurePerformanceAsync(
log,
'dataViewsApi.find',
async (): Promise<DataViewApiResponse<DataView[]>> => {
const response = await kbnClient.request<GetDataViewsResponse>({
method: 'GET',
path: '/api/data_views',
path: withSpace('/api/data_views', spaceId),
retries: 3,
});

Expand All @@ -151,14 +165,14 @@ export const getDataViewsApiHelper = (
);
},

deleteByTitle: async (title: string) => {
deleteByTitle: async (title: string, spaceId?: string) => {
return await measurePerformanceAsync(
log,
'dataViewsApi.deleteByTitle',
async (): Promise<DataViewStatusResponse> => {
const response = await kbnClient.request<GetDataViewsResponse>({
method: 'GET',
path: '/api/data_views',
path: withSpace('/api/data_views', spaceId),
retries: 3,
});

Expand All @@ -172,7 +186,7 @@ export const getDataViewsApiHelper = (

const deleteResponse = await kbnClient.request({
method: 'DELETE',
path: `/api/data_views/data_view/${dataView.id}`,
path: withSpace(`/api/data_views/data_view/${dataView.id}`, spaceId),
retries: 3,
ignoreErrors: [404],
});
Expand All @@ -183,5 +197,24 @@ export const getDataViewsApiHelper = (
}
);
},

getIdByTitle: async (title: string, spaceId?: string) => {
return await measurePerformanceAsync(log, 'dataViewsApi.getIdByTitle', async () => {
const response = await kbnClient.request<GetDataViewsResponse>({
method: 'GET',
path: withSpace('/api/data_views', spaceId),
retries: 3,
});
const match = (response.data.data_view || []).find(
(dataView) => dataView.title === title || dataView.name === title
);
if (!match?.id) {
throw new Error(
`Data view "${title}" not found${spaceId ? ` in space "${spaceId}"` : ''}`
);
}
return match.id;
});
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type { DataViewsApiService } from './data_views';
import { getDataViewsApiHelper } from './data_views';
import type { FleetApiService } from './fleet';
import { getFleetApiHelper } from './fleet';
import type { SampleDataApiService } from './sample_data';
import { getSampleDataApiHelper } from './sample_data';
import type { StreamsApiService } from './streams';
import { getStreamsApiService } from './streams';

Expand All @@ -26,6 +28,7 @@ export interface ApiServicesFixture {
cases: CasesApiService;
dataViews: DataViewsApiService;
fleet: FleetApiService;
sampleData: SampleDataApiService;
streams: StreamsApiService;
core: CoreApiService;
// add more services here
Expand All @@ -45,6 +48,7 @@ export const apiServicesFixture = coreWorkerFixtures.extend<
cases: getCasesApiHelper(log, kbnClient),
dataViews: getDataViewsApiHelper(log, kbnClient),
fleet: getFleetApiHelper(log, kbnClient),
sampleData: getSampleDataApiHelper(log, kbnClient),
streams: getStreamsApiService({ kbnClient, log }),
core: getCoreApiHelper(log, kbnClient),
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { KbnClient, ScoutLogger } from '../../../../../../common';
import { measurePerformanceAsync } from '../../../../../../common';

export interface SampleDataApiService {
install: (dataSetId: string, spaceId?: string) => Promise<void>;
remove: (dataSetId: string, spaceId?: string) => Promise<void>;
}

export const getSampleDataApiHelper = (
log: ScoutLogger,
kbnClient: KbnClient
): SampleDataApiService => {
const withSpace = (path: string, spaceId?: string) => (spaceId ? `/s/${spaceId}${path}` : path);

return {
install: async (dataSetId: string, spaceId?: string) => {
await measurePerformanceAsync(log, 'sampleDataApi.install', async () => {
await kbnClient.request({
method: 'POST',
path: withSpace(`/api/sample_data/${dataSetId}`, spaceId),
retries: 3,
});
});
},

remove: async (dataSetId: string, spaceId?: string) => {
await measurePerformanceAsync(log, 'sampleDataApi.remove', async () => {
await kbnClient.request({
method: 'DELETE',
path: withSpace(`/api/sample_data/${dataSetId}`, spaceId),
retries: 3,
ignoreErrors: [404],
});
});
},
};
};
Loading