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

[Graph] Fix default discover url template building #47587

Merged
merged 2 commits into from
Oct 9, 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 @@ -14,6 +14,7 @@ import {
updateFieldProperties,
} from './fields';
import { AdvancedSettings, WorkspaceField, WorkspaceNode } from '../types';
import { loadTemplates, syncTemplatesSaga } from './url_templates';

/**
* This suite tests all the sagas that only exist to sync the legacy world
Expand All @@ -25,7 +26,13 @@ describe('legacy sync sagas', () => {

beforeEach(() => {
env = createMockGraphStore({
sagas: [syncSettingsSaga, updateSaveButtonSaga, syncFieldsSaga, syncNodeStyleSaga],
sagas: [
syncSettingsSaga,
updateSaveButtonSaga,
syncFieldsSaga,
syncNodeStyleSaga,
syncTemplatesSaga,
],
initialStateOverwrites: {
fields: {
field1: {
Expand Down Expand Up @@ -67,6 +74,12 @@ describe('legacy sync sagas', () => {
expect(env.mockedDeps.getWorkspace()!.options.exploreControls).toBe(newSettings);
});

it('syncs templates with workspace', () => {
env.store.dispatch(loadTemplates([]));
expect(env.mockedDeps.setUrlTemplates).toHaveBeenCalledWith([]);
expect(env.mockedDeps.notifyAngular).toHaveBeenCalled();
});

it('notifies angular when fields are selected', () => {
env.store.dispatch(selectField('field1'));
expect(env.mockedDeps.notifyAngular).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ describe('url_templates', () => {
);
expect(templates.length).toBe(1);
expect(templates[0].encoder).toBe(outlinkEncoders[0]);
expect(templates[0].url).toContain('test-pattern');
expect(templates[0].url).not.toContain('test-pattern');
expect(templates[0].url).toContain('123456');
expect(templates[0].isDefault).toBe(true);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function generateDefaultTemplate(
'_a',
rison.encode({
columns: ['_source'],
index: datasource.title,
index: datasource.id,
interval: 'auto',
query: { language: 'kuery', query: urlTemplatePlaceholder },
sort: ['_score', 'desc'],
Expand Down Expand Up @@ -106,6 +106,9 @@ export const syncTemplatesSaga = ({ setUrlTemplates, notifyAngular }: GraphStore
}

return function*() {
yield takeEvery(matchesOne(loadTemplates, saveTemplate, removeTemplate), syncTemplates);
yield takeEvery(
matchesOne(loadTemplates, saveTemplate, removeTemplate, requestDatasource, setDatasource),
syncTemplates
);
};
};