Skip to content

Commit bd4b793

Browse files
committed
Merge remote-tracking branch 'upstream/master' into kbn-56244-wrap-abort-error
2 parents a79d30c + 8513498 commit bd4b793

File tree

223 files changed

+4985
-1734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+4985
-1734
lines changed

src/core/TESTING.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ This document outlines best practices and patterns for testing Kibana Plugins.
2929
- [Testing dependencies usages](#testing-dependencies-usages)
3030
- [Testing components consuming the dependencies](#testing-components-consuming-the-dependencies)
3131
- [Testing optional plugin dependencies](#testing-optional-plugin-dependencies)
32-
- [Plugin Contracts](#plugin-contracts)
3332

3433
## Strategy
3534

@@ -1082,7 +1081,3 @@ describe('Plugin', () => {
10821081
});
10831082
});
10841083
```
1085-
1086-
## Plugin Contracts
1087-
1088-
_How to test your plugin's exposed API_

src/legacy/core_plugins/kibana/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { migrations } from './migrations';
2525
import { importApi } from './server/routes/api/import';
2626
import { exportApi } from './server/routes/api/export';
2727
import { managementApi } from './server/routes/api/management';
28-
import * as systemApi from './server/lib/system_api';
2928
import mappings from './mappings.json';
3029
import { getUiSettingDefaults } from './ui_setting_defaults';
3130
import { registerCspCollector } from './server/lib/csp_usage_collector';
@@ -323,7 +322,6 @@ export default function(kibana) {
323322
exportApi(server);
324323
managementApi(server);
325324
registerCspCollector(usageCollection, server);
326-
server.expose('systemApi', systemApi);
327325
server.injectUiAppVars('kibana', () => injectVars(server));
328326
},
329327
});

src/legacy/core_plugins/kibana/public/home/np_ready/components/__snapshots__/sample_data_view_data_button.test.js.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/legacy/core_plugins/kibana/public/home/np_ready/components/sample_data_view_data_button.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export class SampleDataViewDataButton extends React.Component {
112112
closePopover={this.closePopover}
113113
panelPaddingSize="none"
114114
anchorPosition="downCenter"
115+
data-test-subj={`launchSampleDataSet${this.props.id}`}
115116
>
116117
<EuiContextMenu initialPanelId={0} panels={panels} />
117118
</EuiPopover>

src/legacy/core_plugins/kibana/server/lib/__tests__/system_api.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/legacy/core_plugins/kibana/server/lib/system_api.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/legacy/ui/public/system_api/__tests__/system_api.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,25 @@ describe('system_api', () => {
3131
};
3232
const newHeaders = addSystemApiHeader(headers);
3333

34-
expect(newHeaders).to.have.property('kbn-system-api');
35-
expect(newHeaders['kbn-system-api']).to.be(true);
34+
expect(newHeaders).to.have.property('kbn-system-request');
35+
expect(newHeaders['kbn-system-request']).to.be(true);
3636

3737
expect(newHeaders).to.have.property('kbn-version');
3838
expect(newHeaders['kbn-version']).to.be('4.6.0');
3939
});
4040
});
4141

4242
describe('#isSystemApiRequest', () => {
43-
it('returns true for a system API HTTP request', () => {
43+
it('returns true for a system HTTP request', () => {
44+
const mockRequest = {
45+
headers: {
46+
'kbn-system-request': true,
47+
},
48+
};
49+
expect(isSystemApiRequest(mockRequest)).to.be(true);
50+
});
51+
52+
it('returns true for a legacy system API HTTP request', () => {
4453
const mockRequest = {
4554
headers: {
4655
'kbn-system-api': true,

src/plugins/kibana_legacy/public/utils/system_api.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
import { IRequestConfig } from 'angular';
2121

22-
const SYSTEM_API_HEADER_NAME = 'kbn-system-api';
22+
const SYSTEM_REQUEST_HEADER_NAME = 'kbn-system-request';
23+
const LEGACY_SYSTEM_API_HEADER_NAME = 'kbn-system-api';
2324

2425
/**
2526
* Adds a custom header designating request as system API
@@ -28,7 +29,7 @@ const SYSTEM_API_HEADER_NAME = 'kbn-system-api';
2829
*/
2930
export function addSystemApiHeader(originalHeaders: Record<string, string>) {
3031
const systemApiHeaders = {
31-
[SYSTEM_API_HEADER_NAME]: true,
32+
[SYSTEM_REQUEST_HEADER_NAME]: true,
3233
};
3334
return {
3435
...originalHeaders,
@@ -44,5 +45,7 @@ export function addSystemApiHeader(originalHeaders: Record<string, string>) {
4445
*/
4546
export function isSystemApiRequest(request: IRequestConfig) {
4647
const { headers } = request;
47-
return headers && !!headers[SYSTEM_API_HEADER_NAME];
48+
return (
49+
headers && (!!headers[SYSTEM_REQUEST_HEADER_NAME] || !!headers[LEGACY_SYSTEM_API_HEADER_NAME])
50+
);
4851
}

test/functional/apps/home/_sample_data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
8484
});
8585

8686
it('should launch sample flights data set dashboard', async () => {
87-
await PageObjects.home.launchSampleDataSet('flights');
87+
await PageObjects.home.launchSampleDashboard('flights');
8888
await PageObjects.header.waitUntilLoadingHasFinished();
8989
await renderable.waitForRender();
9090
const todayYearMonthDay = moment().format('MMM D, YYYY');
@@ -96,7 +96,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
9696
});
9797

9898
it('should render visualizations', async () => {
99-
await PageObjects.home.launchSampleDataSet('flights');
99+
await PageObjects.home.launchSampleDashboard('flights');
100100
await PageObjects.header.waitUntilLoadingHasFinished();
101101
await renderable.waitForRender();
102102
log.debug('Checking pie charts rendered');
@@ -115,7 +115,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
115115
});
116116

117117
it('should launch sample logs data set dashboard', async () => {
118-
await PageObjects.home.launchSampleDataSet('logs');
118+
await PageObjects.home.launchSampleDashboard('logs');
119119
await PageObjects.header.waitUntilLoadingHasFinished();
120120
await renderable.waitForRender();
121121
const todayYearMonthDay = moment().format('MMM D, YYYY');
@@ -127,7 +127,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
127127
});
128128

129129
it('should launch sample ecommerce data set dashboard', async () => {
130-
await PageObjects.home.launchSampleDataSet('ecommerce');
130+
await PageObjects.home.launchSampleDashboard('ecommerce');
131131
await PageObjects.header.waitUntilLoadingHasFinished();
132132
await renderable.waitForRender();
133133
const todayYearMonthDay = moment().format('MMM D, YYYY');

test/functional/page_objects/home_page.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919

2020
import { FtrProviderContext } from '../ftr_provider_context';
2121

22-
export function HomePageProvider({ getService }: FtrProviderContext) {
22+
export function HomePageProvider({ getService, getPageObjects }: FtrProviderContext) {
2323
const testSubjects = getService('testSubjects');
2424
const retry = getService('retry');
25+
const find = getService('find');
26+
const PageObjects = getPageObjects(['common']);
27+
let isOss = true;
2528

2629
class HomePage {
2730
async clickSynopsis(title: string) {
@@ -63,6 +66,14 @@ export function HomePageProvider({ getService }: FtrProviderContext) {
6366
});
6467
}
6568

69+
async launchSampleDashboard(id: string) {
70+
await this.launchSampleDataSet(id);
71+
isOss = await PageObjects.common.isOss();
72+
if (!isOss) {
73+
await find.clickByLinkText('Dashboard');
74+
}
75+
}
76+
6677
async launchSampleDataSet(id: string) {
6778
await this.addSampleDataSet(id);
6879
await testSubjects.click(`launchSampleDataSet${id}`);

0 commit comments

Comments
 (0)