Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] fix: 🐛 pass whole action context to isCompatible() method (#43457) #43524

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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