Skip to content

Commit

Permalink
Merge branch '7.16' into permissions_deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 1, 2021
2 parents 9eec2b9 + 0c34705 commit fd70a66
Show file tree
Hide file tree
Showing 56 changed files with 1,001 additions and 739 deletions.
129 changes: 0 additions & 129 deletions src/plugins/home/server/services/new_instance_status.test.ts

This file was deleted.

66 changes: 0 additions & 66 deletions src/plugins/home/server/services/new_instance_status.ts

This file was deleted.

19 changes: 19 additions & 0 deletions src/plugins/screenshot_mode/public/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import type { ScreenshotModePluginSetup, ScreenshotModePluginStart } from './types';

export const screenshotModePluginMock = {
createSetupContract: (): DeeplyMockedKeys<ScreenshotModePluginSetup> => ({
isScreenshotMode: jest.fn(() => false),
}),
createStartContract: (): DeeplyMockedKeys<ScreenshotModePluginStart> => ({
isScreenshotMode: jest.fn(() => false),
}),
};
11 changes: 6 additions & 5 deletions test/functional/apps/visualize/_timelion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const elasticChart = getService('elasticChart');
const find = getService('find');
const retry = getService('retry');
const timelionChartSelector = 'timelionChart';

describe('Timelion visualization', () => {
Expand Down Expand Up @@ -265,7 +266,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
// wait for index patterns will be loaded
await common.sleep(500);
const suggestions = await timelion.getSuggestionItemsText();
expect(suggestions.length).not.to.eql(0);
expect(suggestions[0].includes('log')).to.eql(true);
});

Expand All @@ -290,7 +290,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await common.sleep(300);
const suggestions = await timelion.getSuggestionItemsText();

expect(suggestions.length).not.to.eql(0);
expect(suggestions[0].includes('@message.raw')).to.eql(true);
});

Expand All @@ -299,9 +298,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
'.es(index=logstash-*, timefield=@timestamp, metric=avg:',
'timelionCodeEditor'
);
const suggestions = await timelion.getSuggestionItemsText();
expect(suggestions.length).not.to.eql(0);
expect(suggestions[0].includes('avg:bytes')).to.eql(true);
// other suggestions might be shown for a short amount of time - retry until metric suggestions show up
await retry.try(async () => {
const suggestions = await timelion.getSuggestionItemsText();
expect(suggestions[0].includes('avg:bytes')).to.eql(true);
});
});
});
});
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/apm/dev_docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ The API tests are located in `x-pack/test/apm_api_integration/`.

**API Test tips**

- For debugging access Elasticsearch on http://localhost:9220 (`elastic` / `changeme`)
- For data generation in API tests have a look at the [elastic-apm-synthtrace](../../../../packages/elastic-apm-synthtrace/README.md) package
- For debugging access Elasticsearch on http://localhost:9220 and Kibana on http://localhost:5620 (`elastic` / `changeme`)
- To update snapshots append `--updateSnapshots` to the functional_test_runner command

---
Expand Down Expand Up @@ -74,3 +75,8 @@ yarn storybook apm
```

All files with a .stories.tsx extension will be loaded. You can access the development environment at http://localhost:9001.

## Data generation
For end-to-end (e.g. agent -> apm server -> elasticsearch <- kibana) development and testing of Elastic APM please check the the [APM Integration Testing repository](https://github.com/elastic/apm-integration-testing).

Data can also be generated using the [elastic-apm-synthtrace](../../../../packages/elastic-apm-synthtrace/README.md) CLI.
2 changes: 1 addition & 1 deletion x-pack/plugins/banners/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["licensing"],
"requiredPlugins": ["licensing", "screenshotMode"],
"optionalPlugins": [],
"requiredBundles": ["kibanaReact"],
"configPath": ["xpack", "banners"]
Expand Down
21 changes: 20 additions & 1 deletion x-pack/plugins/banners/public/plugin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { getBannerInfoMock } from './plugin.test.mocks';
import { coreMock } from '../../../../src/core/public/mocks';
import { screenshotModePluginMock } from '../../../../src/plugins/screenshot_mode/public/mocks';
import { BannerConfiguration } from '../common/types';
import { BannersPlugin } from './plugin';

Expand All @@ -25,11 +26,13 @@ describe('BannersPlugin', () => {
let pluginInitContext: ReturnType<typeof coreMock.createPluginInitializerContext>;
let coreSetup: ReturnType<typeof coreMock.createSetup>;
let coreStart: ReturnType<typeof coreMock.createStart>;
let screenshotModeStart: ReturnType<typeof screenshotModePluginMock.createStartContract>;

beforeEach(() => {
pluginInitContext = coreMock.createPluginInitializerContext();
coreSetup = coreMock.createSetup();
coreStart = coreMock.createStart();
screenshotModeStart = screenshotModePluginMock.createStartContract();

getBannerInfoMock.mockResolvedValue({
allowed: false,
Expand All @@ -41,7 +44,7 @@ describe('BannersPlugin', () => {
pluginInitContext = coreMock.createPluginInitializerContext();
plugin = new BannersPlugin(pluginInitContext);
plugin.setup(coreSetup);
plugin.start(coreStart);
plugin.start(coreStart, { screenshotMode: screenshotModeStart });
// await for the `getBannerInfo` promise to resolve
await nextTick();
};
Expand Down Expand Up @@ -79,6 +82,14 @@ describe('BannersPlugin', () => {

expect(coreStart.chrome.setHeaderBanner).toHaveBeenCalledTimes(0);
});

it('does not register the banner in screenshot mode', async () => {
screenshotModeStart.isScreenshotMode.mockReturnValue(true);

await startPlugin();

expect(coreStart.chrome.setHeaderBanner).not.toHaveBeenCalled();
});
});

describe('when banner is not allowed', () => {
Expand Down Expand Up @@ -107,5 +118,13 @@ describe('BannersPlugin', () => {

expect(coreStart.chrome.setHeaderBanner).toHaveBeenCalledTimes(0);
});

it('does not register the banner in screenshot mode', async () => {
screenshotModeStart.isScreenshotMode.mockReturnValue(true);

await startPlugin();

expect(coreStart.chrome.setHeaderBanner).not.toHaveBeenCalled();
});
});
});
32 changes: 19 additions & 13 deletions x-pack/plugins/banners/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,33 @@ import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core
import { toMountPoint } from '../../../../src/plugins/kibana_react/public';
import { Banner } from './components';
import { getBannerInfo } from './get_banner_info';
import { BannerPluginStartDependencies } from './types';

export class BannersPlugin implements Plugin<{}, {}, {}, {}> {
export class BannersPlugin implements Plugin<{}, {}, {}, BannerPluginStartDependencies> {
constructor(context: PluginInitializerContext) {}

setup({}: CoreSetup<{}, {}>) {
return {};
}

start({ chrome, uiSettings, http }: CoreStart) {
getBannerInfo(http).then(
({ allowed, banner }) => {
if (allowed && banner.placement === 'top') {
chrome.setHeaderBanner({
content: toMountPoint(<Banner bannerConfig={banner} />),
});
start(
{ chrome, uiSettings, http }: CoreStart,
{ screenshotMode }: BannerPluginStartDependencies
) {
if (!screenshotMode.isScreenshotMode()) {
getBannerInfo(http).then(
({ allowed, banner }) => {
if (allowed && banner.placement === 'top') {
chrome.setHeaderBanner({
content: toMountPoint(<Banner bannerConfig={banner} />),
});
}
},
() => {
chrome.setHeaderBanner(undefined);
}
},
() => {
chrome.setHeaderBanner(undefined);
}
);
);
}

return {};
}
Expand Down
Loading

0 comments on commit fd70a66

Please sign in to comment.