Skip to content

Commit

Permalink
fix: πŸ› pass whole action context to isCompatible() method (#43457)
Browse files Browse the repository at this point in the history
* fix: πŸ› pass whole action context to isCompatible() method

* test: πŸ’ add function test for saved search filtering in pie

* test: πŸ’ move save search functional test in its own test suite
  • Loading branch information
streamich authored Aug 19, 2019
1 parent c05598f commit d216659
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ const executeSingleAction = async (action: Action, actionContext: ActionContext)
export const executeTriggerActions: EmbeddableApiPure['executeTriggerActions'] = ({
api,
}) => async (triggerId, actionContext) => {
const actions = await api.getTriggerCompatibleActions!(triggerId, {
embeddable: actionContext.embeddable,
});
const actions = await api.getTriggerCompatibleActions!(triggerId, actionContext);

if (!actions.length) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,30 @@ test('shows a context menu when more than one action is mapped to a trigger', as
expect(executeFn).toBeCalledTimes(0);
expect(openContextMenu).toHaveBeenCalledTimes(1);
});

test('passes whole action context to isCompatible()', async () => {
const { setup, doStart } = embeddables;
const trigger = {
id: 'MY-TRIGGER',
title: 'My trigger',
actionIds: ['test'],
};
const action = new TestAction('test', ({ triggerContext }) => {
expect(triggerContext).toEqual({
foo: 'bar',
});
return true;
});

setup.registerTrigger(trigger);
setup.registerAction(action);
const start = doStart();

const context = {
embeddable: {} as any,
triggerContext: {
foo: 'bar',
},
};
await start.executeTriggerActions('MY-TRIGGER', context);
});
18 changes: 18 additions & 0 deletions test/functional/apps/dashboard/dashboard_filter_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,23 @@ export default function ({ getService, getPageObjects }) {
await pieChart.expectPieSliceCount(1);
});
});

describe('saved search filtering', function () {
before(async () => {
await filterBar.ensureFieldEditorModalIsClosed();
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
});

it('are added when pie chart legend item is clicked', async function () {
await dashboardAddPanel.addVisualization('Rendering Test: pie');
await PageObjects.dashboard.waitForRenderComplete();
await pieChart.filterByLegendItem('4,886');

const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(1);
});
});
});
}
6 changes: 6 additions & 0 deletions test/functional/services/visualizations/pie_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export function PieChartProvider({ getService }) {
}
}

async filterByLegendItem(label) {
log.debug(`PieChart.filterByLegendItem(${label})`);
await testSubjects.click(`legend-${label}`);
await testSubjects.click(`legend-${label}-filterIn`);
}

async getPieSlice(name) {
return await testSubjects.find(`pieSlice-${name.split(' ').join('-')}`);
}
Expand Down

0 comments on commit d216659

Please sign in to comment.