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

[APM] Fix broken unit tests #161636

Merged
merged 1 commit into from
Jul 12, 2023
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 @@ -10,6 +10,7 @@ import React, { useState } from 'react';
import { CoreStart } from '@kbn/core/public';
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
import { TIME_UNITS } from '@kbn/triggers-actions-ui-plugin/public';
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
import { RuleParams, ErrorCountRuleType } from '.';
import { ENVIRONMENT_ALL } from '../../../../../common/environment_filter_values';
import { createCallApmApi } from '../../../../services/rest/create_call_apm_api';
Expand All @@ -36,11 +37,13 @@ const stories: Meta<{}> = {
createCallApmApi(coreMock);

return (
<KibanaReactContext.Provider>
<div style={{ width: 400 }}>
<StoryComponent />
</div>
</KibanaReactContext.Provider>
<IntlProvider locale="en">
<KibanaReactContext.Provider>
<div style={{ width: 400 }}>
<StoryComponent />
</div>
</KibanaReactContext.Provider>
</IntlProvider>
);
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { render } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import { createMemoryHistory, MemoryHistory } from 'history';
import { CoreStart } from '@kbn/core/public';
import React, { ReactNode } from 'react';
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
Expand All @@ -18,7 +18,7 @@ import * as useFetcherModule from '../../../hooks/use_fetcher';
import { ServiceMap } from '.';
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';

const history = createMemoryHistory();
let history: MemoryHistory<unknown>;

const KibanaReactContext = createKibanaReactContext({
usageCollection: { reportUiCounter: () => {} },
Expand Down Expand Up @@ -47,6 +47,7 @@ const expiredLicense = new License({
});

function createWrapper(license: License | null) {
history = createMemoryHistory();
history.replace('/service-map?rangeFrom=now-15m&rangeTo=now');

return ({ children }: { children?: ReactNode }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { queryByLabelText } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import { createMemoryHistory, MemoryHistory } from 'history';
import { CoreStart } from '@kbn/core/public';
import React from 'react';
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
Expand All @@ -32,9 +32,7 @@ const KibanaReactContext = createKibanaReactContext({
usageCollection: { reportUiCounter: () => {} },
} as unknown as Partial<CoreStart>);

const history = createMemoryHistory();
jest.spyOn(history, 'push');
jest.spyOn(history, 'replace');
let history: MemoryHistory<unknown>;

function setup({
urlParams,
Expand All @@ -43,6 +41,10 @@ function setup({
urlParams: ApmUrlParams;
serviceTransactionTypes: string[];
}) {
history = createMemoryHistory();
jest.spyOn(history, 'push');
jest.spyOn(history, 'replace');

history.replace({
pathname: '/services/foo/transactions',
search: fromQuery(urlParams),
Expand Down