From 5669e32ac1ac5494eb4273ae516a673422687096 Mon Sep 17 00:00:00 2001 From: Mike Ball Date: Thu, 3 Feb 2022 20:30:09 -0500 Subject: [PATCH] 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 --- .../EntitySplunkOnCallCard.test.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx index 05d9a071c3..9c16752421 100644 --- a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx +++ b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx @@ -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( + + + + + , + ), + ); + 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()