Skip to content

Commit

Permalink
Merge branch 'master' into bringing-cypress-tests-back
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 19, 2021
2 parents 4657dba + 3cb3984 commit 5a77fbd
Show file tree
Hide file tree
Showing 67 changed files with 2,267 additions and 144 deletions.
3 changes: 3 additions & 0 deletions packages/kbn-plugin-generator/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
23 changes: 17 additions & 6 deletions packages/kbn-plugin-generator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")

PKG_BASE_NAME = "kbn-plugin-generator"
PKG_REQUIRE_NAME = "@kbn/plugin-generator"
Expand Down Expand Up @@ -35,7 +36,7 @@ NPM_MODULE_EXTRA_FILES = [
":template",
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-utils",
"//packages/kbn-dev-utils",
"@npm//del",
Expand All @@ -49,6 +50,11 @@ SRC_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-utils",
"//packages/kbn-dev-utils",
"@npm//del",
"@npm//execa",
"@npm//globby",
"@npm//@types/ejs",
"@npm//@types/inquirer",
"@npm//@types/jest",
Expand All @@ -58,7 +64,11 @@ TYPES_DEPS = [
"@npm//@types/vinyl-fs",
]

DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

ts_config(
name = "tsconfig",
Expand All @@ -70,13 +80,14 @@ ts_config(
)

ts_project(
name = "tsc",
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
out_dir = "target",
emit_declaration_only = True,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
Expand All @@ -85,7 +96,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-plugin-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "target/index.js",
"types": "target/index.d.ts"
"main": "target_node/index.js",
"types": "target_types/index.d.ts"
}
5 changes: 3 additions & 2 deletions packages/kbn-plugin-generator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"outDir": "target",
"target": "ES2019",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-plugin-generator/src",
"target": "ES2019",
"types": [
"jest",
"node"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
* Describes current status of the Elasticsearch connection.
*/
export enum ElasticsearchConnectionStatus {
/**
* Indicates that Kibana hasn't figured out yet if existing Elasticsearch connection configuration is valid.
*/
Unknown = 'unknown',

/**
* Indicates that current Elasticsearch connection configuration valid and sufficient.
*/
Expand Down
43 changes: 43 additions & 0 deletions src/plugins/interactive_setup/server/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import { ConfigSchema } from './config';

describe('config schema', () => {
it('generates proper defaults', () => {
expect(ConfigSchema.validate({})).toMatchInlineSnapshot(`
Object {
"connectionCheck": Object {
"interval": "PT5S",
},
"enabled": false,
}
`);
});

describe('#connectionCheck', () => {
it('should properly set required connection check interval', () => {
expect(ConfigSchema.validate({ connectionCheck: { interval: '1s' } })).toMatchInlineSnapshot(`
Object {
"connectionCheck": Object {
"interval": "PT1S",
},
"enabled": false,
}
`);
});

it('should throw error if interactiveSetup.connectionCheck.interval is less than 1 second', () => {
expect(() =>
ConfigSchema.validate({ connectionCheck: { interval: 100 } })
).toThrowErrorMatchingInlineSnapshot(
`"[connectionCheck.interval]: the value must be greater or equal to 1 second."`
);
});
});
});
10 changes: 10 additions & 0 deletions src/plugins/interactive_setup/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ export type ConfigType = TypeOf<typeof ConfigSchema>;

export const ConfigSchema = schema.object({
enabled: schema.boolean({ defaultValue: false }),
connectionCheck: schema.object({
interval: schema.duration({
defaultValue: '5s',
validate(value) {
if (value.asSeconds() < 1) {
return 'the value must be greater or equal to 1 second.';
}
},
}),
}),
});
20 changes: 20 additions & 0 deletions src/plugins/interactive_setup/server/elasticsearch_service.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import { BehaviorSubject } from 'rxjs';

import { ElasticsearchConnectionStatus } from '../common';

export const elasticsearchServiceMock = {
createSetup: () => ({
connectionStatus$: new BehaviorSubject<ElasticsearchConnectionStatus>(
ElasticsearchConnectionStatus.Configured
),
enroll: jest.fn(),
}),
};
Loading

0 comments on commit 5a77fbd

Please sign in to comment.