Skip to content
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 @@ -35,7 +35,7 @@ const data = [
];

describe('CustomLink', () => {
let callApmApiSpy: Function;
let callApmApiSpy: jasmine.Spy;
beforeAll(() => {
callApmApiSpy = spyOn(apmApi, 'callApmApi').and.returnValue({});
});
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('CustomLink', () => {
]);
});

it('checks if create custom link button is available and working', () => {
it('checks if create custom link button is available and working', async () => {
const { queryByText, getByText } = render(
<LicenseContext.Provider value={goldLicense}>
<MockApmPluginContextWrapper>
Expand All @@ -113,6 +113,7 @@ describe('CustomLink', () => {
act(() => {
fireEvent.click(getByText('Create custom link'));
});
await wait(() => expect(callApmApiSpy).toHaveBeenCalled());
expect(queryByText('Create link')).toBeInTheDocument();
});
});
Expand Down Expand Up @@ -144,8 +145,10 @@ describe('CustomLink', () => {
act(() => {
fireEvent.click(component.getByText('Create custom link'));
});
await wait(() => component.queryByText('Create link'));
expect(component.queryByText('Create link')).toBeInTheDocument();
await wait(() =>
expect(component.queryByText('Create link')).toBeInTheDocument()
);
await wait(() => expect(callApmApiSpy).toHaveBeenCalled());
return component;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React from 'react';
import { render, fireEvent, act } from '@testing-library/react';
import { render, fireEvent, act, wait } from '@testing-library/react';
import { TransactionActionMenu } from '../TransactionActionMenu';
import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
import * as Transactions from './mockData';
Expand Down Expand Up @@ -143,8 +143,9 @@ describe('TransactionActionMenu component', () => {
});

describe('Custom links', () => {
let callApmApiSpy: jasmine.Spy;
beforeAll(() => {
spyOn(apmApi, 'callApmApi').and.returnValue({});
callApmApiSpy = spyOn(apmApi, 'callApmApi').and.returnValue({});
});
afterAll(() => {
jest.resetAllMocks();
Expand Down Expand Up @@ -257,7 +258,7 @@ describe('TransactionActionMenu component', () => {
});
expectTextsInDocument(component, ['Custom Links']);
});
it('opens flyout with filters prefilled', () => {
it('opens flyout with filters prefilled', async () => {
const license = new License({
signature: 'test signature',
license: {
Expand Down Expand Up @@ -287,6 +288,7 @@ describe('TransactionActionMenu component', () => {
fireEvent.click(component.getByText('Create custom link'));
});
expectTextsInDocument(component, ['Create link']);
await wait(() => expect(callApmApiSpy).toHaveBeenCalled());
const getFilterKeyValue = (key: string) => {
return {
[(component.getAllByText(key)[0] as HTMLOptionElement)
Expand Down