mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Reporting] reduce any
usage in test code (#122413)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
1b971c90c3
commit
526f2fd545
5 changed files with 10 additions and 13 deletions
|
@ -51,7 +51,6 @@ beforeEach(async () => {
|
|||
stream = { write: jest.fn((chunk) => (content += chunk)) } as unknown as typeof stream;
|
||||
|
||||
const mockReportingConfig = createMockConfigSchema({
|
||||
index: '.reporting-2018.10.10',
|
||||
encryptionKey: mockEncryptionKey,
|
||||
queue: {
|
||||
indexInterval: 'daily',
|
||||
|
|
|
@ -52,7 +52,6 @@ beforeEach(async () => {
|
|||
stream = { write: jest.fn((chunk) => (content += chunk)) } as unknown as typeof stream;
|
||||
|
||||
const mockReportingConfig = createMockConfigSchema({
|
||||
index: '.reporting-2018.10.10',
|
||||
encryptionKey: mockEncryptionKey,
|
||||
queue: {
|
||||
indexInterval: 'daily',
|
||||
|
|
|
@ -38,7 +38,6 @@ describe(`GET ${API_GET_ILM_POLICY_STATUS}`, () => {
|
|||
timeout: 10000,
|
||||
pollEnabled: true,
|
||||
},
|
||||
index: '.reporting',
|
||||
}),
|
||||
createMockPluginSetup({
|
||||
security,
|
||||
|
|
|
@ -37,7 +37,6 @@ describe('POST /api/reporting/generate', () => {
|
|||
timeout: 10000,
|
||||
pollEnabled: true,
|
||||
},
|
||||
index: '.reporting',
|
||||
});
|
||||
|
||||
const mockLogger = createMockLevelLogger();
|
||||
|
|
|
@ -14,11 +14,12 @@ import { coreMock, elasticsearchServiceMock, statusServiceMock } from 'src/core/
|
|||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { dataPluginMock } from 'src/plugins/data/server/mocks';
|
||||
import { FieldFormatsRegistry } from 'src/plugins/field_formats/common';
|
||||
import { DeepPartial } from 'utility-types';
|
||||
import { ReportingConfig, ReportingCore } from '../';
|
||||
import { featuresPluginMock } from '../../../features/server/mocks';
|
||||
import { securityMock } from '../../../security/server/mocks';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { createMockScreenshottingStart } from '../../../screenshotting/server/mock';
|
||||
import { securityMock } from '../../../security/server/mocks';
|
||||
import { taskManagerMock } from '../../../task_manager/server/mocks';
|
||||
import { ReportingConfigType } from '../config';
|
||||
import { ReportingInternalSetup, ReportingInternalStart } from '../core';
|
||||
|
@ -26,13 +27,15 @@ import { ReportingStore } from '../lib';
|
|||
import { setFieldFormats } from '../services';
|
||||
import { createMockLevelLogger } from './create_mock_levellogger';
|
||||
|
||||
export const createMockPluginSetup = (setupMock?: any): ReportingInternalSetup => {
|
||||
export const createMockPluginSetup = (
|
||||
setupMock: Partial<Record<keyof ReportingInternalSetup, any>>
|
||||
): ReportingInternalSetup => {
|
||||
return {
|
||||
features: featuresPluginMock.createSetup(),
|
||||
basePath: { set: jest.fn() },
|
||||
router: setupMock.router,
|
||||
security: securityMock.createSetup(),
|
||||
licensing: { license$: Rx.of({ isAvailable: true, isActive: true, type: 'basic' }) } as any,
|
||||
licensing: { license$: Rx.of({ isAvailable: true, isActive: true, type: 'basic' }) },
|
||||
taskManager: taskManagerMock.createSetup(),
|
||||
logger: createMockLevelLogger(),
|
||||
status: statusServiceMock.createSetupContract(),
|
||||
|
@ -46,7 +49,7 @@ const createMockReportingStore = () => ({} as ReportingStore);
|
|||
|
||||
export const createMockPluginStart = (
|
||||
mockReportingCore: ReportingCore | undefined,
|
||||
startMock?: any
|
||||
startMock: Partial<Record<keyof ReportingInternalStart, any>>
|
||||
): ReportingInternalStart => {
|
||||
const store = mockReportingCore
|
||||
? new ReportingStore(mockReportingCore, logger)
|
||||
|
@ -61,7 +64,7 @@ export const createMockPluginStart = (
|
|||
taskManager: {
|
||||
schedule: jest.fn().mockImplementation(() => ({ id: 'taskId' })),
|
||||
ensureScheduled: jest.fn(),
|
||||
} as any,
|
||||
},
|
||||
logger: createMockLevelLogger(),
|
||||
screenshotting: startMock.screenshotting || createMockScreenshottingStart(),
|
||||
...startMock,
|
||||
|
@ -75,12 +78,10 @@ interface ReportingConfigTestType {
|
|||
kibanaServer: Partial<ReportingConfigType['kibanaServer']>;
|
||||
csv: Partial<ReportingConfigType['csv']>;
|
||||
roles?: Partial<ReportingConfigType['roles']>;
|
||||
capture: any;
|
||||
server?: any;
|
||||
}
|
||||
|
||||
export const createMockConfigSchema = (
|
||||
overrides: Partial<ReportingConfigTestType> = {}
|
||||
overrides: DeepPartial<ReportingConfigType> = {}
|
||||
): ReportingConfigType => {
|
||||
// deeply merge the defaults and the provided partial schema
|
||||
return {
|
||||
|
@ -106,7 +107,7 @@ export const createMockConfigSchema = (
|
|||
enabled: false,
|
||||
...overrides.roles,
|
||||
},
|
||||
} as any;
|
||||
} as ReportingConfigType;
|
||||
};
|
||||
|
||||
export const createMockConfig = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue