Skip to content

Commit

Permalink
Fixes post master merge
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-tavares committed Apr 8, 2020
1 parent b331c3e commit db54693
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { HostResultList, HostStatus } from '../../../../../common/types';
import { HostInfo, HostResultList, HostStatus } from '../../../../../common/types';
import { EndpointDocGenerator } from '../../../../../common/generate_data';

export const mockHostResultList: (options?: {
Expand Down Expand Up @@ -44,7 +44,10 @@ export const mockHostResultList: (options?: {
/**
* returns a mocked API response for retrieving a single host metadata
*/
export const mockHostDetailsApiResult = (): ReturnType<typeof generator.generateHostMetadata> => {
export const mockHostDetailsApiResult = (): HostInfo => {
const generator = new EndpointDocGenerator('seed');
return generator.generateHostMetadata();
return {
metadata: generator.generateHostMetadata(),
host_status: HostStatus.ERROR,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
mockHostResultList,
} from '../../store/hosts/mock_host_result_list';
import { AppContextTestRender, createAppRootMockRenderer } from '../../mocks';
import { HostMetadata } from '../../../../../common/types';
import { HostInfo } from '../../../../../common/types';

describe('when on the hosts page', () => {
let render: () => ReturnType<AppContextTestRender['render']>;
Expand Down Expand Up @@ -62,6 +62,16 @@ describe('when on the hosts page', () => {
describe('when the user clicks the hostname in the table', () => {
let renderResult: reactTestingLibrary.RenderResult;
beforeEach(async () => {
const hostDetailsApiResponse = mockHostDetailsApiResult();

coreStart.http.get.mockReturnValue(Promise.resolve(hostDetailsApiResponse));
reactTestingLibrary.act(() => {
store.dispatch({
type: 'serverReturnedHostDetails',
payload: hostDetailsApiResponse,
});
});

renderResult = render();
const detailsLink = await renderResult.findByTestId('hostnameCellLink');
if (detailsLink) {
Expand All @@ -79,14 +89,20 @@ describe('when on the hosts page', () => {
});

describe('when there is a selected host in the url', () => {
let hostDetails: HostMetadata;
let hostDetails: HostInfo;
beforeEach(() => {
const { host, ...details } = mockHostDetailsApiResult();
const {
host_status,
metadata: { host, ...details },
} = mockHostDetailsApiResult();
hostDetails = {
...details,
host: {
...host,
id: '1',
host_status,
metadata: {
...details,
host: {
...host,
id: '1',
},
},
};

Expand Down Expand Up @@ -129,7 +145,9 @@ describe('when on the hosts page', () => {
beforeEach(async () => {
const renderResult = render();
const linkToLogs = await renderResult.findByTestId('hostDetailsLinkToLogs');
reactTestingLibrary.act(() => fireEvent.click(linkToLogs));
reactTestingLibrary.act(() => {
fireEvent.click(linkToLogs);
});
});

it('should navigate to logs without full page refresh', async () => {
Expand Down

0 comments on commit db54693

Please sign in to comment.