|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import { loggerMock } from '../../logging/logger.mock'; |
| 21 | +import { logLegacyThirdPartyPluginDeprecationWarning } from './log_legacy_plugins_warning'; |
| 22 | +import { LegacyPluginSpec } from '../types'; |
| 23 | + |
| 24 | +const createPluginSpec = ({ id, path }: { id: string; path: string }): LegacyPluginSpec => { |
| 25 | + return { |
| 26 | + getId: () => id, |
| 27 | + getExpectedKibanaVersion: () => 'kibana', |
| 28 | + getConfigPrefix: () => 'plugin.config', |
| 29 | + getDeprecationsProvider: () => undefined, |
| 30 | + getPack: () => ({ |
| 31 | + getPath: () => path, |
| 32 | + }), |
| 33 | + }; |
| 34 | +}; |
| 35 | + |
| 36 | +describe('logLegacyThirdPartyPluginDeprecationWarning', () => { |
| 37 | + let log: ReturnType<typeof loggerMock.create>; |
| 38 | + |
| 39 | + beforeEach(() => { |
| 40 | + log = loggerMock.create(); |
| 41 | + }); |
| 42 | + |
| 43 | + it('logs warning for third party plugins', () => { |
| 44 | + logLegacyThirdPartyPluginDeprecationWarning({ |
| 45 | + specs: [createPluginSpec({ id: 'plugin', path: '/some-external-path' })], |
| 46 | + log, |
| 47 | + }); |
| 48 | + expect(log.warn).toHaveBeenCalledTimes(1); |
| 49 | + expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` |
| 50 | + Array [ |
| 51 | + "Some installed third party plugin(s) [plugin] are using the legacy plugin format and will no longer work in a future Kibana release. Please refer to https://www.elastic.co/guide/en/kibana/master/breaking-changes-8.0.html for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", |
| 52 | + ] |
| 53 | + `); |
| 54 | + }); |
| 55 | + |
| 56 | + it('lists all the deprecated plugins and only log once', () => { |
| 57 | + logLegacyThirdPartyPluginDeprecationWarning({ |
| 58 | + specs: [ |
| 59 | + createPluginSpec({ id: 'pluginA', path: '/abs/path/to/pluginA' }), |
| 60 | + createPluginSpec({ id: 'pluginB', path: '/abs/path/to/pluginB' }), |
| 61 | + createPluginSpec({ id: 'pluginC', path: '/abs/path/to/pluginC' }), |
| 62 | + ], |
| 63 | + log, |
| 64 | + }); |
| 65 | + expect(log.warn).toHaveBeenCalledTimes(1); |
| 66 | + expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` |
| 67 | + Array [ |
| 68 | + "Some installed third party plugin(s) [pluginA, pluginB, pluginC] are using the legacy plugin format and will no longer work in a future Kibana release. Please refer to https://www.elastic.co/guide/en/kibana/master/breaking-changes-8.0.html for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", |
| 69 | + ] |
| 70 | + `); |
| 71 | + }); |
| 72 | + |
| 73 | + it('does not log warning for internal legacy plugins', () => { |
| 74 | + logLegacyThirdPartyPluginDeprecationWarning({ |
| 75 | + specs: [ |
| 76 | + createPluginSpec({ |
| 77 | + id: 'plugin', |
| 78 | + path: '/absolute/path/to/kibana/src/legacy/core_plugins', |
| 79 | + }), |
| 80 | + createPluginSpec({ |
| 81 | + id: 'plugin', |
| 82 | + path: '/absolute/path/to/kibana/x-pack', |
| 83 | + }), |
| 84 | + ], |
| 85 | + log, |
| 86 | + }); |
| 87 | + |
| 88 | + expect(log.warn).not.toHaveBeenCalled(); |
| 89 | + }); |
| 90 | +}); |
0 commit comments