Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
aac9d14
Boilerplate from scaffolding command
steliosmavro Jan 30, 2026
446d774
Migrate Dashboard's FTR CRUD API tests to Scout
steliosmavro Jan 31, 2026
2866bbc
Remove FTR tests and update CI configuration
steliosmavro Jan 31, 2026
715e4ed
Update TypeScript configuration to include Scout test files and add S…
steliosmavro Jan 31, 2026
9e1e6fa
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Jan 31, 2026
b980b2c
Update tsconfig to include JSON files in Scout test directory
steliosmavro Jan 31, 2026
9bc29ec
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Jan 31, 2026
a5b0886
Use ESS_ONLY tag for tests using editor role because editor role does…
steliosmavro Jan 31, 2026
cc3a93d
Tag schema test as ESS_ONLY
steliosmavro Jan 31, 2026
23fa3d7
Merge branch 'main' into scout-migration-dashboard-crud-api
steliosmavro Feb 1, 2026
cd15d5a
Enable OAS endpoint in Scout serverless config
steliosmavro Feb 2, 2026
f092e52
Address feedback
steliosmavro Feb 2, 2026
bbd4092
Add validation for response body in dashboard REST schema tests
steliosmavro Feb 2, 2026
35a4ea8
Merge branch 'main' into scout-migration-dashboard-crud-api
steliosmavro Feb 2, 2026
7fec875
Move Dashboard OAS schema tests to custom server config
steliosmavro Feb 3, 2026
4d560ef
hotfix
steliosmavro Feb 3, 2026
2173b54
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Feb 3, 2026
7138b58
hotfix
steliosmavro Feb 4, 2026
e11cee1
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Feb 4, 2026
c857259
Remove parallel api tests
steliosmavro Feb 4, 2026
21ed4ee
Merge branch 'main' into scout-migration-dashboard-crud-api
steliosmavro Feb 4, 2026
eb0fd4c
Merge branch 'main' into scout-migration-dashboard-crud-api
steliosmavro Feb 4, 2026
a8fb2ae
Add missing comma
steliosmavro Feb 4, 2026
dd4a406
Remove final comma that caused 1 test to fail among 25 others in Flak…
steliosmavro Feb 4, 2026
6fff2d3
Merge branch 'main' into scout-migration-dashboard-crud-api
steliosmavro Feb 5, 2026
5a91a38
Merge branch 'main' into scout-migration-dashboard-crud-api
steliosmavro Feb 5, 2026
545d67e
Merge branch 'main' into scout-migration-dashboard-crud-api
steliosmavro Feb 5, 2026
aff266a
Small fix after merging main
steliosmavro Feb 6, 2026
24c17eb
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Feb 6, 2026
4f37808
Enhanced oas schema validation with extra assertion
steliosmavro Feb 6, 2026
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: 1 addition & 0 deletions .buildkite/scout_ci_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins:
enabled:
- apm
- console
- dashboard
- cloud_security_posture
- discover_enhanced
- entity_store
Expand Down
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,6 @@ x-pack/platform/plugins/shared/streams_app/public/components/data_management/str
/x-pack/platform/test/fixtures/es_archives/dashboard/async_search @elastic/kibana-presentation
/src/platform/test/functional/fixtures/kbn_archiver/dashboard @elastic/kibana-presentation
/src/platform/test/functional/fixtures/kbn_archiver/canvas @elastic/kibana-presentation
/src/platform/test/api_integration/apis/dashboards @elastic/kibana-presentation
/src/platform/test/interpreter_functional/snapshots @elastic/kibana-presentation # Assigned per https://github.com/elastic/kibana/pull/54342
/src/platform/test/functional/services/inspector.ts @elastic/kibana-presentation
/x-pack/platform/test/functional/services/canvas_element.ts @elastic/kibana-presentation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 { servers as defaultConfig } from '../../../default/serverless/es.serverless.config';
import type { ScoutServerConfig } from '../../../../../types';

/**
* Custom Scout server configuration for OAS (OpenAPI Specification) schema validation tests.
* Enables the OAS endpoint which is required for schema validation.
*
* This config is automatically used when running tests from:
* dashboard/test/scout_oas_schema/
*
* Usage:
* node scripts/scout.js start-server --serverless=es --config-dir oas_schema
*/
export const servers: ScoutServerConfig = {
...defaultConfig,
kbnTestServer: {
...defaultConfig.kbnTestServer,
serverArgs: [
...defaultConfig.kbnTestServer.serverArgs,
// Enable OpenAPI specification endpoint for schema validation tests
'--server.oas.enabled=true',
],
Comment thread
dmlemeshko marked this conversation as resolved.
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 { servers as defaultConfig } from '../../../default/serverless/oblt.serverless.config';
import type { ScoutServerConfig } from '../../../../../types';

/**
* Custom Scout server configuration for OAS (OpenAPI Specification) schema validation tests.
* Enables the OAS endpoint which is required for schema validation.
*
* This config is automatically used when running tests from:
* dashboard/test/scout_oas_schema/
*
* Usage:
* node scripts/scout.js start-server --serverless=oblt --config-dir oas_schema
*/
export const servers: ScoutServerConfig = {
...defaultConfig,
kbnTestServer: {
...defaultConfig.kbnTestServer,
serverArgs: [
...defaultConfig.kbnTestServer.serverArgs,
// Enable OpenAPI specification endpoint for schema validation tests
'--server.oas.enabled=true',
],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 { servers as defaultConfig } from '../../../default/serverless/security.serverless.config';
import type { ScoutServerConfig } from '../../../../../types';

/**
* Custom Scout server configuration for OAS (OpenAPI Specification) schema validation tests.
* Enables the OAS endpoint which is required for schema validation.
*
* This config is automatically used when running tests from:
* dashboard/test/scout_oas_schema/
*
* Usage:
* node scripts/scout.js start-server --serverless=security --config-dir oas_schema
*/
export const servers: ScoutServerConfig = {
...defaultConfig,
kbnTestServer: {
...defaultConfig.kbnTestServer,
serverArgs: [
...defaultConfig.kbnTestServer.serverArgs,
// Enable OpenAPI specification endpoint for schema validation tests
'--server.oas.enabled=true',
],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 { ScoutServerConfig } from '../../../../../types';
import { defaultConfig } from '../../../default/stateful/base.config';

/**
* Custom Scout server configuration for OAS (OpenAPI Specification) schema validation tests.
* Enables the OAS endpoint which is required for schema validation.
*
* This config is automatically used when running tests from:
* dashboard/test/scout_oas_schema/
*
* Usage:
* node scripts/scout.js start-server --stateful --config-dir oas_schema
*/
export const servers: ScoutServerConfig = {
...defaultConfig,
kbnTestServer: {
...defaultConfig.kbnTestServer,
serverArgs: [
...defaultConfig.kbnTestServer.serverArgs,
// Enable OpenAPI specification endpoint for schema validation tests
'--server.oas.enabled=true',
],
},
};
3 changes: 3 additions & 0 deletions src/platform/plugins/shared/dashboard/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ dependsOn:
- '@kbn/core-chrome-app-menu-components'
- '@kbn/core-chrome-app-menu'
- '@kbn/test-jest-helpers'
- '@kbn/scout'
- '@kbn/image-embeddable-plugin'
tags:
- plugin
Expand All @@ -130,6 +131,8 @@ fileGroups:
- public/**/*
- server/**/*
- test/scout/**/*
- test/scout_oas_schema/**/*
- test/scout_oas_schema/**/*.json
- '!target/**/*'
tasks:
jest:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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".
*/

/** The base API path for dashboard endpoints (no leading slash for apiClient). */
export const DASHBOARD_API_PATH = 'api/dashboards';

/** Common headers for Dashboard API requests (internal API version 1) */
export const COMMON_HEADERS = {
'kbn-xsrf': 'some-xsrf-token',
'x-elastic-internal-origin': 'kibana',
'elastic-api-version': '1',
} as const;

/** Test data paths */
export const KBN_ARCHIVES = {
BASIC: 'src/platform/test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json',
TAGS: 'src/platform/test/api_integration/fixtures/kbn_archiver/saved_objects/tags.json',
MANY_DASHBOARDS:
'src/platform/test/api_integration/fixtures/kbn_archiver/saved_objects/many-dashboards.json',
} as const;

/** Test dashboard ID used in fixtures - is a saved object loaded by the kbn_archiver */
export const TEST_DASHBOARD_ID = 'be3733a0-9efe-11e7-acb3-3dab96693fab';
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { FtrProviderContext } from '../../ftr_provider_context';
import type { ScoutTestFixtures, ScoutWorkerFixtures } from '@kbn/scout';
import { apiTest as baseApiTest } from '@kbn/scout';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('dashboards', () => {
loadTestFile(require.resolve('./create_dashboard'));
loadTestFile(require.resolve('./delete_dashboard'));
loadTestFile(require.resolve('./get_dashboard'));
loadTestFile(require.resolve('./update_dashboard'));
loadTestFile(require.resolve('./search_dashboards'));
});
}
export const apiTest = baseApiTest.extend<ScoutTestFixtures, ScoutWorkerFixtures>({});

export { COMMON_HEADERS, DASHBOARD_API_PATH, KBN_ARCHIVES, TEST_DASHBOARD_ID } from './constants';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 { createPlaywrightConfig } from '@kbn/scout';

export default createPlaywrightConfig({
testDir: './tests',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* 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 { RoleApiCredentials } from '@kbn/scout';
import { expect } from '@kbn/scout/api';
import { tags } from '@kbn/scout';
import {
apiTest,
COMMON_HEADERS,
DASHBOARD_API_PATH,
KBN_ARCHIVES,
TEST_DASHBOARD_ID,
} from '../fixtures';

apiTest.describe('dashboards - create', { tag: tags.ESS_ONLY }, () => {
Copy link
Copy Markdown
Member

@csr csr Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears most tests can be run on serverless projects as well, we could update the tags:

Suggested change
apiTest.describe('dashboards - create', { tag: tags.ESS_ONLY }, () => {
apiTest.describe('dashboards - create', { tag: tags.DEPLOYMENT_AGNOSTIC }, () => {

Actually, dashboards may not be available in all projects types (such as @svlLogsEssentials, we need to check <-- you can try starting the Scout servers with that project type), so we may need to list tags manually: e.g., @svlOblt, @svlSecurity and svlSearch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About this one, the ESS_ONLY tag is because of the editor role I use to apply the writes. Serverless uses developer instead of editor. I checked other tests that use editor role and they are all ESS_ONLY.

As far as I understand, once we can have an equivalent method to loginAsPrivilegedUser, we can come back and update these tests to also include Serverless environment as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great 👍 I wonder if we should create an issue in our internal backlog to remember about getting back to updating the test suites tags. What do you think?

let editorCredentials: RoleApiCredentials;

apiTest.beforeAll(async ({ kbnClient, requestAuth }) => {
editorCredentials = await requestAuth.getApiKey('editor');
await kbnClient.importExport.load(KBN_ARCHIVES.BASIC);
await kbnClient.importExport.load(KBN_ARCHIVES.TAGS);
});

apiTest.afterAll(async ({ kbnClient }) => {
await kbnClient.savedObjects.cleanStandardList();
});

apiTest('should create a dashboard', async ({ apiClient }) => {
const title = 'Hello world dashboard';

const response = await apiClient.post(DASHBOARD_API_PATH, {
headers: {
...COMMON_HEADERS,
...editorCredentials.apiKeyHeader,
},
body: {
data: {
title,
},
},
responseType: 'json',
});

expect(response).toHaveStatusCode(200);
expect(response.body.spaces).toStrictEqual(['default']);
expect(response.body.data).toStrictEqual({
title,
});
});

apiTest('can create a dashboard with a specific id', async ({ apiClient }) => {
const title = `foo-${Date.now()}-${Math.random()}`;
const id = `bar-${Date.now()}-${Math.random()}`;

const response = await apiClient.post(DASHBOARD_API_PATH, {
headers: {
...COMMON_HEADERS,
...editorCredentials.apiKeyHeader,
},
body: {
id,
data: {
title,
},
},
responseType: 'json',
});

expect(response).toHaveStatusCode(200);
expect(response.body.id).toBe(id);
});

// TODO Maybe move this test to x-pack/platform/test/api_integration/dashboards
apiTest('can create a dashboard in a defined space', async ({ apiClient }) => {
const title = `foo-${Date.now()}-${Math.random()}`;
const spaceId = 'space-1';

const response = await apiClient.post(DASHBOARD_API_PATH, {
headers: {
...COMMON_HEADERS,
...editorCredentials.apiKeyHeader,
},
body: {
data: {
title,
},
spaces: [spaceId],
},
responseType: 'json',
});

expect(response).toHaveStatusCode(200);
expect(response.body.spaces).toStrictEqual([spaceId]);
});

apiTest('return error if provided id already exists', async ({ apiClient }) => {
const title = `foo-${Date.now()}-${Math.random()}`;

const response = await apiClient.post(DASHBOARD_API_PATH, {
headers: {
...COMMON_HEADERS,
...editorCredentials.apiKeyHeader,
},
body: {
id: TEST_DASHBOARD_ID,
data: {
title,
},
},
responseType: 'json',
});

expect(response).toHaveStatusCode(409);
expect(response.body.message).toBe(`A dashboard with ID ${TEST_DASHBOARD_ID} already exists.`);
});

apiTest('validation - returns error when title is not provided', async ({ apiClient }) => {
const response = await apiClient.post(DASHBOARD_API_PATH, {
headers: {
...COMMON_HEADERS,
...editorCredentials.apiKeyHeader,
},
body: {
data: {},
},
responseType: 'json',
});

expect(response).toHaveStatusCode(400);
expect(response.body.message).toBe(
'[request body.data.title]: expected value of type [string] but got [undefined]'
);
});

apiTest('validation - returns error if panels is not an array', async ({ apiClient }) => {
const response = await apiClient.post(DASHBOARD_API_PATH, {
headers: {
...COMMON_HEADERS,
...editorCredentials.apiKeyHeader,
},
body: {
data: {
title: 'foo',
panels: {},
},
},
responseType: 'json',
});

expect(response).toHaveStatusCode(400);
expect(response.body.message).toBe(
'[request body.data.panels]: expected value of type [array] but got [Object]'
);
});
});
Loading
Loading