diff --git a/plugins/splunk-on-call/src/api/mocks.ts b/plugins/splunk-on-call/src/api/mocks.ts
index 86df04275d..22f1a87788 100644
--- a/plugins/splunk-on-call/src/api/mocks.ts
+++ b/plugins/splunk-on-call/src/api/mocks.ts
@@ -88,6 +88,12 @@ export const MOCK_TEAM: Team = {
isDefaultTeam: false,
};
+export const MOCK_TEAM_NO_INCIDENTS: Team = {
+ ...MOCK_TEAM,
+ name: 'test-noincidents',
+ slug: 'team-O9SqT13fsnCstjMj',
+};
+
export const ESCALATION_POLICIES: EscalationPolicyInfo[] = [
{
policy: {
diff --git a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx
index 365de7b732..838d9e4e4b 100644
--- a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx
+++ b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx
@@ -38,6 +38,7 @@ import {
MOCKED_USER,
MOCK_INCIDENT,
MOCK_TEAM,
+ MOCK_TEAM_NO_INCIDENTS,
} from '../api/mocks';
import { EntitySplunkOnCallCard } from './EntitySplunkOnCallCard';
@@ -82,16 +83,34 @@ const mockEntityData = {
} as Entity,
};
+const mockEntityDataNoIncidents = {
+ loading: false,
+ error: undefined,
+ entity: {
+ apiVersion: 'backstage.io/v1alpha1',
+ kind: 'Component',
+ metadata: {
+ name: 'splunkoncall-test',
+ annotations: {
+ 'splunk.com/on-call-team': 'test-noincidents',
+ },
+ },
+ } as Entity,
+};
+
describe('SplunkOnCallCard', () => {
it('Render splunkoncall', async () => {
mockSplunkOnCallApi.getUsers = jest
.fn()
.mockImplementationOnce(async () => [MOCKED_USER]);
+ mockSplunkOnCallApi.getTeams = jest
+ .fn()
+ .mockImplementation(async () => [MOCK_TEAM_NO_INCIDENTS]);
const { getByText, queryByTestId } = render(
wrapInTestApp(
-
+
,
@@ -148,10 +167,36 @@ describe('SplunkOnCallCard', () => {
).toBeInTheDocument();
});
+ it('handles warning for incorrect team annotation', async () => {
+ mockSplunkOnCallApi.getUsers = jest
+ .fn()
+ .mockImplementationOnce(async () => [MOCKED_USER]);
+ mockSplunkOnCallApi.getTeams = jest
+ .fn()
+ .mockImplementationOnce(async () => []);
+
+ const { getByText, queryByTestId } = render(
+ wrapInTestApp(
+
+
+
+
+ ,
+ ),
+ );
+ await waitFor(() => !queryByTestId('progress'));
+ expect(
+ getByText('Could not find team named "test" in the Splunk On-Call API'),
+ ).toBeInTheDocument();
+ });
+
it('opens the dialog when trigger button is clicked', async () => {
mockSplunkOnCallApi.getUsers = jest
.fn()
.mockImplementationOnce(async () => [MOCKED_USER]);
+ mockSplunkOnCallApi.getTeams = jest
+ .fn()
+ .mockImplementationOnce(async () => [MOCK_TEAM]);
const { getByText, queryByTestId, getByRole } = render(
wrapInTestApp(