Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed Nov 3, 2024
1 parent b876658 commit b82eb04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ const registerHttpRequestMockHelpers = (
const setSimulateTemplateResponse = (response?: HttpResponse, error?: ResponseError) =>
mockResponse('POST', `${API_BASE_PATH}/index_templates/simulate`, response, error);

const setSimulateTemplateByNameResponse = (
name: string,
response?: HttpResponse,
error?: ResponseError
) => mockResponse('POST', `${API_BASE_PATH}/index_templates/simulate/${name}`, response, error);

const setLoadComponentTemplatesResponse = (response?: HttpResponse, error?: ResponseError) =>
mockResponse('GET', `${API_BASE_PATH}/component_templates`, response, error);

Expand Down Expand Up @@ -229,6 +235,7 @@ const registerHttpRequestMockHelpers = (
setLoadIndexStatsResponse,
setUpdateIndexSettingsResponse,
setSimulateTemplateResponse,
setSimulateTemplateByNameResponse,
setLoadComponentTemplatesResponse,
setLoadNodesPluginsResponse,
setLoadTelemetryResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ describe('Index Templates tab', () => {
const { find, actions, exists } = testBed;

httpRequestsMockHelpers.setLoadTemplateResponse(templates[0].name, template);
httpRequestsMockHelpers.setSimulateTemplateResponse({ simulateTemplate: 'response' });
httpRequestsMockHelpers.setSimulateTemplateByNameResponse(templates[0].name, {
simulateTemplate: 'response',
});

await actions.clickTemplateAt(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD
async (context, request, response) => {
const { client } = (await context.core).elasticsearch;
const template = request.body as TypeOf<typeof bodySchema>;
// Until ES fixes a bug on their side we need to send a fake index pattern
// that won't match any indices.
// Issue: https://github.com/elastic/elasticsearch/issues/59152
// eslint-disable-next-line @typescript-eslint/naming-convention
const index_patterns = ['a_fake_index_pattern_that_wont_match_any_indices'];
const templateName = request.params.templateName;
Expand All @@ -38,9 +41,6 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD
: {
body: {
...template,
// Until ES fixes a bug on their side we need to send a fake index pattern
// that won't match any indices.
// Issue: https://github.com/elastic/elasticsearch/issues/59152
index_patterns,
},
};
Expand Down

0 comments on commit b82eb04

Please sign in to comment.