Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into task/EMT141-Polic…
Browse files Browse the repository at this point in the history
…y-UI-Route
  • Loading branch information
paul-tavares committed Feb 14, 2020
2 parents 13920fd + 948bfa9 commit 2d58030
Show file tree
Hide file tree
Showing 298 changed files with 7,527 additions and 3,186 deletions.
20 changes: 10 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a
'kibana-intake-agent': kibanaPipeline.intakeWorker('kibana-intake', './test/scripts/jenkins_unit.sh'),
'x-pack-intake-agent': kibanaPipeline.intakeWorker('x-pack-intake', './test/scripts/jenkins_xpack.sh'),
'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [
'oss-firefoxSmoke': kibanaPipeline.getPostBuildWorker('firefoxSmoke', {
retryable('kibana-firefoxSmoke') {
runbld('./test/scripts/jenkins_firefox_smoke.sh', 'Execute kibana-firefoxSmoke')
}
}),
// 'oss-firefoxSmoke': kibanaPipeline.getPostBuildWorker('firefoxSmoke', {
// retryable('kibana-firefoxSmoke') {
// runbld('./test/scripts/jenkins_firefox_smoke.sh', 'Execute kibana-firefoxSmoke')
// }
// }),
'oss-ciGroup1': kibanaPipeline.getOssCiGroupWorker(1),
'oss-ciGroup2': kibanaPipeline.getOssCiGroupWorker(2),
'oss-ciGroup3': kibanaPipeline.getOssCiGroupWorker(3),
Expand All @@ -39,11 +39,11 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a
// 'oss-visualRegression': kibanaPipeline.getPostBuildWorker('visualRegression', { runbld('./test/scripts/jenkins_visual_regression.sh', 'Execute kibana-visualRegression') }),
]),
'kibana-xpack-agent': kibanaPipeline.withWorkers('kibana-xpack-tests', { kibanaPipeline.buildXpack() }, [
'xpack-firefoxSmoke': kibanaPipeline.getPostBuildWorker('xpack-firefoxSmoke', {
retryable('xpack-firefoxSmoke') {
runbld('./test/scripts/jenkins_xpack_firefox_smoke.sh', 'Execute xpack-firefoxSmoke')
}
}),
// 'xpack-firefoxSmoke': kibanaPipeline.getPostBuildWorker('xpack-firefoxSmoke', {
// retryable('xpack-firefoxSmoke') {
// runbld('./test/scripts/jenkins_xpack_firefox_smoke.sh', 'Execute xpack-firefoxSmoke')
// }
// }),
'xpack-ciGroup1': kibanaPipeline.getXpackCiGroupWorker(1),
'xpack-ciGroup2': kibanaPipeline.getXpackCiGroupWorker(2),
'xpack-ciGroup3': kibanaPipeline.getXpackCiGroupWorker(3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IHttpFetchError extends Error
| Property | Type | Description |
| --- | --- | --- |
| [body](./kibana-plugin-public.ihttpfetcherror.body.md) | <code>any</code> | |
| [name](./kibana-plugin-public.ihttpfetcherror.name.md) | <code>string</code> | |
| [req](./kibana-plugin-public.ihttpfetcherror.req.md) | <code>Request</code> | |
| [request](./kibana-plugin-public.ihttpfetcherror.request.md) | <code>Request</code> | |
| [res](./kibana-plugin-public.ihttpfetcherror.res.md) | <code>Response</code> | |
Expand Down
2 changes: 1 addition & 1 deletion docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ us improve your user experience. Your data is never shared with anyone. Set to
`false` to disable telemetry capabilities entirely. You can alternatively opt
out through the *Advanced Settings* in {kib}.

`vega.enableExternalUrls:`:: *Default: false* Set this value to true to allow Vega to use any URL to access external data sources and images. If false, Vega can only get data from Elasticsearch.
`vis_type_vega.enableExternalUrls:`:: *Default: false* Set this value to true to allow Vega to use any URL to access external data sources and images. If false, Vega can only get data from Elasticsearch.

`xpack.license_management.enabled`:: *Default: true* Set this value to false to
disable the License Management user interface.
Expand Down
5 changes: 0 additions & 5 deletions src/core/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ This document outlines best practices and patterns for testing Kibana Plugins.
- [Testing dependencies usages](#testing-dependencies-usages)
- [Testing components consuming the dependencies](#testing-components-consuming-the-dependencies)
- [Testing optional plugin dependencies](#testing-optional-plugin-dependencies)
- [Plugin Contracts](#plugin-contracts)

## Strategy

Expand Down Expand Up @@ -1082,7 +1081,3 @@ describe('Plugin', () => {
});
});
```
## Plugin Contracts
_How to test your plugin's exposed API_
42 changes: 37 additions & 5 deletions src/core/public/http/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Fetch', () => {
});
afterEach(() => {
fetchMock.restore();
fetchInstance.removeAllInterceptors();
});

describe('http requests', () => {
Expand Down Expand Up @@ -287,6 +288,42 @@ describe('Fetch', () => {
});
});

it('preserves the name of the original error', async () => {
expect.assertions(1);

const abortError = new DOMException('The operation was aborted.', 'AbortError');

fetchMock.get('*', Promise.reject(abortError));

await fetchInstance.fetch('/my/path').catch(e => {
expect(e.name).toEqual('AbortError');
});
});

it('exposes the request to the interceptors in case of aborted request', async () => {
const responseErrorSpy = jest.fn();
const abortError = new DOMException('The operation was aborted.', 'AbortError');

fetchMock.get('*', Promise.reject(abortError));

fetchInstance.intercept({
responseError: responseErrorSpy,
});

await expect(fetchInstance.fetch('/my/path')).rejects.toThrow();

expect(responseErrorSpy).toHaveBeenCalledTimes(1);
const interceptedResponse = responseErrorSpy.mock.calls[0][0];

expect(interceptedResponse.request).toEqual(
expect.objectContaining({
method: 'GET',
url: 'http://localhost/myBase/my/path',
})
);
expect(interceptedResponse.error.name).toEqual('AbortError');
});

it('should support get() helper', async () => {
fetchMock.get('*', {});
await fetchInstance.get('/my/path', { method: 'POST' });
Expand Down Expand Up @@ -368,11 +405,6 @@ describe('Fetch', () => {
fetchMock.get('*', { foo: 'bar' });
});

afterEach(() => {
fetchMock.restore();
fetchInstance.removeAllInterceptors();
});

it('should make request and receive response', async () => {
fetchInstance.intercept({});

Expand Down
10 changes: 3 additions & 7 deletions src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ export class Fetch {
try {
response = await window.fetch(request);
} catch (err) {
if (err.name === 'AbortError') {
throw err;
} else {
throw new HttpFetchError(err.message, request);
}
throw new HttpFetchError(err.message, err.name ?? 'Error', request);
}

const contentType = response.headers.get('Content-Type') || '';
Expand All @@ -170,11 +166,11 @@ export class Fetch {
}
}
} catch (err) {
throw new HttpFetchError(err.message, request, response, body);
throw new HttpFetchError(err.message, err.name ?? 'Error', request, response, body);
}

if (!response.ok) {
throw new HttpFetchError(response.statusText, request, response, body);
throw new HttpFetchError(response.statusText, 'Error', request, response, body);
}

return { fetchOptions, request, response, body };
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/http/http_fetch_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ import { IHttpFetchError } from './types';

/** @internal */
export class HttpFetchError extends Error implements IHttpFetchError {
public readonly name: string;
public readonly req: Request;
public readonly res?: Response;

constructor(
message: string,
name: string,
public readonly request: Request,
public readonly response?: Response,
public readonly body?: any
) {
super(message);
this.name = name;
this.req = request;
this.res = response;

Expand Down
1 change: 1 addition & 0 deletions src/core/public/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export interface IHttpResponseInterceptorOverrides<TResponseBody = any> {

/** @public */
export interface IHttpFetchError extends Error {
readonly name: string;
readonly request: Request;
readonly response?: Response;
/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ export type IContextProvider<THandler extends HandlerFunction<any>, TContextName
export interface IHttpFetchError extends Error {
// (undocumented)
readonly body?: any;
// (undocumented)
readonly name: string;
// @deprecated (undocumented)
readonly req: Request;
// (undocumented)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 2 additions & 66 deletions src/core/server/legacy/plugins/find_legacy_plugin_specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,72 +30,8 @@ import { collectUiExports as collectLegacyUiExports } from '../../../../legacy/u

import { LoggerFactory } from '../../logging';
import { PackageInfo } from '../../config';

import {
LegacyUiExports,
LegacyNavLink,
LegacyPluginSpec,
LegacyPluginPack,
LegacyConfig,
} from '../types';

const REMOVE_FROM_ARRAY: LegacyNavLink[] = [];

function getUiAppsNavLinks({ uiAppSpecs = [] }: LegacyUiExports, pluginSpecs: LegacyPluginSpec[]) {
return uiAppSpecs.flatMap(spec => {
if (!spec) {
return REMOVE_FROM_ARRAY;
}

const id = spec.pluginId || spec.id;

if (!id) {
throw new Error('Every app must specify an id');
}

if (spec.pluginId && !pluginSpecs.some(plugin => plugin.getId() === spec.pluginId)) {
throw new Error(`Unknown plugin id "${spec.pluginId}"`);
}

const listed = typeof spec.listed === 'boolean' ? spec.listed : true;

if (spec.hidden || !listed) {
return REMOVE_FROM_ARRAY;
}

return {
id,
category: spec.category,
title: spec.title,
order: typeof spec.order === 'number' ? spec.order : 0,
icon: spec.icon,
euiIconType: spec.euiIconType,
url: spec.url || `/app/${id}`,
linkToLastSubUrl: spec.linkToLastSubUrl,
};
});
}

function getNavLinks(uiExports: LegacyUiExports, pluginSpecs: LegacyPluginSpec[]) {
return (uiExports.navLinkSpecs || [])
.map<LegacyNavLink>(spec => ({
id: spec.id,
category: spec.category,
title: spec.title,
order: typeof spec.order === 'number' ? spec.order : 0,
url: spec.url,
subUrlBase: spec.subUrlBase || spec.url,
disableSubUrlTracking: spec.disableSubUrlTracking,
icon: spec.icon,
euiIconType: spec.euiIconType,
linkToLastSub: 'linkToLastSubUrl' in spec ? spec.linkToLastSubUrl : false,
hidden: 'hidden' in spec ? spec.hidden : false,
disabled: 'disabled' in spec ? spec.disabled : false,
tooltip: spec.tooltip || '',
}))
.concat(getUiAppsNavLinks(uiExports, pluginSpecs))
.sort((a, b) => a.order - b.order);
}
import { LegacyPluginSpec, LegacyPluginPack, LegacyConfig } from '../types';
import { getNavLinks } from './get_nav_links';

export async function findLegacyPluginSpecs(
settings: unknown,
Expand Down
Loading

0 comments on commit 2d58030

Please sign in to comment.