Removes testId prop and change specs accordingly
This commit is contained in:
@@ -138,7 +138,7 @@ describe('PageDutyCard', () => {
|
||||
.fn()
|
||||
.mockImplementationOnce(async () => [service]);
|
||||
|
||||
const { getByText, queryByTestId, getByTestId, getByRole } = render(
|
||||
const { getByText, queryByTestId, getByRole } = render(
|
||||
wrapInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<EntityProvider entity={entity}>
|
||||
@@ -149,8 +149,8 @@ describe('PageDutyCard', () => {
|
||||
);
|
||||
await waitFor(() => !queryByTestId('progress'));
|
||||
expect(getByText('Service Directory')).toBeInTheDocument();
|
||||
expect(getByText('Create Incident')).toBeInTheDocument();
|
||||
const triggerLink = getByTestId('trigger-link');
|
||||
|
||||
const triggerLink = getByText('Create Incident');
|
||||
await act(async () => {
|
||||
fireEvent.click(triggerLink);
|
||||
});
|
||||
|
||||
@@ -94,7 +94,6 @@ export const PagerDutyCard = () => {
|
||||
onClick: showDialog,
|
||||
icon: <AlarmAddIcon />,
|
||||
color: 'secondary',
|
||||
testId: 'trigger-link',
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { act, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { act, fireEvent, screen, waitFor } from '@testing-library/react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import {
|
||||
ApiRegistry,
|
||||
@@ -63,7 +63,7 @@ describe('TriggerButton', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const { queryByRole, getByRole, getByTestId } = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<EntityProvider entity={entity}>
|
||||
<TriggerButton />
|
||||
@@ -71,25 +71,22 @@ describe('TriggerButton', () => {
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
expect(getByTestId('trigger-button')).toBeInTheDocument();
|
||||
expect(queryByRole('dialog')).not.toBeInTheDocument();
|
||||
|
||||
const triggerButton = getByTestId('trigger-button');
|
||||
expect(triggerButton.textContent).toBe('Create Incident');
|
||||
const triggerButton = screen.getByText('Create Incident');
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(triggerButton);
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(getByRole('dialog')).toBeInTheDocument();
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const closeButton = getByTestId('close-button');
|
||||
const closeButton = screen.getByText('Close');
|
||||
await act(async () => {
|
||||
fireEvent.click(closeButton);
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(queryByRole('dialog')).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -105,7 +102,7 @@ describe('TriggerButton', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const { getByTestId } = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<EntityProvider entity={entity}>
|
||||
<TriggerButton>Send an alert</TriggerButton>
|
||||
@@ -113,8 +110,7 @@ describe('TriggerButton', () => {
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
const triggerButton = getByTestId('trigger-button');
|
||||
expect(triggerButton.textContent).toBe('Send an alert');
|
||||
expect(screen.getByText('Send an alert')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a disabled trigger button if entity does not include key', async () => {
|
||||
@@ -126,7 +122,7 @@ describe('TriggerButton', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const { queryByRole, getByTestId } = await renderInTestApp(
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<EntityProvider entity={entity}>
|
||||
<TriggerButton />
|
||||
@@ -134,16 +130,13 @@ describe('TriggerButton', () => {
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
expect(getByTestId('trigger-button')).toBeInTheDocument();
|
||||
|
||||
const triggerButton = getByTestId('trigger-button');
|
||||
expect(triggerButton.textContent).toBe('Missing integration key');
|
||||
const triggerButton = screen.getByText('Missing integration key');
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(triggerButton);
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(queryByRole('dialog')).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,7 +50,6 @@ export function TriggerButton({
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
data-testid="trigger-button"
|
||||
onClick={showDialog}
|
||||
variant="contained"
|
||||
className={disabled ? '' : buttonStyle}
|
||||
|
||||
@@ -138,12 +138,7 @@ export const TriggerDialog = ({
|
||||
>
|
||||
Trigger Incident
|
||||
</Button>
|
||||
<Button
|
||||
data-testid="close-button"
|
||||
id="close"
|
||||
color="primary"
|
||||
onClick={handleDialog}
|
||||
>
|
||||
<Button id="close" color="primary" onClick={handleDialog}>
|
||||
Close
|
||||
</Button>
|
||||
</DialogActions>
|
||||
|
||||
Reference in New Issue
Block a user