diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts b/x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts index d76e6723c1be9..2a1f93f5b31ca 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/mocks.ts @@ -101,6 +101,7 @@ export const createMockedIndexPattern = (): IndexPattern => { hasRestrictions: false, fields, getFieldByName: getFieldByNameFactory(fields), + spec: undefined, }; }; @@ -140,6 +141,7 @@ export const createMockedRestrictedIndexPattern = () => { fieldFormatMap: { bytes: { id: 'bytes', params: { pattern: '0.0' } } }, fields, getFieldByName: getFieldByNameFactory(fields), + spec: undefined, typeMeta: { params: { rollup_index: 'my-fake-index-pattern', diff --git a/x-pack/plugins/lens/public/indexpattern_service/loader.test.ts b/x-pack/plugins/lens/public/indexpattern_service/loader.test.ts index 912028fba81a2..dc9edff3c31b7 100644 --- a/x-pack/plugins/lens/public/indexpattern_service/loader.test.ts +++ b/x-pack/plugins/lens/public/indexpattern_service/loader.test.ts @@ -64,6 +64,7 @@ describe('loader', () => { id: 'foo', title: 'Foo index', metaFields: [], + isPersisted: () => true, typeMeta: { aggs: { date_histogram: { @@ -100,7 +101,8 @@ describe('loader', () => { id: 'foo', title: 'Foo index', })), - } as unknown as Pick, + create: jest.fn(), + } as unknown as Pick, }); expect(cache.foo.getFieldByName('bytes')!.aggregationRestrictions).toEqual({ @@ -120,6 +122,7 @@ describe('loader', () => { id: 'foo', title: 'Foo index', metaFields: ['timestamp'], + isPersisted: () => true, typeMeta: { aggs: { date_histogram: { @@ -156,7 +159,8 @@ describe('loader', () => { id: 'foo', title: 'Foo index', })), - } as unknown as Pick, + create: jest.fn(), + } as unknown as Pick, }); expect(cache.foo.getFieldByName('timestamp')!.meta).toEqual(true); @@ -198,12 +202,13 @@ describe('loader', () => { timeFieldName: 'timestamp', hasRestrictions: false, fields: [], + isPersisted: () => true, }; } return Promise.reject(); }), getIdsWithTitle: jest.fn(), - } as unknown as Pick; + } as unknown as Pick; const cache = await loadIndexPatterns({ cache: {}, patterns: ['1', '2'], @@ -234,7 +239,7 @@ describe('loader', () => { throw err; }), getIdsWithTitle: jest.fn(), - } as unknown as Pick, + } as unknown as Pick, onError, }); diff --git a/x-pack/plugins/lens/public/indexpattern_service/mocks.ts b/x-pack/plugins/lens/public/indexpattern_service/mocks.ts index 6eb7156a91cff..048333786fdd6 100644 --- a/x-pack/plugins/lens/public/indexpattern_service/mocks.ts +++ b/x-pack/plugins/lens/public/indexpattern_service/mocks.ts @@ -42,6 +42,7 @@ const indexPattern1 = { title: 'my-fake-index-pattern', timeFieldName: 'timestamp', hasRestrictions: false, + isPersisted: () => true, fields: [ { name: 'timestamp', @@ -127,6 +128,7 @@ const indexPattern2 = { title: 'my-fake-restricted-pattern', timeFieldName: 'timestamp', hasRestrictions: true, + isPersisted: () => true, fieldFormatMap: { bytes: { id: 'bytes', params: { pattern: '0.0' } } }, fields: [ { @@ -198,7 +200,11 @@ export const sampleIndexPatterns = { export function mockDataViewsService() { return { get: jest.fn(async (id: '1' | '2') => { - const result = { ...sampleIndexPatternsFromService[id], metaFields: [] }; + const result = { + ...sampleIndexPatternsFromService[id], + metaFields: [], + isPersisted: () => true, + }; if (!result.fields) { result.fields = []; } @@ -216,5 +222,6 @@ export function mockDataViewsService() { }, ]; }), - } as unknown as Pick; + create: jest.fn(), + } as unknown as Pick; }