fix underlying data drilldown for Lens (#82737)
This commit is contained in:
parent
b0eb277983
commit
d83167629c
|
@ -139,6 +139,44 @@ describe('embeddable', () => {
|
||||||
| expression`);
|
| expression`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should initialize output with deduped list of index patterns', async () => {
|
||||||
|
attributeService = attributeServiceMockFromSavedVis({
|
||||||
|
...savedVis,
|
||||||
|
references: [
|
||||||
|
{ type: 'index-pattern', id: '123', name: 'abc' },
|
||||||
|
{ type: 'index-pattern', id: '123', name: 'def' },
|
||||||
|
{ type: 'index-pattern', id: '456', name: 'ghi' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const embeddable = new Embeddable(
|
||||||
|
{
|
||||||
|
timefilter: dataPluginMock.createSetupContract().query.timefilter.timefilter,
|
||||||
|
attributeService,
|
||||||
|
expressionRenderer,
|
||||||
|
basePath,
|
||||||
|
indexPatternService: ({
|
||||||
|
get: (id: string) => Promise.resolve({ id }),
|
||||||
|
} as unknown) as IndexPatternsContract,
|
||||||
|
editable: true,
|
||||||
|
getTrigger,
|
||||||
|
documentToExpression: () =>
|
||||||
|
Promise.resolve({
|
||||||
|
type: 'expression',
|
||||||
|
chain: [
|
||||||
|
{ type: 'function', function: 'my', arguments: {} },
|
||||||
|
{ type: 'function', function: 'expression', arguments: {} },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{} as LensEmbeddableInput
|
||||||
|
);
|
||||||
|
await embeddable.initializeSavedVis({} as LensEmbeddableInput);
|
||||||
|
const outputIndexPatterns = embeddable.getOutput().indexPatterns!;
|
||||||
|
expect(outputIndexPatterns.length).toEqual(2);
|
||||||
|
expect(outputIndexPatterns[0].id).toEqual('123');
|
||||||
|
expect(outputIndexPatterns[1].id).toEqual('456');
|
||||||
|
});
|
||||||
|
|
||||||
it('should re-render if new input is pushed', async () => {
|
it('should re-render if new input is pushed', async () => {
|
||||||
const timeRange: TimeRange = { from: 'now-15d', to: 'now' };
|
const timeRange: TimeRange = { from: 'now-15d', to: 'now' };
|
||||||
const query: Query = { language: 'kquery', query: '' };
|
const query: Query = { language: 'kquery', query: '' };
|
||||||
|
|
|
@ -259,8 +259,10 @@ export class Embeddable
|
||||||
if (!this.savedVis) {
|
if (!this.savedVis) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const promises = this.savedVis.references
|
const promises = _.uniqBy(
|
||||||
.filter(({ type }) => type === 'index-pattern')
|
this.savedVis.references.filter(({ type }) => type === 'index-pattern'),
|
||||||
|
'id'
|
||||||
|
)
|
||||||
.map(async ({ id }) => {
|
.map(async ({ id }) => {
|
||||||
try {
|
try {
|
||||||
return await this.deps.indexPatternService.get(id);
|
return await this.deps.indexPatternService.get(id);
|
||||||
|
|
|
@ -8,7 +8,14 @@ import expect from '@kbn/expect';
|
||||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||||
|
|
||||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
const PageObjects = getPageObjects(['header', 'common', 'dashboard', 'timePicker', 'lens']);
|
const PageObjects = getPageObjects([
|
||||||
|
'header',
|
||||||
|
'common',
|
||||||
|
'dashboard',
|
||||||
|
'timePicker',
|
||||||
|
'lens',
|
||||||
|
'discover',
|
||||||
|
]);
|
||||||
|
|
||||||
const find = getService('find');
|
const find = getService('find');
|
||||||
const dashboardAddPanel = getService('dashboardAddPanel');
|
const dashboardAddPanel = getService('dashboardAddPanel');
|
||||||
|
@ -18,6 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
const testSubjects = getService('testSubjects');
|
const testSubjects = getService('testSubjects');
|
||||||
const filterBar = getService('filterBar');
|
const filterBar = getService('filterBar');
|
||||||
const security = getService('security');
|
const security = getService('security');
|
||||||
|
const panelActions = getService('dashboardPanelActions');
|
||||||
|
|
||||||
async function clickInChart(x: number, y: number) {
|
async function clickInChart(x: number, y: number) {
|
||||||
const el = await elasticChart.getCanvas();
|
const el = await elasticChart.getCanvas();
|
||||||
|
@ -27,7 +35,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
describe('lens dashboard tests', () => {
|
describe('lens dashboard tests', () => {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await PageObjects.common.navigateToApp('dashboard');
|
await PageObjects.common.navigateToApp('dashboard');
|
||||||
await security.testUser.setRoles(['global_dashboard_all', 'test_logstash_reader'], false);
|
await security.testUser.setRoles(
|
||||||
|
['global_dashboard_all', 'global_discover_all', 'test_logstash_reader'],
|
||||||
|
false
|
||||||
|
);
|
||||||
});
|
});
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await security.testUser.restoreDefaults();
|
await security.testUser.restoreDefaults();
|
||||||
|
@ -68,6 +79,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
const hasIpFilter = await filterBar.hasFilter('ip', '97.220.3.248');
|
const hasIpFilter = await filterBar.hasFilter('ip', '97.220.3.248');
|
||||||
expect(hasIpFilter).to.be(true);
|
expect(hasIpFilter).to.be(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be able to drill down to discover', async () => {
|
||||||
|
await PageObjects.common.navigateToApp('dashboard');
|
||||||
|
await PageObjects.dashboard.clickNewDashboard();
|
||||||
|
await dashboardAddPanel.clickOpenAddPanel();
|
||||||
|
await dashboardAddPanel.filterEmbeddableNames('lnsXYvis');
|
||||||
|
await find.clickByButtonText('lnsXYvis');
|
||||||
|
await dashboardAddPanel.closeAddPanel();
|
||||||
|
await PageObjects.lens.goToTimeRange();
|
||||||
|
await PageObjects.dashboard.saveDashboard('lnsDrilldown');
|
||||||
|
await panelActions.openContextMenu();
|
||||||
|
await testSubjects.clickWhenNotDisabled('embeddablePanelAction-ACTION_EXPLORE_DATA');
|
||||||
|
await PageObjects.discover.waitForDiscoverAppOnScreen();
|
||||||
|
|
||||||
|
const el = await testSubjects.find('indexPattern-switch-link');
|
||||||
|
const text = await el.getVisibleText();
|
||||||
|
|
||||||
|
expect(text).to.be('logstash-*');
|
||||||
|
});
|
||||||
|
|
||||||
it('should be able to add filters by clicking in pie chart', async () => {
|
it('should be able to add filters by clicking in pie chart', async () => {
|
||||||
await PageObjects.common.navigateToApp('dashboard');
|
await PageObjects.common.navigateToApp('dashboard');
|
||||||
await PageObjects.dashboard.clickNewDashboard();
|
await PageObjects.dashboard.clickNewDashboard();
|
||||||
|
|
Loading…
Reference in a new issue