Skip to content

Commit

Permalink
[ILM] Fix jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliacech committed Jul 31, 2020
1 parent e9575f4 commit 8ad94dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ describe('edit policy', () => {
beforeEach(() => {
server.respondImmediately = true;
httpRequestsMockHelpers.setNodesListResponse({});
httpRequestsMockHelpers.setNodesDetailsResponse('attribute:true', [
{ nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } },
]);
});

test('should show number required error when trying to save empty warm phase', async () => {
Expand Down Expand Up @@ -395,7 +398,9 @@ describe('edit policy', () => {
rendered.update();
const flyoutButton = findTestSubject(rendered, 'warm-viewNodeDetailsFlyoutButton');
expect(flyoutButton.exists()).toBeTruthy();
flyoutButton.simulate('click');
await act(async () => {
await flyoutButton.simulate('click');
});
rendered.update();
expect(rendered.find('.euiFlyout').exists()).toBeTruthy();
});
Expand All @@ -404,6 +409,9 @@ describe('edit policy', () => {
beforeEach(() => {
server.respondImmediately = true;
httpRequestsMockHelpers.setNodesListResponse({});
httpRequestsMockHelpers.setNodesDetailsResponse('attribute:true', [
{ nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } },
]);
});
test('should allow 0 for phase timing', async () => {
const rendered = mountWithIntl(component);
Expand Down Expand Up @@ -470,7 +478,9 @@ describe('edit policy', () => {
rendered.update();
const flyoutButton = findTestSubject(rendered, 'cold-viewNodeDetailsFlyoutButton');
expect(flyoutButton.exists()).toBeTruthy();
flyoutButton.simulate('click');
await act(async () => {
await flyoutButton.simulate('click');
});
rendered.update();
expect(rendered.find('.euiFlyout').exists()).toBeTruthy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => {
]);
};

const setNodesDetailsResponse = (nodeAttributes: string, response: HttpResponse = []) => {
server.respondWith(`/api/index_lifecycle_management/nodes/${nodeAttributes}/details`, [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify(response),
]);
};

return {
setPoliciesResponse,
setNodesListResponse,
setNodesDetailsResponse,
};
};

Expand Down

0 comments on commit 8ad94dc

Please sign in to comment.