test component rendering w/ new annotation

Test that the Splunk On Call component properly
renders when a `splunk.com/on-call-routing-key`
annotation is used.

Signed-off-by: Mike Ball <mikedball@gmail.com>
This commit is contained in:
Mike Ball
2022-02-03 20:30:09 -05:00
parent 07ffc7ca9d
commit 5669e32ac1
@@ -131,6 +131,35 @@ describe('SplunkOnCallCard', () => {
expect(getByText('Empty escalation policy')).toBeInTheDocument();
});
it('handles a "splunk.com/on-call-routing-key" annotation', async () => {
mockSplunkOnCallApi.getUsers = jest
.fn()
.mockImplementationOnce(async () => [MOCKED_USER]);
mockSplunkOnCallApi.getRoutingKeys = jest
.fn()
.mockImplementationOnce(async () => [MOCK_ROUTING_KEY]);
mockSplunkOnCallApi.getTeams = jest
.fn()
.mockImplementation(async () => [MOCK_TEAM]);
const { getByText, queryByTestId } = render(
wrapInTestApp(
<ApiProvider apis={apis}>
<EntityProvider entity={mockEntityWithRoutingKeyAnnotation}>
<EntitySplunkOnCallCard />
</EntityProvider>
</ApiProvider>,
),
);
await waitFor(() => !queryByTestId('progress'));
expect(getByText(`Team: ${MOCK_TEAM.name}`)).toBeInTheDocument();
await waitFor(
() =>
expect(getByText(MOCK_INCIDENT.entityDisplayName)).toBeInTheDocument(),
{ timeout: 2000 },
);
});
it('Handles custom error for missing token', async () => {
mockSplunkOnCallApi.getUsers = jest
.fn()