From a53b32cdc48859f12c2c7dd880a6fe75910b5197 Mon Sep 17 00:00:00 2001 From: dej611 Date: Tue, 21 Dec 2021 17:42:41 +0100 Subject: [PATCH] :white_check_mark: Add indirect test for visible columns --- .../lens/public/app_plugin/app.test.tsx | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/x-pack/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/plugins/lens/public/app_plugin/app.test.tsx index 08f046925cb46..60b8e1c000434 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx @@ -779,6 +779,40 @@ describe('Lens App', () => { }); expect(getButton(instance).disableButton).toEqual(false); }); + + it('should show a warning tooltip if the datatable contains any char likely to be interpreted as a spreadsheet formula', async () => { + const services = makeDefaultServicesForApp(); + services.application = { + ...services.application, + capabilities: { + ...services.application.capabilities, + visualize: { save: false, saveQuery: false, show: true }, + }, + }; + + const { instance } = await mountWith({ + services, + preloadedState: { + isSaveable: true, + activeData: { + layer1: { + type: 'datatable', + // mind the indexpattern mock will return no columns to be visible + // we use this test to indirectly test the visible columns feature: + // the @myField name should trigger the warning tooltip check, but because + // of the mock no warning is shown + columns: [{ id: 'a', name: '@myField', meta: { type: 'number' } }], + rows: [], + }, + }, + }, + }); + const tooltipFn = getButton(instance).tooltip; + expect(tooltipFn).toEqual(expect.any(Function)); + if (typeof tooltipFn === 'function') { + expect(tooltipFn()).toEqual(undefined); + } + }); }); describe('inspector', () => {